YARP
Yet Another Robot Platform
RFModule.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_RFMODULE_H
11 #define YARP_OS_RFMODULE_H
12 
13 #include <yarp/os/Port.h>
14 #include <yarp/os/ResourceFinder.h>
15 #include <yarp/os/RpcServer.h>
16 
17 namespace yarp {
18 namespace os {
19 
24 {
25 public:
29  RFModule();
30 
34  virtual ~RFModule();
35 
43  virtual double getPeriod();
44 
63  virtual bool updateModule() = 0;
64 
87  virtual int runModule();
88 
96  virtual int runModule(yarp::os::ResourceFinder& rf);
97 
120  virtual int runModuleThreaded();
121 
130  virtual int runModuleThreaded(yarp::os::ResourceFinder& rf);
131 
135  virtual int getThreadKey();
136 
152  virtual bool configure(yarp::os::ResourceFinder& rf);
153 
165  virtual bool respond(const Bottle& command, Bottle& reply);
166 
173  virtual bool attach(yarp::os::Port& source);
174 
181  virtual bool attach(yarp::os::RpcServer& source);
182 
191  bool attachTerminal();
192 
196  bool detachTerminal();
197 
210  virtual bool interruptModule();
211 
222  virtual bool close();
223 
233  void stopModule(bool wait = false);
234 
240  bool isStopping();
241 
255  bool joinModule(double seconds = -1);
256 
271  std::string getName(const std::string& subName = "");
272 
278  void setName(const char* name);
279 
283  bool safeRespond(const Bottle& command, Bottle& reply);
284 
285 private:
286  ResourceFinder resourceFinder;
287  bool stopFlag;
288  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) name;
289 
290  virtual bool basicRespond(const Bottle& command, Bottle& reply);
291 
292 #ifndef DOXYGEN_SHOULD_SKIP_THIS
293 private:
294  class Private;
295  Private* mPriv;
296 #endif // DOXYGEN_SHOULD_SKIP_THIS
297 };
298 
299 } // namespace os
300 } // namespace yarp
301 
302 #endif // YARP_OS_RFMODULE_H
yarp::os::RFModule
A base-class for standard YARP modules that supports ResourceFinder.
Definition: RFModule.h:24
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
Port.h
YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:339
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::RFModule::updateModule
virtual bool updateModule()=0
Override this to do whatever your module needs to do.
RpcServer.h
yarp::os::RpcServer
A port that is specialized as an RPC server.
Definition: RpcServer.h:27
yarp::os::RFModule::Private
Definition: RFModule.cpp:185
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
ResourceFinder.h
yarp::os::ResourceFinder
Helper class for finding config files and other external resources.
Definition: ResourceFinder.h:33