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>
51 public:
Publisher(
const std::string &_topic,
const std::string &_msgType,
52 unsigned int _limit,
double _hzRate);
59 public:
bool HasConnections()
const;
63 public:
void WaitForConnection()
const;
70 public:
bool WaitForConnection(
const common::Time &_timeout)
const;
80 public:
void Publish(
const google::protobuf::Message &_message,
82 { this->PublishImpl(_message, _block); }
88 public:
template<
typename M>
89 void Publish(M _message,
bool _block =
false)
90 { this->PublishImpl(_message, _block); }
94 public:
unsigned int GetOutgoingCount()
const;
98 public: std::string GetTopic()
const;
102 public: std::string GetMsgType()
const;
105 public:
void SendMessage();
110 public:
void SetNode(
NodePtr _node);
114 public: std::string GetPrevMsg()
const;
125 public: uint32_t Id()
const;
131 private:
void PublishImpl(
const google::protobuf::Message &_message,
136 private:
void OnPublishComplete(uint32_t _id);
139 private: std::string topic;
142 private: std::string msgType;
146 private:
unsigned int queueLimit;
150 private:
double updatePeriod;
154 private:
bool queueLimitWarned;
157 private: std::list<MessagePtr> messages;
160 private:
mutable boost::mutex mutex;
173 private: uint32_t pubId;
176 private: std::map<uint32_t, int> pubIds;
179 private: uint32_t id;
182 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:44
Forward declarations for transport.
void Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition: Publisher.hh:89
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:43
virtual ~Publisher()
Destructor.
std::string GetPrevMsg() const
Get the previously published message.
MessagePtr GetPrevMsgPtr() const
Get the previously published message.
void Publish(const google::protobuf::Message &_message, bool _block=false)
Publish a protobuf message on the topic.
Definition: Publisher.hh:80
void SendMessage()
Send latest message over the wire. For internal use only.
void WaitForConnection() const
Block until a connection has been established with this publisher.
unsigned int GetOutgoingCount() const
Get the number of outgoing messages.