A publisher of messages on a topic.
More...
#include <transport/transport.hh>
Inherits enable_shared_from_this< Publisher >.
|
| Publisher (const std::string &_topic, const std::string &_msgType, unsigned int _limit, double _hzRate) |
| Constructor.
|
|
virtual | ~Publisher () |
| Destructor.
|
|
void | Fini () |
| Finalize the publisher.
|
|
std::string | GetMsgType () const |
| Get the message type.
|
|
unsigned int | GetOutgoingCount () const |
| Get the number of outgoing messages.
|
|
std::string | GetPrevMsg () const |
| Get the previously published message.
|
|
MessagePtr | GetPrevMsgPtr () const |
| Get the previously published message.
|
|
unsigned int | GetRemoteSubscriptionCount () |
| Get the amount of remote subscribers.
|
|
std::string | GetTopic () const |
| Get the topic name.
|
|
bool | HasConnections () const |
| Are there any connections?
|
|
uint32_t | Id () const |
| Get the id of this publisher.
|
|
void | Publish (const google::protobuf::Message &_message, bool _block=false) |
| Publish a protobuf message on the topic.
|
|
template<typename M > |
void | Publish (M _message, bool _block=false) |
| Publish an arbitrary message on the topic.
|
|
void | SendMessage () |
| Send message(s) in the local buffer over the wire.
|
|
void | SetNode (NodePtr _node) |
| Set our containing node.
|
|
void | SetPublication (PublicationPtr _publication) |
| Set the publication object for a particular publication.
|
|
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.
|
|
A publisher of messages on a topic.
◆ Publisher()
Publisher |
( |
const std::string & | _topic, |
|
|
const std::string & | _msgType, |
|
|
unsigned int | _limit, |
|
|
double | _hzRate ) |
Constructor.
- Parameters
-
[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. |
◆ ~Publisher()
◆ Fini()
◆ GetMsgType()
std::string GetMsgType |
( |
| ) |
const |
Get the message type.
- Returns
- The message type
◆ GetOutgoingCount()
unsigned int GetOutgoingCount |
( |
| ) |
const |
Get the number of outgoing messages.
- Returns
- The number of outgoing messages
◆ GetPrevMsg()
std::string GetPrevMsg |
( |
| ) |
const |
Get the previously published message.
- Returns
- The previously published message, if any
◆ GetPrevMsgPtr()
Get the previously published message.
- Returns
- The previously published message, if any
◆ GetRemoteSubscriptionCount()
unsigned int GetRemoteSubscriptionCount |
( |
| ) |
|
◆ GetTopic()
std::string GetTopic |
( |
| ) |
const |
Get the topic name.
- Returns
- The topic name
◆ HasConnections()
bool HasConnections |
( |
| ) |
const |
Are there any connections?
- Returns
- true if there are any connections, false otherwise
◆ Id()
Get the id of this publisher.
- Returns
- Unique id of this publisher.
◆ Publish() [1/2]
void Publish |
( |
const google::protobuf::Message & | _message, |
|
|
bool | _block = false ) |
|
inline |
Publish a protobuf message on the topic.
- Parameters
-
[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. |
◆ Publish() [2/2]
template<typename M >
void Publish |
( |
M | _message, |
|
|
bool | _block = false ) |
|
inline |
Publish an arbitrary message on the topic.
- Parameters
-
[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. |
◆ 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.
◆ SetNode()
Set our containing node.
- Parameters
-
[in] | _node | Pointer to a node. Should be the node that create this publisher. |
◆ SetPublication()
Set the publication object for a particular publication.
- Parameters
-
[in] | _publication | Pointer 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] | _timeout | Maxiumum 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: