Gazebo Transport

API Reference

13.4.1
Node::Subscriber Class Reference

A class that is used to store information about an subscriber. An instance of this class is returned from Node::CreateSubscribe. When the object is destroyed, the corresponding subscription handler is removed from the node. More...

#include <Node.hh>

Public Member Functions

 Subscriber ()
 Default constructor. More...
 
 Subscriber (const std::string &_topic, const std::string &_nUuid, const NodeOptions &_nOpts, const std::string &_hUuid)
 Constructor. More...
 
 Subscriber (Subscriber &&_other)
 Move constructor. More...
 
virtual ~Subscriber ()
 Destructor. Unsubscribe to the topic and remove the subcription handler. More...
 
 operator bool ()
 Allows this class to be evaluated as a boolean. More...
 
 operator bool () const
 Allows this class to be evaluated as a boolean (const). More...
 
Node::Subscriberoperator= (Subscriber &&_other)
 Move assignment operator. More...
 
bool Unsubscribe ()
 Unsubscribe from the topic. More...
 
bool Valid () const
 Return true if valid information, such as a non-empty topic name, node and handler UUIDs. More...
 

Detailed Description

A class that is used to store information about an subscriber. An instance of this class is returned from Node::CreateSubscribe. When the object is destroyed, the corresponding subscription handler is removed from the node.

Pseudo code example

std::function<void(const msgs::Int32 &)> cb = [](const msgs::Int32 &) { // Do something }; Node::Subscriber sub = myNode.CreateSubscriber("topic_name", cb);

Constructor & Destructor Documentation

◆ Subscriber() [1/3]

Default constructor.

◆ Subscriber() [2/3]

Subscriber ( const std::string _topic,
const std::string _nUuid,
const NodeOptions _nOpts,
const std::string _hUuid 
)

Constructor.

Parameters
[in]_topicSubscribed topic name
[in]_nUuidNode to which this subscriber belongs
[in]_nOptsNode options for the node
[in]_hUuidSubscriber's handler UUID

◆ ~Subscriber()

virtual ~Subscriber ( )
virtual

Destructor. Unsubscribe to the topic and remove the subcription handler.

◆ Subscriber() [3/3]

Subscriber ( Subscriber &&  _other)

Move constructor.

Parameters
[in]_otherThe other Node::Subscriber

Member Function Documentation

◆ operator bool() [1/2]

operator bool ( )

Allows this class to be evaluated as a boolean.

Returns
True if valid
See also
Valid

◆ operator bool() [2/2]

operator bool ( ) const

Allows this class to be evaluated as a boolean (const).

Returns
True if valid
See also
Valid

◆ operator=()

Node::Subscriber& operator= ( Subscriber &&  _other)

Move assignment operator.

Parameters
[in]_otherThe other Node::Subscriber
Returns
Reference to this

◆ Unsubscribe()

bool Unsubscribe ( )

Unsubscribe from the topic.

Returns
True if the topic was successfully unsubscribed

◆ Valid()

bool Valid ( ) const

Return true if valid information, such as a non-empty topic name, node and handler UUIDs.

Returns
True if this object has a valid subscription.

The documentation for this class was generated from the following file: