YARP
Yet Another Robot Platform
yarpbroker.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_YARPBROKER
10 #define YARP_MANAGER_YARPBROKER
11 
12 #include <string>
13 #include <iostream>
14 #include <yarp/os/Time.h>
15 #include <yarp/os/Port.h>
16 #include <yarp/os/BufferedPort.h>
17 #include <yarp/os/Network.h>
18 #include <yarp/os/Property.h>
19 #include <string>
20 #include <yarp/os/Semaphore.h>
21 #include <yarp/os/PeriodicThread.h>
22 
23 // FIXME Do not use yarp/os/impl in .h files
24 #include <yarp/os/SystemInfo.h>
26 
27 #include <yarp/manager/broker.h>
29 
30 namespace yarp {
31 namespace manager {
32 
33 
38 
39 public:
40  YarpBroker();
41  ~YarpBroker() override;
42  bool init() override;
43  bool init(const char* szcmd, const char* szparam,
44  const char* szhost, const char* szstdio,
45  const char* szworkdir, const char* szenv ) override;
46  void fini() override;
47  bool start() override;
48  bool stop() override;
49  bool kill() override;
50  bool connect(const char* from, const char* to,
51  const char* carrier, bool persist=false) override;
52  bool disconnect(const char* from, const char* to, const char* carrier) override;
53  bool rmconnect(const char* from, const char* to);
54  int running() override;
55  bool exists(const char* port) override;
56  const char* requestRpc(const char* szport, const char* request, double timeout) override;
57  bool connected(const char* from, const char* to, const char* carrier) override;
58  const char* error() override;
59  bool initialized() override { return bInitialized;}
60  bool attachStdout() override;
61  void detachStdout() override;
62 
63  bool getSystemInfo(const char* server,
65  bool getAllProcesses(const char* server,
66  ProcessContainer &processes);
67  bool getAllPorts(std::vector<std::string> &stingList);
68 
69  bool setQos(const char* from, const char* to,
70  const char* qosFrom, const char* qosTo);
71 
72 public: // for rate thread
73  void run() override;
74  bool threadInit() override;
75  void threadRelease() override;
76 
77 protected:
78 
79 private:
80  std::string strCmd;
81  std::string strParam;
82  std::string strHost;
83  std::string strStdio;
84  std::string strWorkdir;
85  std::string strTag;
86  std::string strEnv;
87  unsigned int ID;
88  yarp::os::Property command;
89  std::string strError;
90  bool bOnlyConnector;
91  bool bInitialized;
92  yarp::os::Semaphore semParam;
93  std::string strStdioUUID;
94  std::string __trace_message;
95 
97  //yarp::os::Port port;
98 
99  bool timeout(double base, double timeout);
100  yarp::os::Property& runProperty();
101  int requestServer(yarp::os::Property& config);
102  int SendMsg(yarp::os::Bottle& msg, std::string target,
103  yarp::os::Bottle& resp, float fTimeout=5.0);
104  bool getQosFromString(const char* qos, yarp::os::QosStyle& style);
105 
106 };
107 
108 } // namespace yarp
109 } // namespace manager
110 
111 
112 #endif // __YARP_MANAGER_YARPBROKER__
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::manager::YarpBroker::start
bool start() override
Definition: yarpbroker.cpp:181
Network.h
yarp::os::QosStyle
Preferences for the port's Quality of Service.
Definition: QosStyle.h:26
yarp::os::Semaphore
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:29
yarp::manager::YarpBroker::running
int running() override
Definition: yarpbroker.cpp:318
yarp::manager::YarpBroker::rmconnect
bool rmconnect(const char *from, const char *to)
Definition: yarpbroker.cpp:688
yarp::manager::YarpBroker::stop
bool stop() override
Definition: yarpbroker.cpp:222
yarp::manager::YarpBroker::getSystemInfo
bool getSystemInfo(const char *server, yarp::os::SystemInfoSerializer &info)
Definition: yarpbroker.cpp:555
Port.h
yarp::manager::YarpBroker::threadRelease
void threadRelease() override
Release method.
Definition: yarpbroker.cpp:810
yarp::manager::YarpBroker::run
void run() override
Loop function.
Definition: yarpbroker.cpp:799
yarp::manager::Broker
Class Broker.
Definition: broker.h:34
yarp::manager::YarpBroker::disconnect
bool disconnect(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:445
yarp::manager::YarpBroker::kill
bool kill() override
Definition: yarpbroker.cpp:269
yarp::os::BufferedPort< yarp::os::Bottle >
yarp::manager::YarpBroker::setQos
bool setQos(const char *from, const char *to, const char *qosFrom, const char *qosTo)
Definition: yarpbroker.cpp:702
yarp::manager::YarpBroker::detachStdout
void detachStdout() override
Definition: yarpbroker.cpp:357
yarp::manager::YarpBroker::fini
void fini() override
Definition: yarpbroker.cpp:57
yarp::manager::YarpBroker::getAllPorts
bool getAllPorts(std::vector< std::string > &stingList)
Definition: yarpbroker.cpp:613
Property.h
yarp::manager::ProcessContainer
std::vector< Process > ProcessContainer
Definition: primresource.h:152
primresource.h
yarp::manager::YarpBroker::threadInit
bool threadInit() override
Initialization method.
Definition: yarpbroker.cpp:774
yarp::manager::YarpBroker::connected
bool connected(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:544
yarp::manager::YarpBroker
Class Broker.
Definition: yarpbroker.h:37
Semaphore.h
BufferedPort.h
yarp::manager::YarpBroker::attachStdout
bool attachStdout() override
Definition: yarpbroker.cpp:352
yarp::manager::YarpBroker::connect
bool connect(const char *from, const char *to, const char *carrier, bool persist=false) override
connection broker
Definition: yarpbroker.cpp:383
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
yarp::manager::YarpBroker::initialized
bool initialized() override
Definition: yarpbroker.h:59
PeriodicThread.h
yarp::os::SystemInfoSerializer
A helper class to pass the SystemInfo object around the YARP network.
Definition: SystemInfoSerializer.h:24
yarp::manager::YarpBroker::error
const char * error() override
Definition: yarpbroker.cpp:760
yarp::manager::YarpBroker::getAllProcesses
bool getAllProcesses(const char *server, ProcessContainer &processes)
Definition: yarpbroker.cpp:644
yarp::manager::YarpBroker::init
bool init() override
Definition: yarpbroker.cpp:64
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
broker.h
yarp::manager::YarpBroker::YarpBroker
YarpBroker()
Definition: yarpbroker.cpp:44
yarp::manager::YarpBroker::requestRpc
const char * requestRpc(const char *szport, const char *request, double timeout) override
Definition: yarpbroker.cpp:502
Time.h
yarp::manager::YarpBroker::~YarpBroker
~YarpBroker() override
Definition: yarpbroker.cpp:52
yarp::manager::YarpBroker::exists
bool exists(const char *port) override
Definition: yarpbroker.cpp:494
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
SystemInfoSerializer.h
SystemInfo.h