event.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 EVENT_HPP
19 #define EVENT_HPP
20 
21 #include <string>
22 
23 #include <boost/make_shared.hpp>
24 #include <boost/shared_ptr.hpp>
25 
26 #include <ros/ros.h>
29 #include <naoqi_driver/tools.hpp>
30 
31 namespace naoqi
32 {
33 namespace event
34 {
35 
36 
44 class Event
45 {
46 
47 public:
48 
52  template<typename T>
53  Event( T event ):
54  eventPtr_( boost::make_shared<EventModel<T> >(event) )
55  {}
56 
58  {
59  eventPtr_->resetPublisher(nh);
60  }
61 
63  {
64  eventPtr_->resetRecorder(gr);
65  }
66 
67  void startProcess( )
68  {
69  eventPtr_->startProcess();
70  }
71 
72  void stopProcess( )
73  {
74  eventPtr_->stopProcess();
75  }
76 
77  void writeDump( const ros::Time& time )
78  {
79  eventPtr_->writeDump(time);
80  }
81 
82  void setBufferDuration(float duration)
83  {
84  eventPtr_->setBufferDuration(duration);
85  }
86 
87  void isRecording(bool state)
88  {
89  eventPtr_->isRecording(state);
90  }
91 
92  void isPublishing(bool state)
93  {
94  eventPtr_->isPublishing(state);
95  }
96 
97  void isDumping(bool state)
98  {
99  eventPtr_->isDumping(state);
100  }
101 
102 private:
103 
108  {
109  virtual ~EventConcept(){}
110  virtual void resetPublisher(ros::NodeHandle& nh) = 0;
112  virtual void startProcess() = 0;
113  virtual void stopProcess() = 0;
114  virtual void writeDump(const ros::Time& time) = 0;
115  virtual void setBufferDuration(float duration) = 0;
116  virtual void isRecording(bool state) = 0;
117  virtual void isPublishing(bool state) = 0;
118  virtual void isDumping(bool state) = 0;
119  };
120 
121 
125  template<typename T>
126  struct EventModel : public EventConcept
127  {
128  EventModel( const T& other ):
129  converter_( other )
130  {}
131 
133  {
134  converter_->resetPublisher(nh);
135  }
136 
138  {
139  converter_->resetRecorder(gr);
140  }
141 
142  void startProcess( )
143  {
144  converter_->startProcess();
145  }
146 
147  void stopProcess( )
148  {
149  converter_->stopProcess();
150  }
151 
152  void writeDump( const ros::Time& time )
153  {
154  converter_->writeDump(time);
155  }
156 
157  void setBufferDuration(float duration)
158  {
159  converter_->setBufferDuration(duration);
160  }
161 
162  void isRecording(bool state)
163  {
164  converter_->isRecording(state);
165  }
166 
167  void isPublishing(bool state)
168  {
169  converter_->isPublishing(state);
170  }
171 
172  void isDumping(bool state)
173  {
174  converter_->isDumping(state);
175  }
176 
178  };
179 
181 
182 }; // class converter
183 
184 } //converter
185 } //naoqi
186 
187 #endif
virtual void setBufferDuration(float duration)=0
void startProcess()
Definition: event.hpp:67
void writeDump(const ros::Time &time)
Definition: event.hpp:77
virtual void isDumping(bool state)=0
virtual void resetRecorder(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr)=0
void stopProcess()
Definition: event.hpp:72
virtual void writeDump(const ros::Time &time)=0
EventModel(const T &other)
Definition: event.hpp:128
void resetPublisher(ros::NodeHandle &nh)
Definition: event.hpp:132
void isRecording(bool state)
Definition: event.hpp:162
void resetRecorder(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr)
Definition: event.hpp:137
Event(T event)
Constructor for converter interface.
Definition: event.hpp:53
void setBufferDuration(float duration)
Definition: event.hpp:82
Converter concept interface.
Definition: event.hpp:44
boost::shared_ptr< EventConcept > eventPtr_
Definition: event.hpp:180
void writeDump(const ros::Time &time)
Definition: event.hpp:152
virtual void resetPublisher(ros::NodeHandle &nh)=0
virtual void isRecording(bool state)=0
virtual void isPublishing(bool state)=0
void setBufferDuration(float duration)
Definition: event.hpp:157
void isPublishing(bool state)
Definition: event.hpp:167
void isDumping(bool state)
Definition: event.hpp:97
void isPublishing(bool state)
Definition: event.hpp:92
void resetRecorder(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr)
Definition: event.hpp:62
void isRecording(bool state)
Definition: event.hpp:87
void resetPublisher(ros::NodeHandle &nh)
Definition: event.hpp:57
void isDumping(bool state)
Definition: event.hpp:172


naoqi_driver
Author(s): Karsten Knese
autogenerated on Sat Feb 15 2020 03:24:26