ifw-fcf
4.1.0-pre2
devmgr
common
src
include
fcf
devmgr
common
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
16
#include <
fcf/devmgr/common/iDeviceMaker.hpp
>
17
#include <
fcf/devmgr/common/deviceFactory.hpp
>
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) {
42
DeviceFactory::Instance
().
RegisterMaker
(key,
this
);
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
iDeviceMaker.hpp
Config class header file.
deviceFactory.hpp
DeviceFactory class header file.
fcf::devmgr::common::DeviceFactory::Instance
static DeviceFactory & Instance()
Get instance of singleton.
Definition:
deviceFactory.cpp:29
fcf::devmgr::common::DeviceMaker
Definition:
deviceMaker.hpp:29
fcf::devmgr::common::DataContext
Definition:
dataContext.hpp:90
fcf
Definition:
actionMgr.cpp:29
fcf::devmgr::common::DeviceMaker::Create
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
fcf::devmgr::common::IDeviceMaker
Definition:
iDeviceMaker.hpp:27
fcf::devmgr::common::DeviceMaker::DeviceMaker
DeviceMaker(const std::string &key)
DeviceMaker constructor.
Definition:
deviceMaker.hpp:41
fcf::devmgr::common::DeviceFactory::RegisterMaker
void RegisterMaker(const std::string &key, IDeviceMaker *maker)
Register device maker.
Definition:
deviceFactory.cpp:37
Generated by
1.8.20