-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriverHelper.hpp
More file actions
32 lines (28 loc) · 775 Bytes
/
driverHelper.hpp
File metadata and controls
32 lines (28 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef TMP_AVR_DRIVER_HELPER_HPP
#define TMP_AVR_DRIVER_HELPER_HPP
/**
* @brief The DriverDeInitializer class provides a helper for
* RAII-style initialization and deinitialization of driver classes.
* The DeviceDriver_ must support initialization via a static
* initialize()
* method and deinitialization via a static
* deinitialize()
* method.
* An instance of this class now takes care to deinitialize the
* DeviceDriver_ when this instance goes out of scope.
*/
template<typename DeviceDriver_>
class DriverDeInitializer
{
public:
typedef DeviceDriver_ DeviceDriver;
DriverDeInitializer()
{
DeviceDriver::initialize();
}
~DriverDeInitializer()
{
DeviceDriver::deinitialize();
}
};
#endif // TMP_AVR_DRIVER_HELPER_HPP