A publisher of messages on a topic. More...
#include <transport/transport.hh>
Inherits enable_shared_from_this< Publisher >.
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... | |
unsigned int | GetRemoteSubscriptionCount () |
Get the amount of remote subscribers. 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 message(s) in the local buffer over the wire. 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... | |
A publisher of messages on a topic.
Publisher | ( | const std::string & | _topic, |
const std::string & | _msgType, | ||
unsigned int | _limit, | ||
double | _hzRate | ||
) |
Constructor.
[in] | _topic | Name of topic to be published |
[in] | _msgType | Type of the message to be published |
[in] | _limit | Maximum number of outgoing messages to queue |
[in] | _hz | Update rate for the publisher. Units are 1.0/seconds. |
|
virtual |
Destructor.
void Fini | ( | ) |
Finalize the publisher.
Referenced by Publisher::Publish().
std::string GetMsgType | ( | ) | const |
unsigned int GetOutgoingCount | ( | ) | const |
Get the number of outgoing messages.
Referenced by Publisher::Publish().
std::string GetPrevMsg | ( | ) | const |
Get the previously published message.
Referenced by Publisher::Publish().
MessagePtr GetPrevMsgPtr | ( | ) | const |
Get the previously published message.
Referenced by Publisher::Publish().
unsigned int GetRemoteSubscriptionCount | ( | ) |
Get the amount of remote subscribers.
std::string GetTopic | ( | ) | const |
bool HasConnections | ( | ) | const |
Are there any connections?
uint32_t Id | ( | ) | const |
Get the id of this publisher.
Referenced by Publisher::Publish().
|
inline |
Publish a protobuf message on the topic.
[in] | _message | Message to be published |
[in] | _block | Whether to block until the message is actually written into the local message buffer, and SendMessage() is called. Note that it may be required to call SendMessage() again if it could not be sent out immediately. Check with GetOutgoingCount() if there are still messages in the queue which need to be sent out. |
|
inline |
Publish an arbitrary message on the topic.
[in] | _message | Message to be published |
[in] | _block | Whether to block until the message is actually written into the local message buffer, and SendMessage() is called. Note that it may be required to call SendMessage() again if it could not be sent out immediately. Check with GetOutgoingCount() if there are still messages in the queue which need to be sent out. |
References Publisher::Fini(), Publisher::GetMsgType(), Publisher::GetOutgoingCount(), Publisher::GetPrevMsg(), Publisher::GetPrevMsgPtr(), Publisher::GetTopic(), Publisher::Id(), Publisher::SendMessage(), and Publisher::SetNode().
void SendMessage | ( | ) |
Send message(s) in the local buffer over the wire.
This will be called from Publish() and should normally only be used internally, however you may need to call this function if using blocking calls to Publish (parameter _block = true) in order to ensure the whole message buffer is sent out.
Referenced by Publisher::Publish().
void SetNode | ( | NodePtr | _node | ) |
Set our containing node.
[in] | _node | Pointer to a node. Should be the node that create this publisher. |
Referenced by Publisher::Publish().
void SetPublication | ( | PublicationPtr | _publication | ) |
Set the publication object for a particular publication.
[in] | _publication | Pointer to the publication object to be set |
void WaitForConnection | ( | ) | const |
Block until a connection has been established with this publisher.
bool WaitForConnection | ( | const common::Time & | _timeout | ) | const |
Block until a connection has been established with this publisher.
[in] | _timeout | Maxiumum time to wait. Use a negative time value to wait forever. |