YARP
Yet Another Robot Platform
broker.h
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 
9 #ifndef YARP_MANAGER_BROKER
10 #define YARP_MANAGER_BROKER
11 
12 #include <string>
13 #include <vector>
14 
15 #include <yarp/manager/ymm-types.h>
16 
17 
18 namespace yarp {
19 namespace manager {
20 
21 
23 {
24 public:
25  virtual ~BrokerEventSink() {}
26  virtual void onBrokerStdout(const char* msg) {}
27  virtual void onBrokerModuleFailed() {}
28 };
29 
30 
34 class Broker {
35 
36 public:
37  Broker();
38  virtual ~Broker();
39  void setEventSink(BrokerEventSink* pEventSink);
40  virtual bool init() = 0; //only connector
41  virtual bool init(const char* szcmd, const char* szparam,
42  const char* szhost, const char* szstdio,
43  const char* szworkdir, const char* szenv ) = 0;
44  virtual void fini() = 0;
45  virtual bool start() = 0;
46  virtual bool stop() = 0;
47  virtual bool kill() = 0;
48  virtual bool connect(const char* from, const char* to,
49  const char* carrier, bool persist=false) = 0;
50  virtual bool disconnect(const char* from, const char* to,
51  const char* carrier) = 0;
52  virtual int running() = 0; // 0 if is not running and 1 if is running; otherwise -1.
53  virtual bool exists(const char* port) = 0;
54  virtual const char* requestRpc(const char* szport, const char* request, double timeout=0.0) = 0;
55  virtual bool connected(const char* from, const char* to,
56  const char* carrier) = 0;
57  virtual const char* error() = 0;
58  virtual bool initialized() = 0;
59  virtual bool attachStdout() = 0;
60  virtual void detachStdout() = 0;
61 
62  unsigned int generateID();
63 
64  void enableWatchDog() { bWithWatchDog = true; }
65  void disableWatchDog() { bWithWatchDog = false; }
66  bool hasWatchDog() { return bWithWatchDog; }
67  void setDisplay(const char* szDisplay) { if(szDisplay) { strDisplay = szDisplay; } }
68 
69  const char* getDisplay() const {return strDisplay.c_str(); }
70 protected:
71  unsigned int UNIQUEID;
74  std::string strDisplay;
75 
76 private:
77 
78 };
79 
80 } // namespace yarp
81 } // namespace manager
82 
83 
84 #endif // __YARP_MANAGER_BROKER__
yarp::manager::Broker::Broker
Broker()
Definition: broker.cpp:15
yarp::manager::Broker::detachStdout
virtual void detachStdout()=0
yarp::manager::Broker::setDisplay
void setDisplay(const char *szDisplay)
Definition: broker.h:67
yarp::manager::Broker::disableWatchDog
void disableWatchDog()
Definition: broker.h:65
yarp::manager::Broker::error
virtual const char * error()=0
yarp::manager::Broker::fini
virtual void fini()=0
yarp::manager::Broker::running
virtual int running()=0
yarp::manager::BrokerEventSink::onBrokerStdout
virtual void onBrokerStdout(const char *msg)
Definition: broker.h:26
yarp::manager::Broker
Class Broker.
Definition: broker.h:34
yarp::manager::Broker::hasWatchDog
bool hasWatchDog()
Definition: broker.h:66
yarp::manager::BrokerEventSink::~BrokerEventSink
virtual ~BrokerEventSink()
Definition: broker.h:25
yarp::manager::Broker::attachStdout
virtual bool attachStdout()=0
yarp::manager::Broker::init
virtual bool init()=0
yarp::manager::Broker::kill
virtual bool kill()=0
yarp::manager::Broker::disconnect
virtual bool disconnect(const char *from, const char *to, const char *carrier)=0
ymm-types.h
yarp::manager::Broker::initialized
virtual bool initialized()=0
yarp::manager::Broker::connect
virtual bool connect(const char *from, const char *to, const char *carrier, bool persist=false)=0
yarp::manager::Broker::requestRpc
virtual const char * requestRpc(const char *szport, const char *request, double timeout=0.0)=0
yarp::manager::Broker::generateID
unsigned int generateID()
Definition: broker.cpp:29
yarp::manager::Broker::eventSink
BrokerEventSink * eventSink
Definition: broker.h:72
yarp::manager::Broker::connected
virtual bool connected(const char *from, const char *to, const char *carrier)=0
yarp::manager::Broker::init
virtual bool init(const char *szcmd, const char *szparam, const char *szhost, const char *szstdio, const char *szworkdir, const char *szenv)=0
yarp::manager::Broker::~Broker
virtual ~Broker()
yarp::manager::BrokerEventSink::onBrokerModuleFailed
virtual void onBrokerModuleFailed()
Definition: broker.h:27
yarp::manager::Broker::strDisplay
std::string strDisplay
Definition: broker.h:74
yarp::manager::Broker::stop
virtual bool stop()=0
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::manager::Broker::enableWatchDog
void enableWatchDog()
Definition: broker.h:64
yarp::manager::Broker::bWithWatchDog
bool bWithWatchDog
Definition: broker.h:73
yarp::manager::Broker::UNIQUEID
unsigned int UNIQUEID
Definition: broker.h:71
yarp::manager::BrokerEventSink
Definition: broker.h:23
yarp::manager::Broker::exists
virtual bool exists(const char *port)=0
yarp::manager::Broker::getDisplay
const char * getDisplay() const
Definition: broker.h:69
yarp::manager::Broker::start
virtual bool start()=0
yarp::manager::Broker::setEventSink
void setEventSink(BrokerEventSink *pEventSink)
Definition: broker.cpp:24