snark
clocked_time_stamp.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_CLOCKED_TIMESTAMP
20 #define SNARK_CLOCKED_TIMESTAMP
21 
22 #ifndef WIN32
23 #include <stdlib.h>
24 #endif
25 #include <boost/noncopyable.hpp>
26 #include <snark/timing/time.h>
27 
28 namespace snark{ namespace timing {
29 
42 class clocked_time_stamp : public boost::noncopyable
43 {
44  public:
46  clocked_time_stamp( boost::posix_time::time_duration period );
47 
50 
53  boost::posix_time::ptime adjusted( const boost::posix_time::ptime& t, std::size_t ticks = 1 );
54 
62  boost::posix_time::ptime adjusted( const boost::posix_time::ptime& t, boost::posix_time::time_duration period, std::size_t ticks = 1 );
63 
65  boost::posix_time::time_duration period() const;
66 
68  void reset();
69 
70  private:
71  class impl;
72  impl* m_pimpl;
73 };
74 
75 } } // namespace snark{ namespace timing
76 
77 #endif /*SNARK_CLOCKED_TIMESTAMP*/