snark
play.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_TIMING_PLAY_H
20 #define SNARK_TIMING_PLAY_H
21 
22 #include <boost/optional.hpp>
23 #include <boost/date_time/posix_time/posix_time.hpp>
24 
25 namespace snark
26 {
27 namespace timing
28 {
29 
31 class play
32 {
33 public:
34  play( double speed = 1.0, bool quiet = false, const boost::posix_time::time_duration& precision = boost::posix_time::milliseconds(1) );
35  play( const boost::posix_time::ptime& first, double speed = 1.0, bool quiet = false, const boost::posix_time::time_duration& precision = boost::posix_time::milliseconds(1) );
36 
37  void wait( const boost::posix_time::ptime& time );
38 
39  void wait( const std::string& iso_time );
40 
41 private:
42  boost::posix_time::ptime m_systemFirst;
43  boost::optional< boost::posix_time::time_duration > m_offset;
44  boost::posix_time::ptime m_first;
45  boost::posix_time::ptime m_last;
46  const double m_speed;
47  const boost::posix_time::time_duration m_precision;
48  bool m_lag;
49  unsigned int m_lagCounter;
50  bool m_quiet;
51 };
52 
53 }
54 }
55 
56 #endif // SNARK_TIMING_PLAY_H