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... | |
PublisherPtr | Advertise (const std::string &_topic, const std::string &_msgTypeName, unsigned int _queueLimit, double _hzRate) |
Advertise on a topic. 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 TopicManager * | Instance () |
Get an instance of the singleton. More... | |
Manages topics and their subscriptions.
typedef std::map<std::string, std::list<NodePtr> > SubNodeMap |
A map of string->list of Node pointers.
void AddNode | ( | NodePtr | _node | ) |
Add a node to the manager.
[in,out] | _node | The node to be added |
void AddNodeToProcess | ( | NodePtr | _ptr | ) |
Add a node to the list of nodes that requires processing.
[in] | _ptr | Node to process. |
|
inline |
|
inline |
void ClearBuffers | ( | ) |
Clear all buffers.
void ConnectPubToSub | ( | const std::string & | _topic, |
const SubscriptionTransportPtr | _sublink | ||
) |
Connection a local Publisher to a remote Subscriber.
[in] | _topic | The topic to use |
[in] | _sublink | The subscription transport object to use |
void ConnectSubscribers | ( | const std::string & | _topic | ) |
Connect all subscribers on a topic to known publishers.
[in] | _topic | The topic to be connected |
void ConnectSubToPub | ( | const msgs::Publish & | _pub | ) |
Connect a local Subscriber to a remote Publisher.
[in] | _pub | The publish object to use |
void DisconnectPubFromSub | ( | const std::string & | _topic, |
const std::string & | _host, | ||
unsigned int | _port | ||
) |
Disconnect a local publisher from a remote subscriber.
[in] | _topic | The topic to be disconnected |
[in] | _host | The host to be disconnected |
[in] | _port | The port to be disconnected |
void DisconnectSubFromPub | ( | const std::string & | _topic, |
const std::string & | _host, | ||
unsigned int | _port | ||
) |
Disconnect all local subscribers from a remote publisher.
[in] | _topic | The topic to be disconnected |
[in] | _host | The host to be disconnected |
[in] | _port | The port to be disconnected |
PublicationPtr FindPublication | ( | const std::string & | _topic | ) |
Find a publication object by topic.
[in] | _topic | The topic to search for |
void Fini | ( | ) |
Finalize the manager.
void GetTopicNamespaces | ( | std::list< std::string > & | _namespaces | ) |
Get all the topic namespaces.
[out] | _namespaces | The list of namespaces will be written here |
void Init | ( | ) |
Initialize the manager.
|
inlinestaticinherited |
Get an instance of the singleton.
Referenced by Node::Advertise(), and Node::Subscribe().
void PauseIncoming | ( | bool | _pause | ) |
Pause or unpause processing of incoming messages.
[in] | _pause | If true pause processing; otherwse unpause |
void ProcessNodes | ( | bool | _onlyOut = false | ) |
Process all nodes under management.
[in] | _onlyOut | True means only outbound messages on nodes will be sent. False means nodes process both outbound and inbound messages |
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.
[in] | _topic | Name of the topic |
[in] | _message | The message to send. |
[in] | _cb | Callback, used when the publish is completed. |
[in] | _id | ID associated with the message. |
void RegisterTopicNamespace | ( | const std::string & | _name | ) |
Register a new topic namespace.
[in] | _name | The name of the new namespace |
void RemoveNode | ( | unsigned int | _id | ) |
Remove a node by its id.
[in] | _id | The ID of the node to be removed |
SubscriberPtr Subscribe | ( | const SubscribeOptions & | _options | ) |
Subscribe to a topic.
[in] | _options | The options to use for the subscription |
void Unadvertise | ( | const std::string & | _topic | ) |
Unadvertise a topic.
[in] | _topic | The topic to be unadvertised |
void Unadvertise | ( | PublisherPtr | _pub | ) |
Unadvertise a publisher.
[in] | _pub | Publisher to unadvertise. |
void Unadvertise | ( | const std::string & | _topic, |
const uint32_t | _id | ||
) |
Unadvertise a publisher, based on a publisher id.
[in] | _topic | The publisher's topic. It will also be unadvertised if there are no advertised publishers left. |
[in] | _id | ID of the publisher to unadvertise. |
void Unsubscribe | ( | const std::string & | _topic, |
const NodePtr & | _sub | ||
) |
Unsubscribe from a topic.
Use a Subscriber rather than calling this function directly
[in] | _topic | The topic to unsubscribe from |
[in] | _sub | The node to unsubscribe |
PublicationPtr UpdatePublications | ( | const std::string & | _topic, |
const std::string & | _msgType | ||
) |
Update our list of advertised topics.
[in] | _topic | The topic to be updated |
[in] | _msgType | The type of the topic to be updated |