A class that allows a client to communicate with other peers. More...
#include <ignition/transport/Node.hh>
Classes | |
class | Publisher |
A class that is used to store information about an advertised publisher. More... | |
Public Member Functions | |
Node (const NodeOptions &_options=NodeOptions()) | |
Constructor. More... | |
virtual | ~Node () |
Destructor. More... | |
template<typename T > | |
Node::Publisher | Advertise (const std::string &_topic, const AdvertiseMessageOptions &_options=AdvertiseMessageOptions()) |
Advertise a new topic. More... | |
Node::Publisher | Advertise (const std::string &_topic, const std::string &_msgTypeName, const AdvertiseMessageOptions &_options=AdvertiseMessageOptions()) |
Advertise a new topic. More... | |
template<typename T1 , typename T2 > | |
bool | Advertise (const std::string &_topic, void(*_cb)(const T1 &_req, T2 &_rep, bool &_result), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service. More... | |
template<typename T > | |
bool | Advertise (const std::string &_topic, void(*_cb)(T &_rep, bool &_result), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without input parameter. More... | |
template<typename T > | |
bool | Advertise (const std::string &_topic, void(*_cb)(const T &_req), const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without any output parameter. More... | |
template<typename T1 , typename T2 > | |
bool | Advertise (const std::string &_topic, std::function< void(const T1 &_req, T2 &_rep, bool &_result)> &_cb, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service. More... | |
template<typename T > | |
bool | Advertise (const std::string &_topic, std::function< void(T &_rep, bool &_result)> &_cb, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without input parameter. More... | |
template<typename T > | |
bool | Advertise (const std::string &_topic, std::function< void(const T &_req)> &_cb, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without any output parameter. More... | |
template<typename C , typename T1 , typename T2 > | |
bool | Advertise (const std::string &_topic, void(C::*_cb)(const T1 &_req, T2 &_rep, bool &_result), C *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service. More... | |
template<typename C , typename T > | |
bool | Advertise (const std::string &_topic, void(C::*_cb)(T &_rep, bool &_result), C *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without input parameter. More... | |
template<typename C , typename T > | |
bool | Advertise (const std::string &_topic, void(C::*_cb)(const T &_req), C *_obj, const AdvertiseServiceOptions &_options=AdvertiseServiceOptions()) |
Advertise a new service without any output parameter. More... | |
std::vector< std::string > | AdvertisedServices () const |
Get the list of services advertised by this node. More... | |
std::vector< std::string > | AdvertisedTopics () const |
Get the list of topics advertised by this node. More... | |
template<typename T1 , typename T2 > | |
bool | Request (const std::string &_topic, const T1 &_req, void(*_cb)(const T2 &_rep, const bool _result)) |
Request a new service using a non-blocking call. More... | |
template<typename T > | |
bool | Request (const std::string &_topic, void(*_cb)(const T &_rep, const bool _result)) |
Request a new service without input parameter using a non-blocking call. More... | |
template<typename T1 , typename T2 > | |
bool | Request (const std::string &_topic, const T1 &_req, std::function< void(const T2 &_rep, const bool _result)> &_cb) |
Request a new service using a non-blocking call. More... | |
template<typename T > | |
bool | Request (const std::string &_topic, std::function< void(const T &_rep, const bool _result)> &_cb) |
Request a new service without input parameter using a non-blocking call. More... | |
template<typename C , typename T1 , typename T2 > | |
bool | Request (const std::string &_topic, const T1 &_req, void(C::*_cb)(const T2 &_rep, const bool _result), C *_obj) |
Request a new service using a non-blocking call. More... | |
template<typename C , typename T > | |
bool | Request (const std::string &_topic, void(C::*_cb)(const T &_rep, const bool _result), C *_obj) |
Request a new service without input parameter using a non-blocking call. More... | |
template<typename T1 , typename T2 > | |
bool | Request (const std::string &_topic, const T1 &_req, const unsigned int &_timeout, T2 &_rep, bool &_result) |
Request a new service using a blocking call. More... | |
template<typename T > | |
bool | Request (const std::string &_topic, const unsigned int &_timeout, T &_rep, bool &_result) |
Request a new service without input parameter using a blocking call. More... | |
template<typename T > | |
bool | Request (const std::string &_topic, const T &_req) |
Request a new service without waiting for response. More... | |
bool | ServiceInfo (const std::string &_service, std::vector< ServicePublisher > &_publishers) const |
Get the information about a service. More... | |
void | ServiceList (std::vector< std::string > &_services) const |
Get the list of topics currently advertised in the network. More... | |
template<typename T > | |
bool | Subscribe (const std::string &_topic, void(*_cb)(const T &_msg), const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
template<typename T > | |
bool | Subscribe (const std::string &_topic, std::function< void(const T &_msg)> &_cb, const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
template<typename C , typename T > | |
bool | Subscribe (const std::string &_topic, void(C::*_cb)(const T &_msg), C *_obj, const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
template<typename T > | |
bool | Subscribe (const std::string &_topic, void(*_cb)(const T &_msg, const MessageInfo &_info), const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
template<typename T > | |
bool | Subscribe (const std::string &_topic, std::function< void(const T &_msg, const MessageInfo &_info)> &_cb, const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
template<typename C , typename T > | |
bool | Subscribe (const std::string &_topic, void(C::*_cb)(const T &_msg, const MessageInfo &_info), C *_obj, const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. More... | |
std::vector< std::string > | SubscribedTopics () const |
Get the list of topics subscribed by this node. More... | |
bool | TopicInfo (const std::string &_topic, std::vector< MessagePublisher > &_publishers) const |
Get the information about a topic. More... | |
void | TopicList (std::vector< std::string > &_topics) const |
Get the list of topics currently advertised in the network. More... | |
bool | UnadvertiseSrv (const std::string &_topic) |
Unadvertise a service. More... | |
bool | Unsubscribe (const std::string &_topic) |
Unsubscribe from a topic. More... | |
A class that allows a client to communicate with other peers.
There are two main communication modes: pub/sub messages and service calls.
|
explicit |
Constructor.
[in] | _options | Node options. |
|
virtual |
Destructor.
|
inline |
Advertise a new topic.
If a topic is currently advertised, you cannot advertise it a second time (regardless of its type).
[in] | _topic | Topic name to be advertised. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new topic.
If a topic is currently advertised, you cannot advertise it a second time (regardless of its type).
[in] | _topic | Topic name to be advertised. |
[in] | _msgTypeName | Name of the message type that will be published on the topic. The message type name can be retrieved from a protobuf message using the GetTypeName() function. |
[in] | _options | Advertise options. |
References ignition::transport::TopicUtils::FullyQualifiedName().
|
inline |
Advertise a new service.
In this version the callback is a free function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service without input parameter.
In this version the callback is a free function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service without any output parameter.
In this version the callback is a free function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service.
In this version the callback is a lambda function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _options | Advertise options. |
References ignition::transport::TopicUtils::FullyQualifiedName().
|
inline |
Advertise a new service without input parameter.
In this version the callback is a lambda function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service without any output parameter.
In this version the callback is a lambda function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service.
In this version the callback is a member function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _obj | Instance containing the member function. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service without input parameter.
In this version the callback is a member function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Service call result. |
[in] | _obj | Instance containing the member function. |
[in] | _options | Advertise options. |
|
inline |
Advertise a new service without any output parameter.
In this version the callback is a member function.
[in] | _topic | Topic name associated to the service. |
[in] | _cb | Callback to handle the service request with the following parameters: |
[in] | _req | Protobuf message containing the request. |
[in] | _obj | Instance containing the member function. |
[in] | _options | Advertise options. |
std::vector<std::string> ignition::transport::Node::AdvertisedServices | ( | ) | const |
Get the list of services advertised by this node.
std::vector<std::string> ignition::transport::Node::AdvertisedTopics | ( | ) | const |
Get the list of topics advertised by this node.
|
inline |
Request a new service using a non-blocking call.
In this version the callback is a free function.
[in] | _topic | Service name requested. |
[in] | _req | Protobuf message containing the request's parameters. |
[in] | _cb | Pointer to the callback function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
|
inline |
Request a new service without input parameter using a non-blocking call.
In this version the callback is a free function.
[in] | _topic | Service name requested. |
[in] | _cb | Pointer to the callback function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
|
inline |
Request a new service using a non-blocking call.
In this version the callback is a lambda function.
[in] | _topic | Service name requested. |
[in] | _req | Protobuf message containing the request's parameters. |
[in] | _cb | Lambda function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
References ignition::transport::TopicUtils::FullyQualifiedName().
|
inline |
Request a new service without input parameter using a non-blocking call.
In this version the callback is a lambda function.
[in] | _topic | Service name requested. |
[in] | _cb | Lambda function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
|
inline |
Request a new service using a non-blocking call.
In this version the callback is a member function.
[in] | _topic | Service name requested. |
[in] | _req | Protobuf message containing the request's parameters. |
[in] | _cb | Pointer to the callback function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
[in] | _obj | Instance containing the member function. |
|
inline |
Request a new service without input parameter using a non-blocking call.
In this version the callback is a member function.
[in] | _topic | Service name requested. |
[in] | _cb | Pointer to the callback function executed when the response arrives. The callback has the following parameters: |
[in] | _rep | Protobuf message containing the response. |
[in] | _result | Result of the service call. If false, there was a problem executing your request. |
[in] | _obj | Instance containing the member function. |
|
inline |
Request a new service using a blocking call.
[in] | _topic | Service name requested. |
[in] | _req | Protobuf message containing the request's parameters. |
[in] | _timeout | The request will timeout after '_timeout' ms. |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Result of the service call. |
References ignition::transport::TopicUtils::FullyQualifiedName().
|
inline |
Request a new service without input parameter using a blocking call.
[in] | _topic | Service name requested. |
[in] | _timeout | The request will timeout after '_timeout' ms. |
[out] | _rep | Protobuf message containing the response. |
[out] | _result | Result of the service call. |
|
inline |
Request a new service without waiting for response.
[in] | _topic | Topic requested. |
[in] | _req | Protobuf message containing the request's parameters. |
bool ignition::transport::Node::ServiceInfo | ( | const std::string & | _service, |
std::vector< ServicePublisher > & | _publishers | ||
) | const |
Get the information about a service.
[in] | _service | Name of the service. |
[out] | _publishers | List of publishers on the service. |
void ignition::transport::Node::ServiceList | ( | std::vector< std::string > & | _services | ) | const |
Get the list of topics currently advertised in the network.
Note that this function can block for some time if the discovery is in its initialization phase. The value of the "heartbeatInterval" constant, with a default value of 1000ms, sets the maximum blocking time period.
[out] | _services | List of advertised services. |
|
inline |
Subscribe to a topic registering a callback.
Note that this callback does not include any message information. In this version the callback is a free function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Pointer to the callback function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _opts | Subscription options. |
|
inline |
Subscribe to a topic registering a callback.
Note that this callback does not include any message information. In this version the callback is a lamda function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Lambda function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _opts | Subscription options. |
|
inline |
Subscribe to a topic registering a callback.
Note that this callback does not include any message information. In this version the callback is a member function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Pointer to the callback function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _obj | Instance containing the member function. |
[in] | _opts | Subscription options. |
|
inline |
Subscribe to a topic registering a callback.
Note that this callback includes message information. In this version the callback is a free function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Pointer to the callback function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _info | Message information (e.g.: topic name). |
[in] | _opts | Subscription options. |
|
inline |
Subscribe to a topic registering a callback.
Note that this callback includes message information. In this version the callback is a lamda function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Lambda function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _info | Message information (e.g.: topic name). |
[in] | _opts | Subscription options. |
References ignition::transport::TopicUtils::FullyQualifiedName().
|
inline |
Subscribe to a topic registering a callback.
Note that this callback includes message information. In this version the callback is a member function.
[in] | _topic | Topic to be subscribed. |
[in] | _cb | Pointer to the callback function with the following parameters: |
[in] | _msg | Protobuf message containing a new topic update. |
[in] | _info | Message information (e.g.: topic name). |
[in] | _obj | Instance containing the member function. |
[in] | _opts | Subscription options. |
std::vector<std::string> ignition::transport::Node::SubscribedTopics | ( | ) | const |
Get the list of topics subscribed by this node.
Note that we might be interested in one topic but we still don't know the address of a publisher.
bool ignition::transport::Node::TopicInfo | ( | const std::string & | _topic, |
std::vector< MessagePublisher > & | _publishers | ||
) | const |
Get the information about a topic.
[in] | _topic | Name of the topic. |
[out] | _publishers | List of publishers on the topic |
void ignition::transport::Node::TopicList | ( | std::vector< std::string > & | _topics | ) | const |
Get the list of topics currently advertised in the network.
Note that this function can block for some time if the discovery is in its initialization phase. The value of the "heartbeatInterval" constant, with a default value of 1000 ms, sets the maximum blocking time period.
[out] | _topics | List of advertised topics. |
bool ignition::transport::Node::UnadvertiseSrv | ( | const std::string & | _topic | ) |
Unadvertise a service.
[in] | _topic | Service name to be unadvertised. |
bool ignition::transport::Node::Unsubscribe | ( | const std::string & | _topic | ) |
Unsubscribe from a topic.
[in] | _topic | Topic name to be unsubscribed. |