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 
12 using namespace yarp::os;
13 
15 {
16 public:
17  std::map<std::string, RFModule* (*)(void)> delegates;
18 };
19 
20 RFModuleFactory::RFModuleFactory() :
21  mPriv(new Private)
22 {
23  //add embedded rfmodule here
24 }
25 
26 RFModuleFactory& RFModuleFactory::GetInstance()
27 {
28  static RFModuleFactory instance;
29  return instance;
30 }
31 
32 void RFModuleFactory::AddModule(const std::string& name, RFModule* (*module)())
33 {
34  GetInstance().mPriv->delegates[name] = module;
35 }
36 
37 RFModule* RFModuleFactory::GetModule(const std::string& name)
38 {
39  if (mPriv->delegates.find(name) != mPriv->delegates.end()) {
40  return mPriv->delegates[name]();
41  }
42 
43  return nullptr;
44 }
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:21
An interface to the operating system, including Port based communication.