21 #ifndef _PUBLISHER_HH_
22 #define _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;
127 private:
void PublishImpl(
const google::protobuf::Message &_message,
132 private:
void OnPublishComplete(uint32_t _id);
135 private: std::string topic;
138 private: std::string msgType;
142 private:
unsigned int queueLimit;
146 private:
double updatePeriod;
150 private:
bool queueLimitWarned;
153 private: std::list<MessagePtr> messages;
156 private:
mutable boost::mutex mutex;
169 private: uint32_t pubId;
172 private: std::map<uint32_t, int> pubIds;
175 private: uint32_t id;
178 private:
static uint32_t idCounter;
void Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition: Publisher.hh:89
Forward declarations for transport.
A publisher of messages on a topic.
Definition: Publisher.hh:43
boost::shared_ptr< Publication > PublicationPtr
Definition: TransportTypes.hh:56
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition: TransportTypes.hh:40
void Publish(const google::protobuf::Message &_message, bool _block=false)
Publish a protobuf message on the topic.
Definition: Publisher.hh:80
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:52
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43