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__
Class Broker.
Definition: broker.h:34
void threadRelease() override
Release method.
Definition: yarpbroker.cpp:810
const char * error() override
Definition: yarpbroker.cpp:760
bool connected(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:544
bool getAllPorts(std::vector< std::string > &stingList)
Definition: yarpbroker.cpp:613
const char * requestRpc(const char *szport, const char *request, double timeout) override
Definition: yarpbroker.cpp:502
bool init() override
Definition: yarpbroker.cpp:64
bool getSystemInfo(const char *server, yarp::os::SystemInfoSerializer &info)
Definition: yarpbroker.cpp:555
bool getAllProcesses(const char *server, ProcessContainer &processes)
Definition: yarpbroker.cpp:644
void detachStdout() override
Definition: yarpbroker.cpp:357
bool connect(const char *from, const char *to, const char *carrier, bool persist=false) override
connection broker
Definition: yarpbroker.cpp:383
void fini() override
Definition: yarpbroker.cpp:57
bool initialized() override
Definition: yarpbroker.h:59
bool rmconnect(const char *from, const char *to)
Definition: yarpbroker.cpp:688
bool threadInit() override
Initialization method.
Definition: yarpbroker.cpp:774
bool setQos(const char *from, const char *to, const char *qosFrom, const char *qosTo)
Definition: yarpbroker.cpp:702
bool disconnect(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:445
void run() override
Loop function.
Definition: yarpbroker.cpp:799
bool attachStdout() override
Definition: yarpbroker.cpp:352
bool exists(const char *port) override
Definition: yarpbroker.cpp:494
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
An abstraction for a periodic thread.
A class for storing options and configuration information.
Definition: Property.h:37
Preferences for the port's Quality of Service.
Definition: QosStyle.h:26
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:29
A helper class to pass the SystemInfo object around the YARP network.
std::vector< Process > ProcessContainer
Definition: primresource.h:152
The main, catch-all namespace for YARP.
Definition: environment.h:18