All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PublicationTransport.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 _PUBLICATIONTRANSPORT_HH_
19 #define _PUBLICATIONTRANSPORT_HH_
20 
21 #include <boost/shared_ptr.hpp>
22 #include <string>
23 
24 #include "transport/Connection.hh"
25 #include "common/Event.hh"
26 
27 namespace gazebo
28 {
29  namespace transport
30  {
33 
39  {
43  public: PublicationTransport(const std::string &_topic,
44  const std::string &_msgType);
45 
47  public: virtual ~PublicationTransport();
48 
51  public: void Init(const ConnectionPtr &_conn);
52 
54  public: void Fini();
55 
58  public: void AddCallback(
59  const boost::function<void(const std::string &)> &_cb);
60 
63  public: const ConnectionPtr GetConnection() const;
64 
67  public: std::string GetTopic() const;
68 
71  public: std::string GetMsgType() const;
72 
74  private: void OnConnectionShutdown();
75 
78  private: void OnPublish(const std::string &_data);
79 
81  private: std::string topic;
82 
84  private: std::string msgType;
85 
87  private: ConnectionPtr connection;
88 
90  private: boost::function<void (const std::string &)> callback;
91 
93  private: event::ConnectionPtr shutdownConnectionPtr;
94 
96  private: static int counter;
97 
99  private: int id;
100  };
102  }
103 }
104 #endif