YARP
Yet Another Robot Platform
RFModuleFactory.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
9
10#include <map>
11
12using namespace yarp::os;
13using namespace yarp::os::impl;
14
16{
17public:
18 std::map<std::string, RFModule* (*)(void)> delegates;
19};
20
21RFModuleFactory::RFModuleFactory() :
22 mPriv(new Private)
23{
24 //add embedded rfmodule here
25}
26
27RFModuleFactory& RFModuleFactory::GetInstance()
28{
29 static RFModuleFactory instance;
30 return instance;
31}
32
33void RFModuleFactory::AddModule(const std::string& name, RFModule* (*module)())
34{
35 GetInstance().mPriv->delegates[name] = module;
36}
37
38RFModule* RFModuleFactory::GetModule(const std::string& name)
39{
40 if (mPriv->delegates.find(name) != mPriv->delegates.end()) {
41 return mPriv->delegates[name]();
42 }
43
44 return nullptr;
45}
static RFModule * module
Definition: RFModule.cpp:231
std::map< std::string, RFModule *(*)(void)> delegates
A base-class for standard YARP modules that supports ResourceFinder.
Definition: RFModule.h:20
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.