Ignition Transport

API Reference

4.0.0

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

#include <ignition/transport/TopicUtils.hh>

Static Public Member Functions

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.
 
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 symbol '@' is not allowed in a topic name because it is used as a partition delimitier. A topic name's length must not exceed kMaxNameLength. Examples of valid topics: abc, /abc, /abc/de, /abc/de/.
 

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.
 

Detailed Description

This class provides different utilities related with topics.

Member Function Documentation

◆ 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 sorrounded 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

Referenced by Node::Subscribe().

◆ IsValidNamespace()

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

Determines if a namespace is valid. A namespace's length must not exceed kMaxNameLength.

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 symbol '@' is not allowed in a topic name because it is used as a partition delimitier. 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.

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.


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