YARP
Yet Another Robot Platform
RFModule.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_RFMODULE_H
8 #define YARP_OS_RFMODULE_H
9 
10 #include <yarp/os/Port.h>
11 #include <yarp/os/ResourceFinder.h>
12 #include <yarp/os/RpcServer.h>
13 
14 namespace yarp {
15 namespace os {
16 
21 {
22 public:
26  RFModule();
27 
31  virtual ~RFModule();
32 
40  virtual double getPeriod();
41 
60  virtual bool updateModule() = 0;
61 
84  virtual int runModule();
85 
93  virtual int runModule(yarp::os::ResourceFinder& rf);
94 
117  virtual int runModuleThreaded();
118 
127  virtual int runModuleThreaded(yarp::os::ResourceFinder& rf);
128 
132  virtual int getThreadKey();
133 
149  virtual bool configure(yarp::os::ResourceFinder& rf);
150 
162  virtual bool respond(const Bottle& command, Bottle& reply);
163 
170  virtual bool attach(yarp::os::Port& source);
171 
178  virtual bool attach(yarp::os::RpcServer& source);
179 
188  bool attachTerminal();
189 
193  bool detachTerminal();
194 
207  virtual bool interruptModule();
208 
219  virtual bool close();
220 
230  void stopModule(bool wait = false);
231 
237  bool isStopping();
238 
252  bool joinModule(double seconds = -1);
253 
268  std::string getName(const std::string& subName = "");
269 
275  void setName(const char* name);
276 
280  bool safeRespond(const Bottle& command, Bottle& reply);
281 
282 private:
283  ResourceFinder resourceFinder;
284  bool stopFlag;
285  YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(std::string) name;
286 
287  virtual bool basicRespond(const Bottle& command, Bottle& reply);
288 
289 #ifndef DOXYGEN_SHOULD_SKIP_THIS
290 private:
291  class Private;
292  Private* mPriv;
293 #endif // DOXYGEN_SHOULD_SKIP_THIS
294 };
295 
296 } // namespace os
297 } // namespace yarp
298 
299 #endif // YARP_OS_RFMODULE_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
A mini-server for network communication.
Definition: Port.h:47
A base-class for standard YARP modules that supports ResourceFinder.
Definition: RFModule.h:21
virtual bool updateModule()=0
Override this to do whatever your module needs to do.
Helper class for finding config files and other external resources.
A port that is specialized as an RPC server.
Definition: RpcServer.h:24
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:336
#define YARP_os_API
Definition: api.h:18