ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
deviceFactory.hpp
Go to the documentation of this file.
1 
9 #ifndef DEVMGR_COMMON_DEVICEFACTORY_HPP
10 #define DEVMGR_COMMON_DEVICEFACTORY_HPP
11 
12 // System headers
13 #include <map>
14 #include <string>
15 
16 // Local headers
17 #include <devmgr/common/iDeviceMaker.hpp>
18 
19 namespace devmgr {
20  namespace common {
21 
22  class IDevice;
26  class DeviceFactory {
27  public:
28 
36  static DeviceFactory& Instance();
37 
45  void RegisterMaker(const std::string& key, IDeviceMaker * maker);
46 
47 
55  void DeregisterMaker(const std::string& key, IDeviceMaker * maker);
56 
65  std::shared_ptr<IDevice> Create(const std::string& filename,
66  const std::string& name,
67  DataContext& data_ctx) const;
68 
69  private:
70  // Disable copying and assignment
71  DeviceFactory() {}
72 
73  // Disable copying and assignment
74  DeviceFactory(const DeviceFactory& other);
75  DeviceFactory& operator=(const DeviceFactory& other);
76 
77 
79  std::map<std::string, IDeviceMaker* > m_makers;
80  };
81  }
82 }
83 
84 
85 
86 #endif //DEVMGR_COMMON_DEVICE_FACTORY_HPP
void DeregisterMaker(const std::string &key, IDeviceMaker *maker)
Deregister device maker.
Definition: deviceFactory.cpp:41
std::shared_ptr< IDevice > Create(const std::string &filename, const std::string &name, DataContext &data_ctx) const
Creates a new device.
Definition: deviceFactory.cpp:50
static DeviceFactory & Instance()
Get instance of singleton.
Definition: deviceFactory.cpp:22
void RegisterMaker(const std::string &key, IDeviceMaker *maker)
Register device maker.
Definition: deviceFactory.cpp:29
optional string name
Definition: topics.proto:50