Node.hh
Go to the documentation of this file.
A class for customizing the publication options for a topic advertised. E.g.: Set the rate of message...
Definition: AdvertiseOptions.hh:152
A class for customizing the publication options for a service advertised.
Definition: AdvertiseOptions.hh:249
A class that provides information about the message received.
Definition: MessageInfo.hh:38
This class stores all the information about a message publisher.
Definition: Publisher.hh:223
A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name.
Definition: NodeOptions.hh:41
A class that is used to store information about an advertised publisher. An instance of this class is...
Definition: Node.hh:116
bool Valid() const
Return true if valid information, such as a non-empty topic name, is present.
Publisher(const MessagePublisher &_publisher)
Constructor.
bool ThrottledUpdateReady() const
Check if message publication is throttled. If so, verify whether the next message should be published...
bool PublishRaw(const std::string &_msgData, const std::string &_msgType)
Publish a raw pre-serialized message.
bool HasConnections() const
Return true if this publisher has subscribers.
bool Publish(const ProtoMsg &_msg)
Publish a message. This function will copy the message when publishing to interprocess subscribers....
A class that allows a client to communicate with other peers. There are two main communication modes:...
Definition: Node.hh:96
bool Request(const std::string &_topic, const RequestT &_request, void(*_callback)(const ReplyT &_reply, const bool _result))
Request a new service using a non-blocking call. In this version the callback is a free function.
bool Advertise(const std::string &_topic, std::function< bool(ReplyT &_reply)> &_callback, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without input parameter. In this version the callback is a lambda function.
bool Subscribe(const std::string &_topic, void(*_callback)(const MessageT &_msg), const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback does not include any message inf...
Node::Publisher Advertise(const std::string &_topic, const std::string &_msgTypeName, const AdvertiseMessageOptions &_options=AdvertiseMessageOptions())
Advertise a new topic. If a topic is currently advertised, you cannot advertise it a second time (reg...
bool Advertise(const std::string &_topic, bool(ClassT::*_callback)(ReplyT &_reply), ClassT *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without input parameter. In this version the callback is a member function.
bool Request(const std::string &_topic, const unsigned int &_timeout, ReplyT &_reply, bool &_result)
Request a new service without input parameter using a blocking call.
bool Request(const std::string &_topic, const RequestT &_request, std::function< void(const ReplyT &_reply, const bool _result)> &_callback)
Request a new service using a non-blocking call. In this version the callback is a lambda function.
bool Request(const std::string &_topic, const RequestT &_request, const unsigned int &_timeout, ReplyT &_reply, bool &_result)
Request a new service using a blocking call.
bool Request(const std::string &_topic, std::function< void(const ReplyT &_reply, const bool _result)> &_callback)
Request a new service without input parameter using a non-blocking call. In this version the callback...
bool Advertise(const std::string &_topic, bool(*_callback)(const RequestT &_request, ReplyT &_reply), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service. In this version the callback is a plain function pointer.
Node::Publisher Advertise(const std::string &_topic, const AdvertiseMessageOptions &_options=AdvertiseMessageOptions())
Advertise a new topic. If a topic is currently advertised, you cannot advertise it a second time (reg...
bool TopicInfo(const std::string &_topic, std::vector< MessagePublisher > &_publishers) const
Get the information about a topic.
std::vector< std::string > AdvertisedTopics() const
Get the list of topics advertised by this node.
bool Advertise(const std::string &_topic, std::function< bool(const RequestT &_request, ReplyT &_reply)> _callback, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service. In this version the callback is a lambda function.
bool SubscribeRaw(const std::string &_topic, const RawCallback &_callback, const std::string &_msgType=kGenericMessageType, const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. The callback must accept a std::string to represent the ...
bool Advertise(const std::string &_topic, void(*_callback)(const RequestT &_request), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without any output parameter. In this version the callback is a free function...
bool Advertise(const std::string &_topic, std::function< void(const RequestT &_request)> &_callback, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without any output parameter. In this version the callback is a lambda functi...
bool Subscribe(const std::string &_topic, std::function< void(const MessageT &_msg)> &_callback, const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback does not include any message inf...
void ServiceList(std::vector< std::string > &_services) const
Get the list of topics currently advertised in the network. Note that this function can block for som...
bool UnadvertiseSrv(const std::string &_topic)
Unadvertise a service.
bool EnableStats(const std::string &_topic, bool _enable, const std::string &_publicationTopic="/statistics", uint64_t _publicationRate=1)
Turn topic statistics on or off.
bool Request(const std::string &_topic, void(ClassT::*_callback)(const ReplyT &_reply, const bool _result), ClassT *_obj)
Request a new service without input parameter using a non-blocking call. In this version the callback...
const NodeOptions & Options() const
Get the reference to the current node options.
bool Subscribe(const std::string &_topic, void(ClassT::*_callback)(const MessageT &_msg), ClassT *_obj, const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback does not include any message inf...
std::optional< TopicStatistics > TopicStats(const std::string &_topic) const
Get the current statistics for a topic. Statistics must have been enabled using the EnableStatistics ...
bool Subscribe(const std::string &_topic, std::function< void(const MessageT &_msg, const MessageInfo &_info)> &_callback, const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback includes message information....
bool Request(const std::string &_topic, void(*_callback)(const ReplyT &_reply, const bool _result))
Request a new service without input parameter using a non-blocking call. In this version the callback...
std::vector< std::string > SubscribedTopics() const
Get the list of topics subscribed by this node. Note that we might be interested in one topic but we ...
bool ServiceInfo(const std::string &_service, std::vector< ServicePublisher > &_publishers) const
Get the information about a service.
bool Subscribe(const std::string &_topic, void(*_callback)(const MessageT &_msg, const MessageInfo &_info), const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback includes message information....
bool Advertise(const std::string &_topic, void(ClassT::*_callback)(const RequestT &_request), ClassT *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without any output parameter. In this version the callback is a member functi...
bool Request(const std::string &_topic, const RequestT &_request, void(ClassT::*_callback)(const ReplyT &_reply, const bool _result), ClassT *_obj)
Request a new service using a non-blocking call. In this version the callback is a member function.
bool Advertise(const std::string &_topic, bool(ClassT::*_callback)(const RequestT &_request, ReplyT &_reply), ClassT *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service. In this version the callback is a member function.
bool Advertise(const std::string &_topic, bool(*_callback)(ReplyT &_reply), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions())
Advertise a new service without input parameter. In this version the callback is a free function.
bool Unsubscribe(const std::string &_topic)
Unsubscribe from a topic.
std::vector< std::string > AdvertisedServices() const
Get the list of services advertised by this node.
bool Request(const std::string &_topic, const RequestT &_request)
Request a new service without waiting for response.
void TopicList(std::vector< std::string > &_topics) const
Get the list of topics currently advertised in the network. Note that this function can block for som...
bool Subscribe(const std::string &_topic, void(ClassT::*_callback)(const MessageT &_msg, const MessageInfo &_info), ClassT *_obj, const SubscribeOptions &_opts=SubscribeOptions())
Subscribe to a topic registering a callback. Note that this callback includes message information....
A class to provide different options for a subscription.
Definition: SubscribeOptions.hh:40
int rcvHwm()
Get the capacity of the buffer (High Water Mark) that stores incoming Ignition Transport messages....
int sndHwm()
Get the capacity of the buffer (High Water Mark) that stores outgoing Ignition Transport messages....
const std::string kGenericMessageType
The string type used for generic messages.
Definition: TransportTypes.hh:174
void waitForShutdown()
Block the current thread until a SIGINT or SIGTERM is received. Note that this function registers a s...
Definition: AdvertiseOptions.hh:29