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 Open Source Robotics Foundation
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 
53  public: void Init(const ConnectionPtr &_conn, bool _latched);
54 
56  public: void Fini();
57 
60  public: void AddCallback(
61  const boost::function<void(const std::string &)> &_cb);
62 
65  public: const ConnectionPtr GetConnection() const;
66 
69  public: std::string GetTopic() const;
70 
73  public: std::string GetMsgType() const;
74 
76  private: void OnConnectionShutdown();
77 
80  private: void OnPublish(const std::string &_data);
81 
83  private: std::string topic;
84 
86  private: std::string msgType;
87 
89  private: ConnectionPtr connection;
90 
92  private: boost::function<void (const std::string &)> callback;
93 
95  private: event::ConnectionPtr shutdownConnectionPtr;
96 
98  private: static int counter;
99 
101  private: int id;
102  };
104  }
105 }
106 #endif