naoqidriver
basic.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_REGISTER_HPP
19 #define EVENT_REGISTER_HPP
20 
21 #include <string>
22 
23 #include <boost/make_shared.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/thread/mutex.hpp>
26 
27 #include <qi/session.hpp>
28 
29 #include <ros/ros.h>
30 
31 #include <naoqi_driver/tools.hpp>
33 
34 namespace naoqi
35 {
36 
44 template <typename Converter, typename Publisher, typename Recorder>
46 {
47 
48 public:
49 
53  EventRegister();
54  EventRegister( const std::string& key, const qi::SessionPtr& session );
56 
57  void resetPublisher( ros::NodeHandle& nh );
58  void resetRecorder( boost::shared_ptr<naoqi::recorder::GlobalRecorder> gr );
59 
60  void startProcess();
61  void stopProcess();
62 
63  void writeDump(const ros::Time& time);
64  void setBufferDuration(float duration);
65 
66  void isRecording(bool state);
67  void isPublishing(bool state);
68  void isDumping(bool state);
69 
70 private:
71  void registerCallback();
72  void unregisterCallback();
73  void onEvent();
74 
75 private:
76  boost::shared_ptr<Converter> converter_;
77  boost::shared_ptr<Publisher> publisher_;
78  boost::shared_ptr<Recorder> recorder_;
79 
80  qi::AnyObject p_memory_;
81  qi::AnyObject signal_;
82  qi::SignalLink signalID_;
83  std::string key_;
84 
85  boost::mutex mutex_;
86 
87  bool isStarted_;
90  bool isDumping_;
91 
92 }; // class globalrecorder
93 } //naoqi
94 #include "basic.hxx"
95 
96 #endif
bool isPublishing_
Definition: basic.hpp:88
std::string key_
Definition: basic.hpp:83
void writeDump(const ros::Time &time)
Definition: basic.hxx:98
qi::AnyObject signal_
Definition: basic.hpp:81
boost::shared_ptr< Publisher > publisher_
Definition: basic.hpp:77
qi::AnyObject p_memory_
Definition: basic.hpp:80
boost::mutex mutex_
Definition: basic.hpp:85
bool isRecording_
Definition: basic.hpp:89
bool isDumping_
Definition: basic.hpp:90
void isRecording(bool state)
Definition: basic.hxx:113
void startProcess()
Definition: basic.hxx:76
Definition: audio.cpp:29
void resetPublisher(ros::NodeHandle &nh)
Definition: basic.hxx:64
bool isStarted_
Definition: basic.hpp:87
void setBufferDuration(float duration)
Definition: basic.hxx:107
boost::shared_ptr< Converter > converter_
Definition: basic.hpp:76
void onEvent()
Definition: basic.hxx:147
void stopProcess()
Definition: basic.hxx:87
~EventRegister()
Definition: basic.hxx:59
void unregisterCallback()
Definition: basic.hxx:141
EventRegister()
Constructor for recorder interface.
Definition: basic.hxx:34
boost::shared_ptr< Recorder > recorder_
Definition: basic.hpp:78
void isPublishing(bool state)
Definition: basic.hxx:120
void resetRecorder(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr)
Definition: basic.hxx:70
qi::SignalLink signalID_
Definition: basic.hpp:82
GlobalRecorder concept interface.
Definition: basic.hpp:45
void registerCallback()
Definition: basic.hxx:134
void isDumping(bool state)
Definition: basic.hxx:127