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 2011 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 
40  {
42  public: Publication(const std::string &topic,
43  const std::string &msgType);
44 
46  public: virtual ~Publication();
47 
49  public: std::string GetMsgType() const;
50 
51  public: void AddSubscription(const CallbackHelperPtr &callback);
52  public: void AddSubscription(const NodePtr &_node);
53 
55  public: void RemoveSubscription(const NodePtr &_node);
56 
58  public: void RemoveSubscription(const std::string &host,
59  unsigned int port);
60 
61  public: void RemoveTransport(const std::string &host, unsigned int port);
62 
63  public: unsigned int GetTransportCount() const;
64  public: unsigned int GetCallbackCount() const;
65  public: unsigned int GetNodeCount() const;
66  public: unsigned int GetRemoteSubscriptionCount();
67 
70  public: bool GetLocallyAdvertised() const;
71 
73  public: void SetLocallyAdvertised(bool _value);
74 
76  public: void LocalPublish(const std::string &data);
77 
78  public: void Publish(const google::protobuf::Message &msg,
79  const boost::function<void()> &cb = NULL);
80 
81  public: void AddTransport(const PublicationTransportPtr &publink);
82  public: bool HasTransport(const std::string &_host, unsigned int _port);
83 
84  public: void AddPublisher(PublisherPtr _pub);
85 
86  private: unsigned int id;
87  private: static unsigned int idCounter;
88  private: std::string topic;
89  private: std::string msgType;
90 
92  private: std::list<CallbackHelperPtr> callbacks;
93 
95  private: std::list<NodePtr> nodes;
96 
97  private: std::list<PublicationTransportPtr> transports;
98 
99  private: std::vector<PublisherPtr> publishers;
100 
101  private: bool locallyAdvertised;
102  };
104  }
105 }
106 #endif
107 
108