Gazebo Transport

API Reference

11.4.1

A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name. More...

#include <ignition/transport/NodeOptions.hh>

Public Member Functions

 NodeOptions ()
 Constructor. More...
 
 NodeOptions (const NodeOptions &_other)
 Copy constructor. More...
 
virtual ~NodeOptions ()
 Destructor. More...
 
bool AddTopicRemap (const std::string &_fromTopic, const std::string &_toTopic)
 Add a new topic remapping. Any [Un]Advertise(), [Un]Subscribe() or Request() operation will check for topic remappings. If a topic is remapped, the '_fromTopic' topic will be renamed to '_toTopic' in any of the previous functions. Is not possible to add two remaps over the same '_fromTopic'. More...
 
const std::stringNameSpace () const
 Get the namespace used in this node. More...
 
NodeOptionsoperator= (const NodeOptions &_other)
 Assignment operator. More...
 
const std::stringPartition () const
 Get the partition used in this node. More...
 
bool SetNameSpace (const std::string &_ns)
 Set the node's namespace. A namespace is considered a prefix that might be potentially applied to some of the topic/services advertised in a node. E.g.: Node1 sets a namespace 'ns1' and advertises the topics 't1', 't2' and '/t3'. '/t3' is considered an absolute topic (starts with '/') and it won't be affected by a namespace. However, 't1' and 't2' will be advertised as '/ns1/t1' and '/ns1/t2'. A namespace is any alphanumeric string with a few exceptions. The symbol '/' is allowed as part of a namespace but just '/' is not allowed. The symbols '@', '~' and ' ' are not allowed as part of a namespace. Two or more consecutive slashes ('//') are not allowed. More...
 
bool SetPartition (const std::string &_partition)
 Set the node's partition name. A partition is used to isolate a set of topics or services from other nodes that use the same names. E.g.: Node1 advertises topics '/foo' and Node2 advertises '/foo' too. If we don't use a partition, a node subscribed to '/foo' will receive the messages published from Node1 and Node2. Alternatively, we could specify 'p1' as a partition for Node1 and 'p2' as a partition for Node2. When we create the node for our subscriber, if we specify 'p1' as a partition name, we'll receive the messages published only by Node1. If we use 'p2', we'll only receive the messages published by Node2. If we don't set a partition name, we won't receive any messages from Node1 or Node2. A partition name is any alphanumeric string with a few exceptions. The symbol '/' is allowed as part of a partition name but just '/' is not allowed. The symbols '@', '~' and ' ' are not allowed as part of a partition name. Two or more consecutive slashes ('//') are not allowed. More...
 
bool TopicRemap (const std::string &_fromTopic, std::string &_toTopic) const
 Get a topic remapping. More...
 

Protected Attributes

std::unique_ptr< transport::NodeOptionsPrivate > dataPtr
 

Detailed Description

A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name.

Constructor & Destructor Documentation

◆ NodeOptions() [1/2]

Constructor.

◆ NodeOptions() [2/2]

NodeOptions ( const NodeOptions _other)

Copy constructor.

Parameters
[in]_otherNodeOptions to copy.

◆ ~NodeOptions()

virtual ~NodeOptions ( )
virtual

Destructor.

Member Function Documentation

◆ AddTopicRemap()

bool AddTopicRemap ( const std::string _fromTopic,
const std::string _toTopic 
)

Add a new topic remapping. Any [Un]Advertise(), [Un]Subscribe() or Request() operation will check for topic remappings. If a topic is remapped, the '_fromTopic' topic will be renamed to '_toTopic' in any of the previous functions. Is not possible to add two remaps over the same '_fromTopic'.

Parameters
[in]_fromTopicOriginal topic to be renamed.
[in]_toTopicNew topic to be used.
Returns
True if the topic remap is possible or false otherwise.

◆ NameSpace()

const std::string& NameSpace ( ) const

Get the namespace used in this node.

Returns
The namespace.
See also
SetNameSpace.

◆ operator=()

NodeOptions& operator= ( const NodeOptions _other)

Assignment operator.

Parameters
[in]_otherThe new NodeOptions.
Returns
A reference to this instance.

◆ Partition()

const std::string& Partition ( ) const

Get the partition used in this node.

Returns
The partition name.
See also
SetPartition.

◆ SetNameSpace()

bool SetNameSpace ( const std::string _ns)

Set the node's namespace. A namespace is considered a prefix that might be potentially applied to some of the topic/services advertised in a node. E.g.: Node1 sets a namespace 'ns1' and advertises the topics 't1', 't2' and '/t3'. '/t3' is considered an absolute topic (starts with '/') and it won't be affected by a namespace. However, 't1' and 't2' will be advertised as '/ns1/t1' and '/ns1/t2'. A namespace is any alphanumeric string with a few exceptions. The symbol '/' is allowed as part of a namespace but just '/' is not allowed. The symbols '@', '~' and ' ' are not allowed as part of a namespace. Two or more consecutive slashes ('//') are not allowed.

Parameters
[in]_nsThe namespace.
Returns
True when operation succeed or false if the namespace was invalid.
See also
NameSpace.

◆ SetPartition()

bool SetPartition ( const std::string _partition)

Set the node's partition name. A partition is used to isolate a set of topics or services from other nodes that use the same names. E.g.: Node1 advertises topics '/foo' and Node2 advertises '/foo' too. If we don't use a partition, a node subscribed to '/foo' will receive the messages published from Node1 and Node2. Alternatively, we could specify 'p1' as a partition for Node1 and 'p2' as a partition for Node2. When we create the node for our subscriber, if we specify 'p1' as a partition name, we'll receive the messages published only by Node1. If we use 'p2', we'll only receive the messages published by Node2. If we don't set a partition name, we won't receive any messages from Node1 or Node2. A partition name is any alphanumeric string with a few exceptions. The symbol '/' is allowed as part of a partition name but just '/' is not allowed. The symbols '@', '~' and ' ' are not allowed as part of a partition name. Two or more consecutive slashes ('//') are not allowed.

Parameters
[in]_partitionThe partition's name. The default partition value is created using a combination of your hostname, followed by ':' and your username. E.g.: "bb9:caguero" . It's also possible to use the environment variable IGN_PARTITION for setting a partition name.
Returns
True when operation succeed or false if the partition name was invalid.
See also
Partition

◆ TopicRemap()

bool TopicRemap ( const std::string _fromTopic,
std::string _toTopic 
) const

Get a topic remapping.

Parameters
[in]_fromTopicThe original topic.
[out]_toTopicThe new topic name. _toTopic is unchanged if there is no remapping.
Returns
True if a topic remap was found for '_fromTopic' or false otherwise.

Member Data Documentation

◆ dataPtr

std::unique_ptr<transport::NodeOptionsPrivate> dataPtr
protected

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