YARP
Yet Another Robot Platform
RFModuleFactory.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 
12 
13 #include <map>
14 
15 using namespace std;
16 using namespace yarp::os;
17 
19 {
20 public:
21  map<string, RFModule* (*)(void)> delegates;
22 };
23 
24 RFModuleFactory::RFModuleFactory() :
25  mPriv(new Private)
26 {
27  //add embedded rfmodule here
28 }
29 
30 RFModuleFactory& RFModuleFactory::GetInstance()
31 {
32  static RFModuleFactory instance;
33  return instance;
34 }
35 
36 void RFModuleFactory::AddModule(const string& name, RFModule* (*module)())
37 {
38  GetInstance().mPriv->delegates[name] = module;
39 }
40 
41 RFModule* RFModuleFactory::GetModule(const string& name)
42 {
43  if (mPriv->delegates.find(name) != mPriv->delegates.end()) {
44  return mPriv->delegates[name]();
45  }
46 
47  return nullptr;
48 }
yarp::os::RFModule
A base-class for standard YARP modules that supports ResourceFinder.
Definition: RFModule.h:24
yarp::os::RFModuleFactory::Private::delegates
map< string, RFModule *(*)(void)> delegates
Definition: RFModuleFactory.cpp:21
YarpPluginSettings.h
yarp::os::RFModuleFactory::Private
Definition: RFModuleFactory.cpp:19
yarp::os::RFModuleFactory
Definition: RFModuleFactory.h:20
module
static RFModule * module
Definition: RFModule.cpp:234
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
RFModuleFactory.h