A class that allows a client to communicate with other peers. There are two main communication modes: pub/sub messages and service calls. More...
#include <ignition/transport/Node.hh>
Classes | |
class | Publisher |
A class that is used to store information about an advertised publisher. An instance of this class is returned from Node::Advertise, and should be used in subsequent Node::Publisher::Publish calls. More... | |
Public Member Functions | |
Node (const NodeOptions &_options=NodeOptions()) | |
Constructor. | |
virtual | ~Node () |
Destructor. | |
template<typename MessageT > | |
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 (regardless of its type). | |
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 (regardless of its type). | |
std::vector< std::string > | AdvertisedTopics () const |
Get the list of topics advertised by this node. | |
template<typename MessageT > | |
bool | Subscribe (const std::string &_topic, std::function< void(const MessageT &_msg)> &_cb, const SubscribeOptions &_opts=SubscribeOptions()) |
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. | |
template<typename MessageT > | |
bool | Subscribe (const std::string &_topic, std::function< void(const MessageT &_msg, const MessageInfo &_info)> &_cb, const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. Note that this callback includes message information. In this version the callback is a lamda function. | |
template<typename MessageT > | |
bool | Subscribe (const std::string &_topic, void(*_cb)(const MessageT &_msg), const SubscribeOptions &_opts=SubscribeOptions()) |
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. | |
template<typename MessageT > | |
bool | Subscribe (const std::string &_topic, void(*_cb)(const MessageT &_msg, const MessageInfo &_info), const SubscribeOptions &_opts=SubscribeOptions()) |
Subscribe to a topic registering a callback. Note that this callback includes message information. In this version the callback is a free function. | |
template<typename ClassT , typename MessageT > | |
bool | Subscribe (const std::string &_topic, void(ClassT::*_cb)(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 information. In this version the callback is a member function. | |
template<typename ClassT , typename MessageT > | |
bool | Subscribe (const std::string &_topic, void(ClassT::*_cb)(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. In this version the callback is a member function. | |
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 still don't know the address of a publisher. | |
bool | Unsubscribe (const std::string &_topic) |
Unsubscribe from a topic. | |
Public Attributes | |
class ignition::transport::Node::Publisher | Advertise [in] |
Detailed Description
A class that allows a client to communicate with other peers. There are two main communication modes: pub/sub messages and service calls.
Constructor & Destructor Documentation
◆ Node()
|
explicit |
Constructor.
- Parameters
-
[in] _options Node options.
◆ ~Node()
|
virtual |
Destructor.
Member Function Documentation
◆ Advertise() [1/2]
|
inline |
Advertise a new topic. If a topic is currently advertised, you cannot advertise it a second time (regardless of its type).
- Parameters
-
[in] _topic Topic name to be advertised. [in] _options Advertise options.
- Returns
- A PublisherId, which can be used in Node::Publish calls. The PublisherId also acts as boolean, where true occurs if the topic was succesfully advertised.
- See also
- AdvertiseOptions.
References ignition::transport::_options, and Node::Advertise.
◆ Advertise() [2/2]
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 (regardless of its type).
- Parameters
-
[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.
- Returns
- A PublisherId, which can be used in Node::Publish calls. The PublisherId also acts as boolean, where true occurs if the topic was succesfully advertised.
- See also
- AdvertiseOptions.
◆ AdvertisedTopics()
std::vector< std::string > AdvertisedTopics | ( | ) | const |
Get the list of topics advertised by this node.
- Returns
- A vector containing all the topics advertised by this node.
◆ Subscribe() [1/6]
|
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.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, and ignition::transport::_topic.
◆ Subscribe() [2/6]
|
inline |
Subscribe to a topic registering a callback. Note that this callback includes message information. In this version the callback is a lamda function.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, ignition::transport::_topic, std::endl(), TopicUtils::FullyQualifiedName(), ignition::transport::lk(), and ignition::transport::Shared().
◆ Subscribe() [3/6]
|
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.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, and ignition::transport::_topic.
◆ Subscribe() [4/6]
|
inline |
Subscribe to a topic registering a callback. Note that this callback includes message information. In this version the callback is a free function.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, and ignition::transport::_topic.
◆ Subscribe() [5/6]
|
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.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, ignition::transport::_obj, ignition::transport::_topic, std::bind(), and ignition::transport::cb().
◆ Subscribe() [6/6]
|
inline |
Subscribe to a topic registering a callback. Note that this callback includes message information. In this version the callback is a member function.
- Parameters
-
[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.
- Returns
- true when successfully subscribed or false otherwise.
References ignition::transport::_cb, ignition::transport::_obj, ignition::transport::_topic, std::bind(), and ignition::transport::cb().
◆ SubscribedTopics()
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 still don't know the address of a publisher.
- Returns
- A vector containing the subscribed topics (even if we do not have an address for a particular topic yet).
◆ Unsubscribe()
bool Unsubscribe | ( | const std::string & | _topic | ) |
Unsubscribe from a topic.
- Parameters
-
[in] _topic Topic name to be unsubscribed.
- Returns
- true when successfully unsubscribed or false otherwise.
References ignition::transport::_rep, ignition::transport::_req, ignition::transport::_result, ignition::transport::_topic, and ignition::transport::RequestT.
Member Data Documentation
◆ Advertise
class ignition::transport::Node::Publisher Advertise[in] |
Referenced by ignition::transport::Advertise(), Node::Advertise(), and ignition::transport::Advertise().
The documentation for this class was generated from the following file: