Gazebo Transport

API Reference

15.0.0~pre1

This class provides different utilities related with topics. More...

#include <gz/transport/TopicUtils.hh>

Static Public Member Functions

static std::string AsValidTopic (const std::string &_topic)
 Convert a topic name to a valid topic. The input topic is modified by:
 
static std::string CreateLivelinessToken (const std::string &_fullyQualifiedTopic, const std::string &_pUuid, const std::string &_nUuid, const std::string &_entityType, const std::string &_reqTypeName, const std::string &_repTypeName)
 Create a liveliness token.
 
static std::string CreateLivelinessToken (const std::string &_fullyQualifiedTopic, const std::string &_pUuid, const std::string &_nUuid, const std::string &_entityType, const std::string &_typeName)
 Create a liveliness token.
 
static std::string CreateLivelinessTokenHelper (const std::string &_fullyQualifiedTopic, const std::string &_pUuid, const std::string &_nUuid, const std::string &_entityType)
 Create a partial liveliness token.
 
static bool DecomposeFullyQualifiedTopic (const std::string &_fullyQualifiedName, std::string &_partition, std::string &_namespaceAndTopic)
 Decompose a fully qualified topic name into its partition and topic strings. Note that if the topic is preceded by a namespace, then the namespace and topic name will remain together as one string.
 
static bool DecomposeLivelinessToken (const std::string &_token, std::string &_prefix, std::string &_partition, std::string &_namespaceAndTopic, std::string &_pUUID, std::string &_nUUID, std::string &_entityType, std::string &_reqType, std::string &_repType)
 Decompose a Zenoh liveliness token into its components.
 
static bool DecomposeLivelinessToken (const std::string &_token, std::string &_prefix, std::string &_partition, std::string &_namespaceAndTopic, std::string &_pUUID, std::string &_nUUID, std::string &_entityType, std::string &_typeName)
 Decompose a Zenoh liveliness token into its components.
 
static bool DecomposeLivelinessTokenHelper (const std::string &_token, std::string &_prefix, std::string &_partition, std::string &_namespaceAndTopic, std::string &_pUUID, std::string &_nUUID, std::string &_entityType, std::string &_remainingToken)
 Partially decompose a Zenoh liveliness token into its components.
 
static std::string DemangleName (const std::string &_input)
 Recompose a previously mangled name.
 
static bool DemangleType (const std::string &_input, std::vector< std::string > &_output)
 Recompose a previously mangled type.
 
static bool FullyQualifiedName (const std::string &_partition, const std::string &_ns, const std::string &_topic, std::string &_name)
 Get the full topic path given a namespace and a topic name. A fully qualified topic name's length must not exceed kMaxNameLength. The fully qualified name follows the next syntax: @<PARTITION>@<NAMESPACE>/<TOPIC> where: <PARTITION>: The name of the partition or empty string. A "/" will be prefixed to the partition name unless is empty or it already starts with slash. A trailing slash will always be removed. <NAMESPACE>: The namespace or empty string. A namespace is a prefix applied to the topic name. If not empty, it will always start with a "/". A trailing slash will always be removed <TOPIC>: The topic name. A trailing slash will always be removed.
 
static bool IsValidNamespace (const std::string &_ns)
 Determines if a namespace is valid. A namespace's length must not exceed kMaxNameLength. The following symbols are not allowed as part of the namespace: '@', ':=', '~'.
 
static bool IsValidPartition (const std::string &_partition)
 Determines if a partition is valid. The same rules to validate a topic name applies to a partition with the addition of the empty string, which is a valid partition (meaning no partition is used). A partition name's length must not exceed kMaxNameLength.
 
static bool IsValidTopic (const std::string &_topic)
 Determines if a topic name is valid. A topic name is any non-empty alphanumeric string. The symbol '/' is also allowed as part of a topic name. The following symbols are not allowed as part of the topic name: '@', ':=', '~'. A topic name's length must not exceed kMaxNameLength. Examples of valid topics: abc, /abc, /abc/de, /abc/de/.
 
static std::string MangleName (const std::string &_input)
 Replace "/" instances with "%".
 
static bool MangleType (const std::vector< std::string > &_input, std::string &_output)
 Mangle multiple types into a single string using "&" as delimiter.
 

Static Public Attributes

static const uint16_t kMaxNameLength = 65535
 The kMaxNameLength specifies the maximum number of characters allowed in a namespace, a partition name, a topic name, and a fully qualified topic name.
 
static const char kSlashReplacement
 A replacement for the slash when mangling names.
 
static const char kTokenPrefix []
 A common prefix for all liveliness tokens.
 
static const char kTokenSeparator []
 The separator used within the liveliness token.
 
static const char kTypeSeparator []
 The separator used to concatenate type names.
 

Detailed Description

This class provides different utilities related with topics.

Member Function Documentation

◆ AsValidTopic()

static std::string AsValidTopic ( const std::string _topic)
static

Convert a topic name to a valid topic. The input topic is modified by:

  • turning white space into _.
  • removing special characters and combinations.
    Parameters
    [in]_topicInput topic, which may be invalid.
    Returns
    A valid topic, or empty string if not possible to convert.

◆ CreateLivelinessToken() [1/2]

static std::string CreateLivelinessToken ( const std::string _fullyQualifiedTopic,
const std::string _pUuid,
const std::string _nUuid,
const std::string _entityType,
const std::string _reqTypeName,
const std::string _repTypeName 
)
static

Create a liveliness token.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_fullyQualifiedTopicThe fully qualified topic.
[in]_pUuidThe process UUID.
[in]_nUuidThe node UUID.
[in]_entityTypeThe entity type.
  • MP for a message publisher.
  • MS for a message subscription.
  • SS for a service server.
[in]_reqTypeNameThe service request type.
[in]_repTypeNameThe service response type.
Returns
The liveliness token.

◆ CreateLivelinessToken() [2/2]

static std::string CreateLivelinessToken ( const std::string _fullyQualifiedTopic,
const std::string _pUuid,
const std::string _nUuid,
const std::string _entityType,
const std::string _typeName 
)
static

Create a liveliness token.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_fullyQualifiedTopicThe fully qualified topic.
[in]_pUuidThe process UUID.
[in]_nUuidThe node UUID.
[in]_entityTypeThe entity type.
  • MP for a message publisher.
  • MS for a message subscription.
  • SS for a service server.
[in]_typeNameThe message type.
Returns
The liveliness token.

◆ CreateLivelinessTokenHelper()

static std::string CreateLivelinessTokenHelper ( const std::string _fullyQualifiedTopic,
const std::string _pUuid,
const std::string _nUuid,
const std::string _entityType 
)
static

Create a partial liveliness token.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_fullyQualifiedTopicThe fully qualified topic.
[in]_pUuidThe process UUID.
[in]_nUuidThe node UUID.
[in]_entityTypeThe entity type.
  • MP for a message publisher.
  • MS for a message subscription.
  • SS for a service server.
Returns
A partial liveliness token.

◆ DecomposeFullyQualifiedTopic()

static bool DecomposeFullyQualifiedTopic ( const std::string _fullyQualifiedName,
std::string _partition,
std::string _namespaceAndTopic 
)
static

Decompose a fully qualified topic name into its partition and topic strings. Note that if the topic is preceded by a namespace, then the namespace and topic name will remain together as one string.

Given a fully qualified topic name with the following syntax:

@<PARTITION>@<NAMESPACE>/<TOPIC>

The _partition output argument will be set to <PARTITION>, and the _namespaceAndTopic output argument will be set to <NAMESPACE>/<TOPIC>.

Parameters
[in]_fullyQualifiedNameThe fully qualified topic name.
[out]_partitionThe partition component of the fully qualified topic name.
[out]_namespaceAndTopicThe namespace and topic name component. Note that there is no way to distinguish between where a namespace ends and a topic name begins, since topic names may contain slashes.
Returns
True if the topic and partition were set.
See also
FullyQualifiedName

◆ DecomposeLivelinessToken() [1/2]

static bool DecomposeLivelinessToken ( const std::string _token,
std::string _prefix,
std::string _partition,
std::string _namespaceAndTopic,
std::string _pUUID,
std::string _nUUID,
std::string _entityType,
std::string _reqType,
std::string _repType 
)
static

Decompose a Zenoh liveliness token into its components.

Given a Zenoh liveliness token with the following syntax:

<prefix>/<partition>/<session_id>/<node_id>/<entity_id>/ <entity_kind>/<mangled_enclave>/<mangled_namespace>/<node_name>/ <mangled_qualified_name>/<type_name>/<type_hash>/<qos>

