NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
registerDevice.h
1 #ifndef NDSREGISTER_DEVICE_H
2 #define NDSREGISTER_DEVICE_H
3 
4 namespace nds
5 {
6 
10 template <class T>
11 class NDS3_API RegisterDevice
12 {
13 private:
14  const std::string m_driverName;
15 
16 public:
17  RegisterDevice(const char *driverName) : m_driverName(std::string(driverName)) {
19  }
20 
21  static void *allocateDevice(nds::Factory& factory, const std::string& device, const nds::namedParameters_t& parameters){
22  return new T(factory, device, parameters);
23  }
24 
25  static void deallocateDevice(void *device) {
26  delete (T *)device;
27  }
28 
29  const char *getDriverName() {
30  return m_driverName;
31  }
32 
33 protected:
35 
36 };
37 } /* namespace nds */
38 
39 
40 #endif /* NDSREGISTER_DEVICE_H */
This is a class intended to be used as a static class for automatic registering of device supports...
Definition: registerDevice.h:11
std::map< std::string, std::string > namedParameters_t
Map containing named parameters passed to the device during the initialization.
Definition: definitions.h:222
Communicates with a static instance of the control system.
Definition: factory.h:43
static void registerDriver(const std::string &driverName, allocateDriver_t allocateFunction, deallocateDriver_t deallocateFunction)
Register a device in the control system.