Publisher Class Reference

A publisher of messages on a topic. More...

#include <transport/transport.hh>

Public Member Functions

 Publisher (const std::string &_topic, const std::string &_msgType, unsigned int _limit, double _hzRate)
 Constructor. More...
 
virtual ~Publisher ()
 Destructor. More...
 
void Fini ()
 Finalize the publisher. More...
 
std::string GetMsgType () const
 Get the message type. More...
 
unsigned int GetOutgoingCount () const
 Get the number of outgoing messages. More...
 
std::string GetPrevMsg () const
 Get the previously published message. More...
 
MessagePtr GetPrevMsgPtr () const
 Get the previously published message. More...
 
std::string GetTopic () const
 Get the topic name. More...
 
bool HasConnections () const
 Are there any connections? More...
 
uint32_t Id () const
 Get the id of this publisher. More...
 
void Publish (const google::protobuf::Message &_message, bool _block=false)
 Publish a protobuf message on the topic. More...
 
template<typename M >
void Publish (M _message, bool _block=false)
 Publish an arbitrary message on the topic. More...
 
void SendMessage ()
 Send latest message over the wire. For internal use only. More...
 
void SetNode (NodePtr _node)
 Set our containing node. More...
 
void SetPublication (PublicationPtr _publication)
 Set the publication object for a particular publication. More...
 
void WaitForConnection () const
 Block until a connection has been established with this publisher. More...
 
bool WaitForConnection (const common::Time &_timeout) const
 Block until a connection has been established with this publisher. More...
 

Detailed Description

A publisher of messages on a topic.

Constructor & Destructor Documentation

§ Publisher()

Publisher ( const std::string &  _topic,
const std::string &  _msgType,
unsigned int  _limit,
double  _hzRate 
)

Constructor.

Parameters
[in]_topicName of topic to be published
[in]_msgTypeType of the message to be published
[in]_limitMaximum number of outgoing messages to queue
[in]_hzUpdate rate for the publisher. Units are 1.0/seconds.

§ ~Publisher()

virtual ~Publisher ( )
virtual

Destructor.

Member Function Documentation

§ Fini()

void Fini ( )

Finalize the publisher.

Referenced by Publisher::Publish().

§ GetMsgType()

std::string GetMsgType ( ) const

Get the message type.

Returns
The message type

Referenced by Publisher::Publish().

§ GetOutgoingCount()

unsigned int GetOutgoingCount ( ) const

Get the number of outgoing messages.

Returns
The number of outgoing messages

Referenced by Publisher::Publish().

§ GetPrevMsg()

std::string GetPrevMsg ( ) const

Get the previously published message.

Returns
The previously published message, if any

Referenced by Publisher::Publish().

§ GetPrevMsgPtr()

MessagePtr GetPrevMsgPtr ( ) const

Get the previously published message.

Returns
The previously published message, if any

Referenced by Publisher::Publish().

§ GetTopic()

std::string GetTopic ( ) const

Get the topic name.

Returns
The topic name

Referenced by Publisher::Publish().

§ HasConnections()

bool HasConnections ( ) const

Are there any connections?

Returns
true if there are any connections, false otherwise

§ Id()

uint32_t Id ( ) const

Get the id of this publisher.

Returns
Unique id of this publisher.

Referenced by Publisher::Publish().

§ Publish() [1/2]

void Publish ( const google::protobuf::Message &  _message,
bool  _block = false 
)
inline

Publish a protobuf message on the topic.

Parameters
[in]_messageMessage to be published
[in]_blockWhether to block until the message is actually written out

§ Publish() [2/2]

void Publish ( _message,
bool  _block = false 
)
inline

Publish an arbitrary message on the topic.

Parameters
[in]_messageMessage to be published
[in]_blockWhether to block until the message is actually written out

References Publisher::Fini(), Publisher::GetMsgType(), Publisher::GetOutgoingCount(), Publisher::GetPrevMsg(), Publisher::GetPrevMsgPtr(), Publisher::GetTopic(), Publisher::Id(), Publisher::SendMessage(), and Publisher::SetNode().

§ SendMessage()

void SendMessage ( )

Send latest message over the wire. For internal use only.

Referenced by Publisher::Publish().

§ SetNode()

void SetNode ( NodePtr  _node)

Set our containing node.

Parameters
[in]_nodePointer to a node. Should be the node that create this publisher.

Referenced by Publisher::Publish().

§ SetPublication()

void SetPublication ( PublicationPtr  _publication)

Set the publication object for a particular publication.

Parameters
[in]_publicationPointer to the publication object to be set

§ WaitForConnection() [1/2]

void WaitForConnection ( ) const

Block until a connection has been established with this publisher.

§ WaitForConnection() [2/2]

bool WaitForConnection ( const common::Time _timeout) const

Block until a connection has been established with this publisher.

Parameters
[in]_timeoutMaxiumum time to wait. Use a negative time value to wait forever.
Returns
True if a connection was established.

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