ifw-fcf  2.0.0
 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 FCF_DEVMGR_COMMON_DEVICEMAKER_HPP
10 #define FCF_DEVMGR_COMMON_DEVICEMAKER_HPP
11 
12 // System headers
13 #include <string>
14 
15 // Local headers
18 
19 namespace fcf {
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 }
64 #endif // FCF_DEVMGR_COMMON_DEVICEMAKER_HPP
static DeviceFactory & Instance()
Get instance of singleton.
Definition: deviceFactory.cpp:23
Config class header file.
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
void RegisterMaker(const std::string &key, IDeviceMaker *maker)
Register device maker.
Definition: deviceFactory.cpp:30
DeviceFactory class header file.
Definition: dataContext.hpp:81
Definition: deviceMaker.hpp:29
Definition: iDeviceMaker.hpp:26
DeviceMaker(const std::string &key)
DeviceMaker constructor.
Definition: deviceMaker.hpp:41