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;
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 Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition: Publisher.hh:89
Forward declarations for the common classes.
Definition: Animation.hh:33
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:80
boost::shared_ptr< Publication > PublicationPtr
Definition: TransportTypes.hh:61
A publisher of messages on a topic.
Definition: Publisher.hh:43
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44