1 #ifndef B0__SUBSCRIBER_H__INCLUDED 2 #define B0__SUBSCRIBER_H__INCLUDED 6 #include <boost/function.hpp> 7 #include <boost/bind.hpp> 38 Subscriber(
Node *node, std::string topic_name, boost::function<
void(
const std::string&)> callback = 0,
bool managed =
true,
bool notify_graph =
true);
44 Subscriber(TNode *node, std::string topic_name,
void (TNode::*callbackMethod)(
const std::string&),
bool managed =
true,
bool notify_graph =
true)
45 :
Subscriber(node, topic_name, boost::
bind(callbackMethod, node, _1), managed, notify_graph)
54 Subscriber(
Node *node, std::string topic_name,
void (T::*callbackMethod)(
const std::string&), T *callbackObject,
bool managed =
true,
bool notify_graph =
true)
55 :
Subscriber(node, topic_name, boost::
bind(callbackMethod, callbackObject, _1), managed, notify_graph)
68 void log(
LogLevel level, std::string message)
const override;
73 virtual void init()
override;
78 virtual void cleanup()
override;
112 #endif // B0__SUBSCRIBER_H__INCLUDED LogLevel
Definition: interface.h:23
virtual void disconnect()
Disconnect from the remote address.
Subscriber(Node *node, std::string topic_name, boost::function< void(const std::string &)> callback=0, bool managed=true, bool notify_graph=true)
Construct an Subscriber child of the specified Node, optionally using a boost::function as callback...
virtual void connect()
Connect to the remote address.
void bind(std::string const &addr)
Wrapper to zmq::socket_t::bind.
The abstraction for a node in the network.
Definition: node.h:40
virtual void cleanup() override
Perform cleanup and optionally send graph notify.
The subscriber class.
Definition: subscriber.h:30
Subscriber(TNode *node, std::string topic_name, void(TNode::*callbackMethod)(const std::string &), bool managed=true, bool notify_graph=true)
Construct a Subscriber child of a specified Node, with a method (of the Node subclass) as a callback...
Definition: subscriber.h:44
virtual ~Subscriber()
Subscriber destructor.
std::string getTopicName()
Return the name of this subscriber's topic.
The Socket class.
Definition: socket.h:31
const bool notify_graph_
If false this socket will not send announcement to resolv (i.e. it will be "invisible") ...
Definition: subscriber.h:102
virtual void log(LogLevel level, std::string message) const =0
Log a message to the remote logger, with a specified level.
virtual void spinOnce() override
Process incoming messages and call callbacks.
virtual void init() override
Perform initialization and optionally send graph notify.
Subscriber(Node *node, std::string topic_name, void(T::*callbackMethod)(const std::string &), T *callbackObject, bool managed=true, bool notify_graph=true)
Construct a Subscriber child of a specified Node, with a method as a callback.
Definition: subscriber.h:54
void log(LogLevel level, std::string message) const override
Log a message using node's logger, prepending this subscriber informations.
boost::function< void(std::string &)> callback_
Callback which will be called when a new message is read from the socket.
Definition: subscriber.h:107