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 Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition: Publisher.hh:101
Forward declarations for the common classes.
Definition: Animation.hh:26
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition: TransportTypes.hh:45
Forward declarations for transport.
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
void Publish(const google::protobuf::Message &_message, bool _block=false)
Publish a protobuf message on the topic.
Definition: Publisher.hh:89
boost::shared_ptr< Publication > PublicationPtr
Definition: TransportTypes.hh:61
A publisher of messages on a topic.
Definition: Publisher.hh:44
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44