TopicManager Class Reference

Manages topics and their subscriptions. More...

#include <transport/transport.hh>

Inherits SingletonT< TopicManager >.

Public Types

typedef std::map< std::string, std::list< NodePtr > > SubNodeMap
 A map of string->list of Node pointers. More...
 

Public Member Functions

void AddNode (NodePtr _node)
 Add a node to the manager. More...
 
void AddNodeToProcess (NodePtr _ptr)
 Add a node to the list of nodes that requires processing. More...
 
template<typename M >
PublisherPtr Advertise (const std::string &_topic, unsigned int _queueLimit, double _hzRate)
 Advertise on a topic. More...
 
void ClearBuffers ()
 Clear all buffers. More...
 
void ConnectPubToSub (const std::string &_topic, const SubscriptionTransportPtr _sublink)
 Connection a local Publisher to a remote Subscriber. More...
 
void ConnectSubscribers (const std::string &_topic)
 Connect all subscribers on a topic to known publishers. More...
 
void ConnectSubToPub (const msgs::Publish &_pub)
 Connect a local Subscriber to a remote Publisher. More...
 
void DisconnectPubFromSub (const std::string &_topic, const std::string &_host, unsigned int _port)
 Disconnect a local publisher from a remote subscriber. More...
 
void DisconnectSubFromPub (const std::string &_topic, const std::string &_host, unsigned int _port)
 Disconnect all local subscribers from a remote publisher. More...
 
PublicationPtr FindPublication (const std::string &_topic)
 Find a publication object by topic. More...
 
void Fini ()
 Finalize the manager. More...
 
void GetTopicNamespaces (std::list< std::string > &_namespaces)
 Get all the topic namespaces. More...
 
void Init ()
 Initialize the manager. More...
 
void PauseIncoming (bool _pause)
 Pause or unpause processing of incoming messages. More...
 
void ProcessNodes (bool _onlyOut=false)
 Process all nodes under management. More...
 
void Publish (const std::string &_topic, MessagePtr _message, boost::function< void(uint32_t)> _cb, uint32_t _id)
 Send a message. More...
 
void RegisterTopicNamespace (const std::string &_name)
 Register a new topic namespace. More...
 
void RemoveNode (unsigned int _id)
 Remove a node by its id. More...
 
SubscriberPtr Subscribe (const SubscribeOptions &_options)
 Subscribe to a topic. More...
 
void Unadvertise (const std::string &_topic)
 Unadvertise a topic. More...
 
void Unadvertise (PublisherPtr _pub)
 Unadvertise a publisher. More...
 
void Unadvertise (const std::string &_topic, const uint32_t _id)
 Unadvertise a publisher, based on a publisher id. More...
 
void Unsubscribe (const std::string &_topic, const NodePtr &_sub)
 Unsubscribe from a topic. More...
 
PublicationPtr UpdatePublications (const std::string &_topic, const std::string &_msgType)
 Update our list of advertised topics. More...
 

Static Public Member Functions

static TopicManagerInstance ()
 Get an instance of the singleton. More...
 

Detailed Description

Manages topics and their subscriptions.

Member Typedef Documentation

§ SubNodeMap

typedef std::map<std::string, std::list<NodePtr> > SubNodeMap

A map of string->list of Node pointers.

Member Function Documentation

§ AddNode()

void AddNode ( NodePtr  _node)

Add a node to the manager.

Parameters
[in,out]_nodeThe node to be added

§ AddNodeToProcess()

void AddNodeToProcess ( NodePtr  _ptr)

Add a node to the list of nodes that requires processing.

Parameters
[in]_ptrNode to process.

Referenced by TopicManager::Advertise().

§ Advertise()

PublisherPtr Advertise ( const std::string &  _topic,
unsigned int  _queueLimit,
double  _hzRate 
)
inline

§ ClearBuffers()

void ClearBuffers ( )

Clear all buffers.

Referenced by TopicManager::Advertise().

§ ConnectPubToSub()

void ConnectPubToSub ( const std::string &  _topic,
const SubscriptionTransportPtr  _sublink 
)

Connection a local Publisher to a remote Subscriber.

Parameters
[in]_topicThe topic to use
[in]_sublinkThe subscription transport object to use

Referenced by TopicManager::Advertise().

§ ConnectSubscribers()

void ConnectSubscribers ( const std::string &  _topic)

Connect all subscribers on a topic to known publishers.

Parameters
[in]_topicThe topic to be connected

Referenced by TopicManager::Advertise().

§ ConnectSubToPub()

void ConnectSubToPub ( const msgs::Publish &  _pub)

