naoqidriver
subscriber_base.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran
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 BASE_SUBSCRIBER_HPP
19 #define BASE_SUBSCRIBER_HPP
20 
21 /*
22  * ALDEBARAN includes
23  */
24 #include <qi/session.hpp>
25 
26 /*
27  * LOCAL includes
28  */
29 #include <naoqi_driver/tools.hpp>
30 #include "../helpers/driver_helpers.hpp"
31 
32 namespace naoqi
33 {
34 namespace subscriber
35 {
36 
37 // CRTP
38 template<class T>
40 {
41 
42 public:
43  BaseSubscriber( const std::string& name, const std::string& topic, qi::SessionPtr session ):
44  name_( name ),
45  topic_( topic ),
46  is_initialized_( false ),
47  robot_( helpers::driver::getRobot(session) ),
48  session_(session)
49  {}
50 
51  virtual ~BaseSubscriber() {}
52 
53  inline std::string name() const
54  {
55  return name_;
56  }
57 
58  inline std::string topic() const
59  {
60  return topic_;
61  }
62 
63  inline bool isInitialized() const
64  {
65  return is_initialized_;
66  }
67 
68 protected:
69  std::string name_, topic_;
70 
72 
75 
77  qi::SessionPtr session_;
78 }; // class
79 
80 } // subscriber
81 } // naoqi
82 
83 #endif
bool is_initialized_
Definition: subscriber_base.hpp:71
qi::SessionPtr session_
Definition: subscriber_base.hpp:77
virtual ~BaseSubscriber()
Definition: subscriber_base.hpp:51
Definition: audio.cpp:29
Robot
Definition: tools.hpp:37
std::string name() const
Definition: subscriber_base.hpp:53
bool isInitialized() const
Definition: subscriber_base.hpp:63
const robot::Robot & robot_
Definition: subscriber_base.hpp:74
BaseSubscriber(const std::string &name, const std::string &topic, qi::SessionPtr session)
Definition: subscriber_base.hpp:43
std::string topic() const
Definition: subscriber_base.hpp:58
Definition: subscriber_base.hpp:39
const robot::Robot & getRobot(const qi::SessionPtr &session)
Definition: driver_helpers.cpp:54
std::string topic_
Definition: subscriber_base.hpp:69
std::string name_
Definition: subscriber_base.hpp:69