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);
89 public:
void Publish(
const google::protobuf::Message &_message,
91 { this->PublishImpl(_message, _block); }
100 public:
template<
typename M>
102 { this->PublishImpl(_message, _block); }
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;
transport
Definition ConnectionManager.hh:35
Forward declarations for transport.
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
A publisher of messages on a topic.
Definition Publisher.hh:46
void Fini()
Finalize the publisher.
std::string GetPrevMsg() const
Get the previously published message.
void Publish(M _message, bool _block=false)
Publish an arbitrary message on the topic.
Definition Publisher.hh:101
unsigned int GetRemoteSubscriptionCount()
Get the amount of remote subscribers.
void SendMessage()
Send message(s) in the local buffer over the wire.
void SetPublication(PublicationPtr _publication)
Set the publication object for a particular publication.
std::string GetMsgType() const
Get the message type.
virtual ~Publisher()
Destructor.
MessagePtr GetPrevMsgPtr() const
Get the previously published message.
unsigned int GetOutgoingCount() const
Get the number of outgoing messages.
void WaitForConnection() const
Block until a connection has been established with this publisher.
Publisher(const std::string &_topic, const std::string &_msgType, unsigned int _limit, double _hzRate)
Constructor.
void SetNode(NodePtr _node)
Set our containing node.
bool WaitForConnection(const common::Time &_timeout) const
Block until a connection has been established with this publisher.
uint32_t Id() const
Get the id of this publisher.
bool HasConnections() const
Are there any connections?
std::string GetTopic() const
Get the topic name.
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
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition TransportTypes.hh:45
boost::shared_ptr< Node > NodePtr
Definition TransportTypes.hh:57
Forward declarations for the common classes.
Definition Animation.hh:27