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 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 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 
37  {
38  public: PublicationTransport(const std::string &topic,
39  const std::string &msgType);
40 
41  public: virtual ~PublicationTransport();
42 
43  public: void Init(const ConnectionPtr &conn);
44  public: void Fini();
45  public: void AddCallback(
46  const boost::function<void(const std::string &)> &cb);
47 
48  public: const ConnectionPtr GetConnection() const;
49  public: std::string GetTopic() const;
50  public: std::string GetMsgType() const;
51 
52  private: void OnConnectionShutdown();
53 
54  private: void OnPublish(const std::string &data);
55 
56  private: std::string topic;
57  private: std::string msgType;
58  private: ConnectionPtr connection;
59  private: boost::function<void (const std::string &)> callback;
60  private: event::ConnectionPtr shutdownConnectionPtr;
61 
62  private: static int counter;
63  private: int id;
64  };
66  }
67 }
68 
69 #endif
70 
71