Ignition Transport

API Reference

4.0.0
TopicStorage< T > Class Template Reference

Store address information about topics and provide convenient methods for adding new topics, removing them, etc. More...

#include <ignition/transport/TopicStorage.hh>

Public Member Functions

 TopicStorage ()=default
 Constructor.
virtual ~TopicStorage ()=default
 Destructor.
bool AddPublisher (const T &_publisher)
 Add a new address associated to a given topic and node UUID.
bool DelPublisherByNode (const std::string &_topic, const std::string &_pUuid, const std::string &_nUuid)
 Remove a publisher associated to a given topic and UUID pair.
bool DelPublishersByProc (const std::string &_pUuid)
 Remove all the publishers associated to a given process.
bool HasAnyPublishers (const std::string &_topic, const std::string &_pUuid) const
 Return if there is any publisher stored for the given topic and process UUID.
bool HasPublisher (const std::string &_addr) const
 Return if the requested publisher's address is stored.
bool HasTopic (const std::string &_topic) const
 Return if there is any publisher stored for the given topic.
bool HasTopic (const std::string &_topic, const std::string &_type) const
 Return if there is any publisher stored for the given topic and type.
void Print () const
 Print all the information for debugging purposes.
bool Publisher (const std::string &_topic, const std::string &_pUuid, const std::string &_nUuid, T &_publisher) const
 Get the address information for a given topic and node UUID.
bool Publishers (const std::string &_topic, std::map< std::string, std::vector< T > > &_info) const
 Get the map of publishers stored for a given topic.
void PublishersByNode (const std::string &_pUuid, const std::string &_nUuid, std::vector< T > &_pubs) const
 Given a process UUID and the node UUID, the function returns the list of publishers contained in the node.
void PublishersByProc (const std::string &_pUuid, std::map< std::string, std::vector< T > > &_pubs) const
 Given a process UUID, the function returns the list of publishers contained in this process UUID with its address information.
void TopicList (std::vector< std::string > &_topics) const
 Get the list of topics currently stored.

Detailed Description

template<typename T>
class ignition::transport::TopicStorage< T >

Store address information about topics and provide convenient methods for adding new topics, removing them, etc.

Constructor & Destructor Documentation

◆ TopicStorage()

template<typename T>
TopicStorage ( )
default

Constructor.

◆ ~TopicStorage()

template<typename T>
virtual ~TopicStorage ( )
virtualdefault

Destructor.

Member Function Documentation

◆ AddPublisher()

template<typename T>
bool AddPublisher ( const T & _publisher)
inline

Add a new address associated to a given topic and node UUID.

Parameters
[in]_publisherNew publisher.
Returns
true if the new entry is added or false if not (because it was already stored).

References std::find_if().

◆ DelPublisherByNode()

template<typename T>
bool DelPublisherByNode ( const std::string & _topic,
const std::string & _pUuid,
const std::string & _nUuid )
inline

Remove a publisher associated to a given topic and UUID pair.

Parameters
[in]_topicTopic name
[in]_pUuidProcess UUID of the publisher.
[in]_nUuidNode UUID of the publisher.
Returns
True when the publisher was removed or false otherwise.

References ignition::transport::_topic, and std::remove_if().

◆ DelPublishersByProc()

template<typename T>
bool DelPublishersByProc ( const std::string & _pUuid)
inline

Remove all the publishers associated to a given process.

Parameters
[in]_pUuidProcess' UUID of the publisher.
Returns
True when at least one address was removed or false otherwise.

◆ HasAnyPublishers()

template<typename T>
bool HasAnyPublishers ( const std::string & _topic,
const std::string & _pUuid ) const
inline

Return if there is any publisher stored for the given topic and process UUID.

Parameters
[in]_topicTopic name.
[in]_pUuidProcess UUID of the publisher.
Returns
True if there is at least one address stored for the topic and process UUID.

References ignition::transport::_topic, and HasTopic().

◆ HasPublisher()

template<typename T>
bool HasPublisher ( const std::string & _addr) const
inline

Return if the requested publisher's address is stored.

Parameters
[in]_addrPublisher's address requested
Returns
true if the publisher's address is stored.

◆ HasTopic() [1/2]

template<typename T>
bool HasTopic ( const std::string & _topic) const
inline

Return if there is any publisher stored for the given topic.

Parameters
[in]_topicTopic name.
Returns
True if there is at least one entry stored for the topic.

References ignition::transport::_topic.

Referenced by HasAnyPublishers(), HasTopic(), and Publishers().

◆ HasTopic() [2/2]

template<typename T>
bool HasTopic ( const std::string & _topic,
const std::string & _type ) const
inline

Return if there is any publisher stored for the given topic and type.

Parameters
[in]_topicTopic name.
[in]_typeTopic type.
Returns
True if there is at least one entry stored for the topic and type.

References ignition::transport::_topic, std::find_if(), and HasTopic().

◆ Print()

template<typename T>
void Print ( ) const
inline

Print all the information for debugging purposes.

References std::endl().

◆ Publisher()

template<typename T>
bool Publisher ( const std::string & _topic,
const std::string & _pUuid,
const std::string & _nUuid,
T & _publisher ) const
inline

Get the address information for a given topic and node UUID.

Parameters
[in]_topicTopic name.
[in]_pUuidProcess UUID of the publisher.
[in]_nUuidNode UUID of the publisher.
[out]_publisherPublisher's information requested.
Returns
true if a publisher is found for the given topic and UUID pair

References ignition::transport::_topic, and std::find_if().

◆ Publishers()

template<typename T>
bool Publishers ( const std::string & _topic,
std::map< std::string, std::vector< T > > & _info ) const
inline

Get the map of publishers stored for a given topic.

Parameters
[in]_topicTopic name.
[out]_infoMap of publishers requested.
Returns
true if at least there is one publisher stored.

References ignition::transport::_topic, and HasTopic().

◆ PublishersByNode()

template<typename T>
void PublishersByNode ( const std::string & _pUuid,
const std::string & _nUuid,
std::vector< T > & _pubs ) const
inline

Given a process UUID and the node UUID, the function returns the list of publishers contained in the node.

Parameters
[in]_pUuidProcess UUID.
[in]_nUuidNode UUID.
[out]_pubsVector of publishers.

References vector< T >::clear(), and vector< T >::push_back().

◆ PublishersByProc()

template<typename T>
void PublishersByProc ( const std::string & _pUuid,
std::map< std::string, std::vector< T > > & _pubs ) const
inline

Given a process UUID, the function returns the list of publishers contained in this process UUID with its address information.

Parameters
[in]_pUuidProcess UUID.
[out]_pubsMap of publishers where the keys are the node UUIDs and the value is its address information.

◆ TopicList()

template<typename T>
void TopicList ( std::vector< std::string > & _topics) const
inline

Get the list of topics currently stored.

Parameters
[out]_topicsList of stored topics.

References vector< T >::push_back().


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