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;