Manages topics and their subscriptions. More...
#include <transport/transport.hh>
Public Types | |
typedef std::map< std::string, std::list< NodePtr > > | SubNodeMap |
A map of string->list of Node pointers. | |
Public Member Functions | |
void | AddNode (NodePtr _node) |
Add a node to the manager. | |
template<typename M > | |
PublisherPtr | Advertise (const std::string &_topic, unsigned int _queueLimit) |
Advertise on a topic. | |
void | ClearBuffers () |
Clear all buffers. | |
void | ConnectPubToSub (const std::string &_topic, const SubscriptionTransportPtr &_sublink) |
Connection a local Publisher to a remote Subscriber. | |
void | ConnectSubscribers (const std::string &_topic) |
Connect all subscribers on a topic to known publishers. | |
void | ConnectSubToPub (const msgs::Publish &_pub) |
Connect a local Subscriber to a remote Publisher. | |
void | DisconnectPubFromSub (const std::string &_topic, const std::string &_host, unsigned int _port) |
Disconnect a local publisher from a remote subscriber. | |
void | DisconnectSubFromPub (const std::string &_topic, const std::string &_host, unsigned int _port) |
Disconnect all local subscribers from a remote publisher. | |
PublicationPtr | FindPublication (const std::string &_topic) |
Find a publication object by topic. | |
void | Fini () |
Finalize the manager. | |
std::map< std::string, std::list< std::string > > | GetAdvertisedTopics () const GAZEBO_DEPRECATED |
Get a list of all the topics. | |
void | GetTopicNamespaces (std::list< std::string > &_namespaces) |
Get all the topic namespaces. | |
void | Init () |
Initialize the manager. | |
bool | IsAdvertised (const std::string &_topic) |
Has the topic been advertised? | |
void | PauseIncoming (bool _pause) |
Pause or unpause processing of incoming messages. | |
void | ProcessNodes (bool _onlyOut=false) |
Process all nodes under management. | |
void | Publish (const std::string &_topic, const google::protobuf::Message &_message, const boost::function< void()> &_cb=NULL) |
Send a message. | |
void | RegisterTopicNamespace (const std::string &_name) |
Register a new topic namespace. | |
void | RemoveNode (unsigned int _id) |
Remove a node by its id. | |
SubscriberPtr | Subscribe (const SubscribeOptions &_options) |
Subscribe to a topic. | |
void | Unadvertise (const std::string &_topic) |
Unadvertise a topic. | |
void | Unsubscribe (const std::string &_topic, const NodePtr &_sub) |
Unsubscribe from a topic. | |
PublicationPtr | UpdatePublications (const std::string &_topic, const std::string &_msgType) |
Update our list of advertised topics. | |
Additional Inherited Members | |
Static Public Member Functions inherited from SingletonT< T > | |
static T * | Instance () |
Get an instance of the singleton. | |
Protected Member Functions inherited from SingletonT< T > | |
SingletonT () | |
Constructor. | |
virtual | ~SingletonT () |
Destructor. | |
Manages topics and their subscriptions.
typedef std::map<std::string, std::list<NodePtr> > gazebo::transport::TopicManager::SubNodeMap |
void gazebo::transport::TopicManager::AddNode | ( | NodePtr | _node | ) |
Add a node to the manager.
[in,out] | _node | The node to be added |
|
inline |
Advertise on a topic.
[in] | _topic | The name of the topic |
[in] | _queueLimit | The maximum number of outgoing messages to queue |
References gazebo::transport::Publication::AddPublisher(), gazebo::transport::Publication::AddSubscription(), FindPublication(), gazebo::transport::Publication::GetLocallyAdvertised(), gzthrow, SingletonT< T >::Instance(), NULL, gazebo::transport::Publication::SetLocallyAdvertised(), and UpdatePublications().
void gazebo::transport::TopicManager::ClearBuffers | ( | ) |
Clear all buffers.
void gazebo::transport::TopicManager::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 gazebo::transport::TopicManager::ConnectSubscribers | ( | const std::string & | _topic | ) |
Connect all subscribers on a topic to known publishers.
[in] | _topic | The topic to be connected |
void gazebo::transport::TopicManager::ConnectSubToPub | ( | const msgs::Publish & | _pub | ) |
Connect a local Subscriber to a remote Publisher.
[in] | _pub | The publish object to use |
void gazebo::transport::TopicManager::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 gazebo::transport::TopicManager::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 gazebo::transport::TopicManager::FindPublication | ( | const std::string & | _topic | ) |
Find a publication object by topic.
[in] | _topic | The topic to search for |
Referenced by Advertise().
void gazebo::transport::TopicManager::Fini | ( | ) |
Finalize the manager.
std::map<std::string, std::list<std::string> > gazebo::transport::TopicManager::GetAdvertisedTopics | ( | ) | const |
Get a list of all the topics.
void gazebo::transport::TopicManager::GetTopicNamespaces | ( | std::list< std::string > & | _namespaces | ) |
Get all the topic namespaces.
[out] | _namespaces | The list of namespaces will be written here |
void gazebo::transport::TopicManager::Init | ( | ) |
Initialize the manager.
bool gazebo::transport::TopicManager::IsAdvertised | ( | const std::string & | _topic | ) |
Has the topic been advertised?
[in] | _topic | The name of the topic to check |
void gazebo::transport::TopicManager::PauseIncoming | ( | bool | _pause | ) |
Pause or unpause processing of incoming messages.
[in] | _pause | If true pause processing; otherwse unpause |
void gazebo::transport::TopicManager::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 gazebo::transport::TopicManager::Publish | ( | const std::string & | _topic, |
const google::protobuf::Message & | _message, | ||
const boost::function< void()> & | _cb = NULL |
||
) |
Send a message.
Use a Publisher instead of calling this function directly.
_topic | Name of the topic |
_message | The message to send. |
_cb | Callback, used when the publish is completed. |
void gazebo::transport::TopicManager::RegisterTopicNamespace | ( | const std::string & | _name | ) |
Register a new topic namespace.
[in] | _name | The name of the new namespace |
void gazebo::transport::TopicManager::RemoveNode | ( | unsigned int | _id | ) |
Remove a node by its id.
[in] | _id | The ID of the node to be removed |
SubscriberPtr gazebo::transport::TopicManager::Subscribe | ( | const SubscribeOptions & | _options | ) |
Subscribe to a topic.
[in] | _options | The options to use for the subscription |
void gazebo::transport::TopicManager::Unadvertise | ( | const std::string & | _topic | ) |
Unadvertise a topic.
[in] | _topic | The topic to be unadvertised |
void gazebo::transport::TopicManager::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 gazebo::transport::TopicManager::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 |
Referenced by Advertise().