All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SubscribeOptions.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 #ifndef SUBSCRIBEOPTIONS_HH
18 #define SUBSCRIBEOPTIONS_HH
19 
20 #include <boost/function.hpp>
21 #include <boost/shared_ptr.hpp>
22 #include <string>
24 
25 namespace gazebo
26 {
27  namespace transport
28  {
31 
34  {
35  public: SubscribeOptions()
36  : latching(false)
37  {}
38 
39  public: template<class M>
40  void Init(const std::string &_topic,
41  NodePtr _node,
42  bool _latching)
43  {
44  google::protobuf::Message *msg = NULL;
45  M msgtype;
46  msg = dynamic_cast<google::protobuf::Message *>(&msgtype);
47  if (!msg)
48  gzthrow("Subscribe requires a google protobuf type");
49 
50  this->node = _node;
51  this->topic = _topic;
52  this->msgType = msg->GetTypeName();
53  this->latching = _latching;
54  }
55 
56  public: NodePtr GetNode() const
57  {
58  return this->node;
59  }
60 
61  public: std::string GetTopic() const
62  {
63  return this->topic;
64  }
65 
66  public: std::string GetMsgType() const
67  {
68  return this->msgType;
69  }
70 
71  public: bool GetLatching() const
72  {
73  return this->latching;
74  }
75 
76  private: std::string topic;
77  private: std::string msgType;
78  private: NodePtr node;
79  private: bool latching;
80  };
82  }
83 }
84 
85 #endif
86 
87