The _prefix output argument will be set from <prefix>, the _partition output argument will be set from <partition>, the _namespaceAndTopic output argument will be set and unmangled from <mangled_namespace>/<mangled_qualified_name>, the _pUUID output argument will be set from <session_id>, the _nUUID output argument will be set from <node_id>, the _entityType output argument will be set from <entity_kind>, the _reqType and _reptype output arguments will be set from unmangling <type_name>.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_tokenThe Zenoh liveliness token.
[out]_prefixThe prefix component.
[out]_partitionThe partition component.
[out]_namespaceAndTopicThe namespace and topic name component. Note that there is no way to distinguish between where a namespace ends and a topic name begins, since topic names may contain slashes.
[out]_pUUIDThe process UUID component.
[out]_nUUIDThe node UUID component.
[out]_entityTypeThe entity type.
  • MP for a message publisher.
  • MS for a message subscription.
  • SS for a service server.
[out]_reqTypeThe service request message type.
[out]_repTypeThe service response message type.
Returns
True if all the components were set.

◆ DecomposeLivelinessToken() [2/2]

static bool DecomposeLivelinessToken ( const std::string _token,
std::string _prefix,
std::string _partition,
std::string _namespaceAndTopic,
std::string _pUUID,
std::string _nUUID,
std::string _entityType,
std::string _typeName 
)
static

Decompose a Zenoh liveliness token into its components.

Given a Zenoh liveliness token with the following syntax:

<prefix>/<partition>/<session_id>/<node_id>/<entity_id>/ <entity_kind>/<mangled_enclave>/<mangled_namespace>/<node_name>/ <mangled_qualified_name>/<type_name>/<type_hash>/<qos>

The _prefix output argument will be set from <prefix>, the _partition output argument will be set from <partition>, the _namespaceAndTopic output argument will be set and unmangled from <mangled_namespace>/<mangled_qualified_name>, the _pUUID output argument will be set from <session_id>, the _nUUID output argument will be set from <node_id>, the _entityType output argument will be set from <entity_kind>, the _msgType output argument will be set from <type_name>.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_tokenThe Zenoh liveliness token.
[out]_prefixThe prefix component.
[out]_partitionThe partition component.
[out]_namespaceAndTopicThe namespace and topic name component. Note that there is no way to distinguish between where a namespace ends and a topic name begins, since topic names may contain slashes.
[out]_pUUIDThe process UUID component.
[out]_nUUIDThe node UUID component.
[out]_entityTypeThe entity type.
  • MP for a message publisher.
  • MS for a message subscription.
  • SS for a service server.
[out]_typeNameThe message type component.
Returns
True if all the components were set.

◆ DecomposeLivelinessTokenHelper()

static bool DecomposeLivelinessTokenHelper ( const std::string _token,
std::string _prefix,
std::string _partition,
std::string _namespaceAndTopic,
std::string _pUUID,
std::string _nUUID,
std::string _entityType,
std::string _remainingToken 
)
static

Partially decompose a Zenoh liveliness token into its components.

Given a Zenoh liveliness token with the following syntax:

<prefix>/<partition>/<session_id>/<node_id>/<entity_id>/ <entity_kind>/<mangled_enclave>/<mangled_namespace>/<node_name>/ <mangled_qualified_name>/<type_name>/<type_hash>/<qos>

The _prefix output argument will be set from <prefix>, the _partition output argument will be set from <partition>, the _namespaceAndTopic output argument will be set and unmangled from <mangled_namespace>/<mangled_qualified_name>, the _pUUID output argument will be set from <session_id>, the _nUUID output argument will be set from <node_id>, the _entityType output argument will be set from <entity_kind>, the _remainingToken output argument will be set from the remaining token to be processed afterwards.

We're using the ROS 2 liveliness token convention. https://github.com/ros2/rmw_zenoh/blob/rolling/docs/design.md#graph-cache

Parameters
[in]_tokenThe Zenoh liveliness token.
[out]_prefixThe prefix component.
[out]_partitionThe partition component.
[out]_namespaceAndTopicThe namespace and topic name component. Note that there is no way to distinguish between where a namespace ends and a topic name begins, since topic names may contain slashes.
[out]_pUUIDThe process UUID component.
[out]_nUUIDThe node UUID component.
[out]_entityTypeThe entity type (pub, sub) component.
[out]_remainingTokenThe part of the token unprocessed.
Returns
True if all the components were set.