Connect a local Subscriber to a remote Publisher.

Parameters
[in]_pubThe publish object to use

Referenced by TopicManager::Advertise().

§ DisconnectPubFromSub()

void DisconnectPubFromSub ( const std::string &  _topic,
const std::string &  _host,
unsigned int  _port 
)

Disconnect a local publisher from a remote subscriber.

Parameters
[in]_topicThe topic to be disconnected
[in]_hostThe host to be disconnected
[in]_portThe port to be disconnected

Referenced by TopicManager::Advertise().

§ DisconnectSubFromPub()

void DisconnectSubFromPub ( const std::string &  _topic,
const std::string &  _host,
unsigned int  _port 
)

Disconnect all local subscribers from a remote publisher.

Parameters
[in]_topicThe topic to be disconnected
[in]_hostThe host to be disconnected
[in]_portThe port to be disconnected

Referenced by TopicManager::Advertise().

§ FindPublication()

PublicationPtr FindPublication ( const std::string &  _topic)

Find a publication object by topic.

Parameters
[in]_topicThe topic to search for
Returns
Pointer to the publication object, if found (can be null)

Referenced by TopicManager::Advertise().

§ Fini()

void Fini ( )

Finalize the manager.

§ GetTopicNamespaces()

void GetTopicNamespaces ( std::list< std::string > &  _namespaces)

Get all the topic namespaces.

Parameters
[out]_namespacesThe list of namespaces will be written here

Referenced by TopicManager::Advertise().

§ Init()

void Init ( )

Initialize the manager.

§ Instance()

static TopicManager * Instance ( )
inlinestaticinherited

Get an instance of the singleton.

Referenced by Node::Advertise(), and Node::Subscribe().

§ PauseIncoming()

void PauseIncoming ( bool  _pause)

Pause or unpause processing of incoming messages.

Parameters
[in]_pauseIf true pause processing; otherwse unpause

Referenced by TopicManager::Advertise().

§ ProcessNodes()

void ProcessNodes ( bool  _onlyOut = false)

Process all nodes under management.

Parameters
[in]_onlyOutTrue means only outbound messages on nodes will be sent. False means nodes process both outbound and inbound messages

§ Publish()

void Publish ( const std::string &  _topic,
MessagePtr  _message,
boost::function< void(uint32_t)>  _cb,
uint32_t  _id 
)

Send a message.

Use a Publisher instead of calling this function directly.

Parameters
[in]_topicName of the topic
[in]_messageThe message to send.
[in]_cbCallback, used when the publish is completed.
[in]_idID associated with the message.

Referenced by TopicManager::Advertise().

§ RegisterTopicNamespace()

void RegisterTopicNamespace ( const std::string &  _name)

Register a new topic namespace.

Parameters
[in]_nameThe name of the new namespace

Referenced by TopicManager::Advertise().

§ RemoveNode()

void RemoveNode ( unsigned int  _id)

Remove a node by its id.

Parameters
[in]_idThe ID of the node to be removed

§ Subscribe()

SubscriberPtr Subscribe ( const SubscribeOptions _options)

Subscribe to a topic.

Parameters
[in]_optionsThe options to use for the subscription
Returns
Pointer to the newly created subscriber

§ Unadvertise() [1/3]

void Unadvertise ( const std::string &  _topic)

Unadvertise a topic.

Parameters
[in]_topicThe topic to be unadvertised

Referenced by TopicManager::Advertise().

§ Unadvertise() [2/3]

void Unadvertise ( PublisherPtr  _pub)

Unadvertise a publisher.

Parameters
[in]_pubPublisher to unadvertise.

§ Unadvertise() [3/3]

void Unadvertise ( const std::string &  _topic,
const uint32_t  _id 
)

Unadvertise a publisher, based on a publisher id.

Parameters
[in]_topicThe publisher's topic. It will also be unadvertised if there are no advertised publishers left.
[in]_idID of the publisher to unadvertise.

§ Unsubscribe()

void Unsubscribe ( const std::string &  _topic,
const NodePtr _sub 
)

Unsubscribe from a topic.

Use a Subscriber rather than calling this function directly

Parameters
[in]_topicThe topic to unsubscribe from
[in]_subThe node to unsubscribe

§ UpdatePublications()

PublicationPtr UpdatePublications ( const std::string &  _topic,
const std::string &  _msgType 
)

Update our list of advertised topics.

Parameters
[in]_topicThe topic to be updated
[in]_msgTypeThe type of the topic to be updated
Returns
True if the provided params define a new publisher, false otherwise

Referenced by TopicManager::Advertise().


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