YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
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}
std::map< std::string, RFModule *(*)(void)> delegates
A mini-server for performing network communication in the background.
A base-class for standard YARP modules that supports ResourceFinder.
Definition RFModule.h:20
static void AddModule(const std::string &name, RFModule *(*moduleCreate)(void))
static RFModuleFactory & GetInstance()
RFModule * GetModule(const std::string &name)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.