BlueZero (BØ)
Middleware for distributed applications
service_client.h
1 #ifndef B0__SERVICE_CLIENT_H__INCLUDED
2 #define B0__SERVICE_CLIENT_H__INCLUDED
3 
4 #include <string>
5 
6 #include <b0/socket.h>
7 
8 namespace b0
9 {
10 
11 class Node;
12 
21 class ServiceClient : public Socket
22 {
23 public:
25 
29  ServiceClient(Node *node, std::string service_name, bool managed = true, bool notify_graph = true);
30 
34  virtual ~ServiceClient();
35 
39  void log(LogLevel level, std::string message) const override;
40 
44  virtual void init() override;
45 
49  virtual void cleanup() override;
50 
54  std::string getServiceName();
55 
60  virtual void call(const std::string &req, std::string &rep);
61 
62 protected:
66  virtual void resolve();
67 
71  virtual void connect();
72 
76  virtual void disconnect();
77 
79  const bool notify_graph_;
80 };
81 
82 } // namespace b0
83 
84 #endif // B0__SERVICE_CLIENT_H__INCLUDED
LogLevel
Definition: interface.h:23
const bool notify_graph_
If false this socket will not send announcement to resolv (i.e. it will be "invisible") ...
Definition: service_client.h:79
virtual void init() override
Perform initialization and optionally send graph notify.
virtual void cleanup() override
Perform cleanup and optionally send graph notify.
The abstraction for a node in the network.
Definition: node.h:40
std::string getServiceName()
Return the name of this client&#39;s service.
virtual ~ServiceClient()
ServiceClient destructor.
ServiceClient(Node *node, std::string service_name, bool managed=true, bool notify_graph=true)
Construct an ServiceClient child of the specified Node.
virtual void call(const std::string &req, std::string &rep)
Write a request and read a reply from the underlying ZeroMQ REQ socket.
The Socket class.
Definition: socket.h:31
virtual void resolve()
Perform service address resolution.
virtual void log(LogLevel level, std::string message) const =0
Log a message to the remote logger, with a specified level.
virtual void disconnect()
Disconnect from service server endpoint.
void log(LogLevel level, std::string message) const override
Log a message using node&#39;s logger, prepending this service client informations.
Definition: node.h:17
virtual void connect()
Connect to service server endpoint.
The service client class.
Definition: service_client.h:21