Go to the documentation of this file.
18 #ifndef _PUBLICATION_HH_
19 #define _PUBLICATION_HH_
22 #include <boost/function.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/thread/mutex.hpp>
46 public boost::enable_shared_from_this<Publication>
52 const std::string &_msgType);
59 public: std::string GetMsgType()
const;
67 public:
void AddSubscription(
const NodePtr &_node);
71 public:
void RemoveSubscription(
const NodePtr &_node);
76 public:
void RemoveSubscription(
const std::string &_host,
82 public:
void RemoveTransport(
const std::string &_host,
unsigned
87 public:
unsigned int GetTransportCount()
const;
91 public:
unsigned int GetCallbackCount()
const;
95 public:
unsigned int PublisherCount()
const;
99 public:
unsigned int GetNodeCount()
const;
103 public:
unsigned int GetRemoteSubscriptionCount();
108 public:
bool GetLocallyAdvertised()
const;
113 public:
void SetLocallyAdvertised(
bool _value);
117 public:
void LocalPublish(
const std::string &_data);
126 boost::function<
void(uint32_t)> _cb,
136 public:
bool RemovePublisher(
const uint32_t
id);
141 public:
void SetPrevMsg(uint32_t _pubId,
MessagePtr _msg);
147 public:
MessagePtr GetPrevMsg(uint32_t _pubId);
150 public:
void ClearPrevMsgs();
161 public:
bool HasTransport(
const std::string &_host,
unsigned int _port);
168 private:
void RemoveNodes();
171 private:
unsigned int id;
174 private:
static unsigned int idCounter;
177 private: std::string topic;
180 private: std::string msgType;
183 private: std::list<CallbackHelperPtr> callbacks;
186 private: std::list<NodePtr> nodes;
189 private: std::list<unsigned int> removeNodes;
192 private: std::list<std::pair<std::string, unsigned int> > removeCallbacks;
195 private: std::list<PublicationTransportPtr> transports;
198 private: std::vector<PublisherPtr> publishers;
201 private:
bool locallyAdvertised;
204 private:
mutable boost::mutex nodeMutex;
207 private:
mutable boost::mutex callbackMutex;
210 private:
mutable boost::mutex nodeRemoveMutex;
213 private: std::map<uint32_t, MessagePtr> prevMsgs;
void RemovePublisher(PublisherPtr _pub)
Remove a publisher.
Publication(const std::string &_topic, const std::string &_msgType)
Constructor.
Forward declarations for the common classes.
Definition: Animation.hh:26
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition: TransportTypes.hh:45
MessagePtr GetPrevMsg(uint32_t _pubId)
Get a previous message for a publisher.
unsigned int GetNodeCount() const
Get the number of nodes.
unsigned int GetCallbackCount() const
Get the number of callbacks.
void SetLocallyAdvertised(bool _value)
Set whether this topic has been advertised from this process.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Forward declarations for transport.
virtual ~Publication()
Destructor.
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
void ClearPrevMsgs()
Clear all previous messages for a publisher.
void AddTransport(const PublicationTransportPtr &_publink)
Add a transport.
void SetPrevMsg(uint32_t _pubId, MessagePtr _msg)
Set the previous message for a publisher.
bool GetLocallyAdvertised() const
Was the topic has been advertised from this process?
boost::shared_ptr< PublicationTransport > PublicationTransportPtr
Definition: TransportTypes.hh:65
void RemoveSubscription(const NodePtr &_node)
Unsubscribe a node from our topic.
unsigned int GetTransportCount() const
Get the number of transports.
int Publish(MessagePtr _msg, boost::function< void(uint32_t)> _cb, uint32_t _id)
Publish data to remote subscribers.
std::string GetMsgType() const
Get the type of message.
void AddPublisher(PublisherPtr _pub)
Add a publisher.
transport
Definition: ConnectionManager.hh:35
void AddSubscription(const CallbackHelperPtr _callback)
Subscribe a callback to our topic.
void LocalPublish(const std::string &_data)
Publish data to local subscribers (skip serialization)
void RemoveTransport(const std::string &_host, unsigned int _port)
Remove a transport.
boost::shared_ptr< CallbackHelper > CallbackHelperPtr
boost shared pointer to transport::CallbackHelper
Definition: CallbackHelper.hh:105
unsigned int PublisherCount() const
Get the number of publishers.
unsigned int GetRemoteSubscriptionCount()
Get the number of remote subscriptions.
A publication for a topic. This facilitates transport of messages.
Definition: Publication.hh:45
bool HasTransport(const std::string &_host, unsigned int _port)
Does a given transport exist?