All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Publication.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _PUBLICATION_HH_
19 #define _PUBLICATION_HH_
20 
21 #include <boost/shared_ptr.hpp>
22 #include <list>
23 #include <string>
24 #include <vector>
25 
29 
30 namespace gazebo
31 {
32  namespace transport
33  {
36 
41  {
45  public: Publication(const std::string &_topic,
46  const std::string &_msgType);
47 
49  public: virtual ~Publication();
50 
53  public: std::string GetMsgType() const;
54 
57  public: void AddSubscription(const CallbackHelperPtr &_callback);
58 
61  public: void AddSubscription(const NodePtr &_node);
62 
65  public: void RemoveSubscription(const NodePtr &_node);
66 
70  public: void RemoveSubscription(const std::string &_host,
71  unsigned int _port);
72 
76  public: void RemoveTransport(const std::string &_host, unsigned
77  int _port);
78 
81  public: unsigned int GetTransportCount() const;
82 
85  public: unsigned int GetCallbackCount() const;
86 
89  public: unsigned int GetNodeCount() const;
90 
93  public: unsigned int GetRemoteSubscriptionCount();
94 
98  public: bool GetLocallyAdvertised() const;
99 
103  public: void SetLocallyAdvertised(bool _value);
104 
107  public: void LocalPublish(const std::string &_data);
108 
113  public: void Publish(const google::protobuf::Message &_msg,
114  const boost::function<void()> &_cb = NULL);
115 
119  public: void AddTransport(const PublicationTransportPtr &_publink);
120 
125  public: bool HasTransport(const std::string &_host, unsigned int _port);
126 
129  public: void AddPublisher(PublisherPtr _pub);
130 
131  private: unsigned int id;
132  private: static unsigned int idCounter;
133  private: std::string topic;
134  private: std::string msgType;
135 
137  private: std::list<CallbackHelperPtr> callbacks;
138 
140  private: std::list<NodePtr> nodes;
141 
142  private: std::list<PublicationTransportPtr> transports;
143 
144  private: std::vector<PublisherPtr> publishers;
145 
146  private: bool locallyAdvertised;
147  };
149  }
150 }
151 #endif
152 
153