PublicationTransport.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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/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  public boost::enable_shared_from_this<PublicationTransport>
42  {
46  public: PublicationTransport(const std::string &_topic,
47  const std::string &_msgType);
48 
50  public: virtual ~PublicationTransport();
51 
56  public: void Init(const ConnectionPtr &_conn, bool _latched);
57 
59  public: void Fini();
60 
63  public: void AddCallback(
64  const boost::function<void(const std::string &)> &_cb);
65 
68  public: const ConnectionPtr GetConnection() const;
69 
72  public: std::string GetTopic() const;
73 
76  public: std::string GetMsgType() const;
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: static int counter;
96 
98  private: int id;
99  };
101  }
102 }
103 #endif
Forward declarations for the common classes.
Definition: Animation.hh:26
transport
Definition: ConnectionManager.hh:35
transport/transport.hh
Definition: PublicationTransport.hh:40
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:51
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.