Publication Class Reference

A publication for a topic. More...

#include <transport/transport.hh>

Public Member Functions

 Publication (const std::string &_topic, const std::string &_msgType)
 Constructor. More...
 
virtual ~Publication ()
 Destructor. More...
 
void AddPublisher (PublisherPtr _pub)
 Add a publisher. More...
 
void AddSubscription (const CallbackHelperPtr _callback)
 Subscribe a callback to our topic. More...
 
void AddSubscription (const NodePtr &_node)
 Subscribe a node to our topic. More...
 
void AddTransport (const PublicationTransportPtr &_publink)
 Add a transport. More...
 
void ClearPrevMsgs ()
 Clear all previous messages for a publisher. More...
 
unsigned int GetCallbackCount () const
 Get the number of callbacks. More...
 
bool GetLocallyAdvertised () const
 Was the topic has been advertised from this process? More...
 
std::string GetMsgType () const
 Get the type of message. More...
 
unsigned int GetNodeCount () const
 Get the number of nodes. More...
 
MessagePtr GetPrevMsg (uint32_t _pubId)
 Get a previous message for a publisher. More...
 
unsigned int GetRemoteSubscriptionCount ()
 Get the number of remote subscriptions. More...
 
unsigned int GetTransportCount () const
 Get the number of transports. More...
 
bool HasTransport (const std::string &_host, unsigned int _port)
 Does a given transport exist? More...
 
void LocalPublish (const std::string &_data)
 Publish data to local subscribers (skip serialization) More...
 
int Publish (MessagePtr _msg, boost::function< void(uint32_t)> _cb, uint32_t _id)
 Publish data to remote subscribers. More...
 
unsigned int PublisherCount () const
 Get the number of publishers. More...
 
void RemovePublisher (PublisherPtr _pub)
 Remove a publisher. More...
 
bool RemovePublisher (const uint32_t id)
 Remove a publisher, based on a publisher ID. More...
 
void RemoveSubscription (const NodePtr &_node)
 Unsubscribe a node from our topic. More...
 
void RemoveSubscription (const std::string &_host, unsigned int _port)
 Unsubscribe a a node by host/port from our topic. More...
 
void RemoveTransport (const std::string &_host, unsigned int _port)
 Remove a transport. More...
 
void SetLocallyAdvertised (bool _value)
 Set whether this topic has been advertised from this process. More...
 
void SetPrevMsg (uint32_t _pubId, MessagePtr _msg)
 Set the previous message for a publisher. More...
 

Detailed Description

A publication for a topic.

This facilitates transport of messages

Constructor & Destructor Documentation

Publication ( const std::string &  _topic,
const std::string &  _msgType 
)

Constructor.

Parameters
[in]_topicThe topic we're publishing
[in]_msgTypeThe type of the topic we're publishing
virtual ~Publication ( )
virtual

Destructor.

Member Function Documentation

void AddPublisher ( PublisherPtr  _pub)

Add a publisher.

Parameters
[in,out]_pubPointer to publisher object to be added
void AddSubscription ( const CallbackHelperPtr  _callback)

Subscribe a callback to our topic.

Parameters
[in]_callbackThe callback
void AddSubscription ( const NodePtr _node)

Subscribe a node to our topic.

Parameters
[in]_nodeThe node
void AddTransport ( const PublicationTransportPtr _publink)

Add a transport.

Parameters
[in]_publinkPointer to publication transport object to be added
void ClearPrevMsgs ( )

Clear all previous messages for a publisher.

unsigned int GetCallbackCount ( ) const

Get the number of callbacks.

Returns
The number of callbacks
bool GetLocallyAdvertised ( ) const

Was the topic has been advertised from this process?

Returns
true if the topic has been advertised from this process, false otherwise
std::string GetMsgType ( ) const

Get the type of message.

Returns
The type of message
unsigned int GetNodeCount ( ) const

Get the number of nodes.

Returns
The number of nodes
MessagePtr GetPrevMsg ( uint32_t  _pubId)

Get a previous message for a publisher.

Parameters
[in]_pubIdID of the publisher.
Returns
Pointer to the previous message. NULL if there is no previous message.
unsigned int GetRemoteSubscriptionCount ( )

Get the number of remote subscriptions.

Returns
The number of remote subscriptions
unsigned int GetTransportCount ( ) const

Get the number of transports.

Returns
The number of transports
bool HasTransport ( const std::string &  _host,
unsigned int  _port 
)

Does a given transport exist?

Parameters
[in]_hostHostname of the transport
[in]_portPort of the transport
Returns
true if the transport exists, false otherwise
void LocalPublish ( const std::string &  _data)

Publish data to local subscribers (skip serialization)

Parameters
[in]_dataThe data to be published
int Publish ( MessagePtr  _msg,
boost::function< void(uint32_t)>  _cb,
uint32_t  _id 
)

Publish data to remote subscribers.

Parameters
[in]_msgMessage to be published
[in]_cbCallback to be invoked after publishing is completed
Returns
Number of remote subscribers that will receive the message.
unsigned int PublisherCount ( ) const

Get the number of publishers.

Returns
The number of publishers.
void RemovePublisher ( PublisherPtr  _pub)

Remove a publisher.

Parameters
[in]_pubPointer to publisher object to remove.
bool RemovePublisher ( const uint32_t  id)

Remove a publisher, based on a publisher ID.

Parameters
[in]_idID of the publisher to remove.
Returns
True if successful.
void RemoveSubscription ( const NodePtr _node)

Unsubscribe a node from our topic.

Parameters
[in]_nodeThe node
void RemoveSubscription ( const std::string &  _host,
unsigned int  _port 
)

Unsubscribe a a node by host/port from our topic.

Parameters
[in]_hostThe node's hostname
[in]_portThe node's port
void RemoveTransport ( const std::string &  _host,
unsigned int  _port 
)

Remove a transport.

Parameters
[in]_hostThe transport's hostname
[in]_portThe transport's port
void SetLocallyAdvertised ( bool  _value)

Set whether this topic has been advertised from this process.

Parameters
[in]_valueIf true, the topic was locally advertise, otherwise it was not
void SetPrevMsg ( uint32_t  _pubId,
MessagePtr  _msg 
)

Set the previous message for a publisher.

Parameters
[in]_pubIdID of the publisher.
[in]_msgThe previous message.

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