◆ DemangleName()

static std::string DemangleName ( const std::string _input)
static

Recompose a previously mangled name.

Parameters
[in]_inputInput mangled name.
Returns
The unmangled name.

◆ DemangleType()

static bool DemangleType ( const std::string _input,
std::vector< std::string > &  _output 
)
static

Recompose a previously mangled type.

Parameters
[in]_inputInput mangled type.
[out]_outputThe unmangled vector with types.
Returns
True if the demanged worked succesfully.

◆ FullyQualifiedName()

static bool FullyQualifiedName ( const std::string _partition,
const std::string _ns,
const std::string _topic,
std::string _name 
)
static

Get the full topic path given a namespace and a topic name. A fully qualified topic name's length must not exceed kMaxNameLength. The fully qualified name follows the next syntax: @<PARTITION>@<NAMESPACE>/<TOPIC> where: <PARTITION>: The name of the partition or empty string. A "/" will be prefixed to the partition name unless is empty or it already starts with slash. A trailing slash will always be removed. <NAMESPACE>: The namespace or empty string. A namespace is a prefix applied to the topic name. If not empty, it will always start with a "/". A trailing slash will always be removed <TOPIC>: The topic name. A trailing slash will always be removed.

Note: Intuitively, you can imagine the fully qualified name as a UNIX absolute path, where the partition is always surrounded by "@". A namespace, if present, corresponds with the directories of the path, and you can imagine the topic as the filename.

E.g.: Only topic: @/topic No partition: @/namespace/topic1 No namespace: @/partition@/topic1 Partition+namespace+topic: @/my_partition@/name/space/topic

Parameters
[in]_partitionPartition name.
[in]_nsNamespace.
[in]_topicTopic name.
[out]_nameFully qualified topic name.
Returns
True if the fully qualified name is valid (if partition, namespace and topic are correct).
See also
IsValidPartition
IsValidNamespace
IsValidTopic
DecomposeFullyQualifiedTopic

Referenced by FullyQualifiedTopic::FullyQualifiedTopic().

◆ IsValidNamespace()

static bool IsValidNamespace ( const std::string _ns)
static

Determines if a namespace is valid. A namespace's length must not exceed kMaxNameLength. The following symbols are not allowed as part of the namespace: '@', ':=', '~'.

Parameters
[in]_nsNamespace to be checked.
Returns
true if the namespace is valid.

◆ IsValidPartition()

static bool IsValidPartition ( const std::string _partition)
static

Determines if a partition is valid. The same rules to validate a topic name applies to a partition with the addition of the empty string, which is a valid partition (meaning no partition is used). A partition name's length must not exceed kMaxNameLength.

Parameters
[in]_partitionPartition to be checked.
Returns
true if the partition is valid.

◆ IsValidTopic()

static bool IsValidTopic ( const std::string _topic)
static

Determines if a topic name is valid. A topic name is any non-empty alphanumeric string. The symbol '/' is also allowed as part of a topic name. The following symbols are not allowed as part of the topic name: '@', ':=', '~'. A topic name's length must not exceed kMaxNameLength. Examples of valid topics: abc, /abc, /abc/de, /abc/de/.

Parameters
[in]_topicTopic name to be checked.
Returns
true if the topic name is valid.

◆ MangleName()

static std::string MangleName ( const std::string _input)
static

Replace "/" instances with "%".

Parameters
[in]_inputInput name.
Returns
The mangled name.

◆ MangleType()

static bool MangleType ( const std::vector< std::string > &  _input,
std::string _output 
)
static

Mangle multiple types into a single string using "&" as delimiter.

Parameters
[in]_inputInput vector with types.
[out]_outputThe mangled string.
Returns
True if the mangled worked succesfully.

Member Data Documentation

◆ kMaxNameLength

const uint16_t kMaxNameLength = 65535
static

The kMaxNameLength specifies the maximum number of characters allowed in a namespace, a partition name, a topic name, and a fully qualified topic name.

◆ kSlashReplacement

const char kSlashReplacement
static

A replacement for the slash when mangling names.

◆ kTokenPrefix

const char kTokenPrefix[]
static

A common prefix for all liveliness tokens.

◆ kTokenSeparator

const char kTokenSeparator[]
static

The separator used within the liveliness token.

◆ kTypeSeparator

const char kTypeSeparator[]
static

The separator used to concatenate type names.


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