ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
deviceMaker.hpp
Go to the documentation of this file.
1 
9 #ifndef DEVMGR_COMMON_DEVICEMAKER_HPP
10 #define DEVMGR_COMMON_DEVICEMAKER_HPP
11 
12 // System headers
13 #include <string>
14 
15 // Local headers
16 #include <devmgr/common/iDeviceMaker.hpp>
17 #include <devmgr/common/deviceFactory.hpp>
18 
19 
20 namespace devmgr {
21  namespace common {
22 
27  class IDevice;
28  template<typename T>
29  class DeviceMaker : public IDeviceMaker {
30  public:
31 
32 
41  explicit DeviceMaker(const std::string& key) {
43  }
44 
53  virtual std::shared_ptr<IDevice> Create(const std::string& filename,
54  const std::string& name,
55  DataContext& data_ctx) const {
56  // Create new instance of T using constructor from YAML::Node
57  // Assumes T has a constructor that accepts YAML::Node
58  return std::make_shared<T>(filename, name, data_ctx);
59  }
60  };
61  }
62 }
63 #endif // DEVMGR_COMMON_DEVICEMAKER_HPP
virtual std::shared_ptr< IDevice > Create(const std::string &filename, const std::string &name, DataContext &data_ctx) const
Create an instance of a device.
Definition: deviceMaker.hpp:53
Definition: dataContext.hpp:73
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
DeviceMaker(const std::string &key)
DeviceMaker constructor.
Definition: deviceMaker.hpp:41