Go to the documentation of this file.
21 #ifndef GAZEBO_TRANSPORT_PUBLISHER_HH_
22 #define GAZEBO_TRANSPORT_PUBLISHER_HH_
24 #include <google/protobuf/message.h>
25 #include <boost/thread.hpp>
26 #include <boost/shared_ptr.hpp>
45 public boost::enable_shared_from_this<Publisher>
53 public:
Publisher(
const std::string &_topic,
const std::string &_msgType,
54 unsigned int _limit,
double _hzRate);
61 public:
bool HasConnections()
const;
65 public:
void WaitForConnection()
const;
72 public:
bool WaitForConnection(
const common::Time &_timeout)
const;
80 public:
unsigned int GetRemoteSubscriptionCount();
89 public:
void Publish(
const google::protobuf::Message &_message,
91 { this->PublishImpl(_message, _block); }
100 public:
template<
typename M>
102 { this->PublishImpl(_message, _block); }
106 public:
unsigned int GetOutgoingCount()
const;
110 public: std::string GetTopic()
const;
114 public: std::string GetMsgType()
const;
121 public:
void SendMessage();
126 public:
void SetNode(
NodePtr _node);
130 public: std::string GetPrevMsg()
const;
141 public: uint32_t Id()
const;
147 private:
void PublishImpl(
const google::protobuf::Message &_message,
152 private:
void OnPublishComplete(uint32_t _id);
155 private: std::string topic;
158 private: std::string msgType;
162 private:
unsigned int queueLimit;
166 private:
double updatePeriod;
170 private:
bool queueLimitWarned;
173 private: std::list<MessagePtr> messages;
176 private:
mutable boost::mutex mutex;
189 private: uint32_t pubId;
192 private: std::map<uint32_t, int> pubIds;
195 private: uint32_t id;
198 private:
static uint32_t idCounter;
void Fini()
Finalize the publisher.
uint32_t Id() const
Get the id of this publisher.
Forward declarations for the common classes.
Definition: Animation.hh:26
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition: TransportTypes.hh:45
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
Forward declarations for transport.
void Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition: Publisher.hh:101
boost::shared_ptr< Publication > PublicationPtr
Definition: TransportTypes.hh:61
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
void SetNode(NodePtr _node)
Set our containing node.
void SetPublication(PublicationPtr _publication)
Set the publication object for a particular publication.
bool HasConnections() const
Are there any connections?
std::string GetTopic() const
Get the topic name.
std::string GetMsgType() const
Get the message type.
Publisher(const std::string &_topic, const std::string &_msgType, unsigned int _limit, double _hzRate)
Constructor.
A publisher of messages on a topic.
Definition: Publisher.hh:44
virtual ~Publisher()
Destructor.
std::string GetPrevMsg() const
Get the previously published message.
MessagePtr GetPrevMsgPtr() const
Get the previously published message.
transport
Definition: ConnectionManager.hh:35
void Publish(const google::protobuf::Message &_message, bool _block=false)
Publish a protobuf message on the topic.
Definition: Publisher.hh:89
void SendMessage()
Send message(s) in the local buffer over the wire.
unsigned int GetRemoteSubscriptionCount()
Get the amount of remote subscribers.
void WaitForConnection() const
Block until a connection has been established with this publisher.
unsigned int GetOutgoingCount() const
Get the number of outgoing messages.