PublicationTransport.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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/function.hpp>
22 #include <boost/shared_ptr.hpp>
23 #include <string>
24 
26 #include "gazebo/common/Event.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace transport
32  {
35 
40  class GZ_TRANSPORT_VISIBLE PublicationTransport
41  {
45  public: PublicationTransport(const std::string &_topic,
46  const std::string &_msgType);
47 
49  public: virtual ~PublicationTransport();
50 
55  public: void Init(const ConnectionPtr &_conn, bool _latched);
56 
58  public: void Fini();
59 
62  public: void AddCallback(
63  const boost::function<void(const std::string &)> &_cb);
64 
67  public: const ConnectionPtr GetConnection() const;
68 
71  public: std::string GetTopic() const;
72 
75  public: std::string GetMsgType() const;
76 
79  private: void OnPublish(const std::string &_data);
80 
82  private: std::string topic;
83 
85  private: std::string msgType;
86 
88  private: ConnectionPtr connection;
89 
91  private: boost::function<void (const std::string &)> callback;
92 
94  private: static int counter;
95 
97  private: int id;
98  };
100  }
101 }
102 #endif
transport/transport.hh
Definition: PublicationTransport.hh:40
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:50
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.