Realistic 3D camera system
3D camera system components
time_traits.hpp
Go to the documentation of this file.
1 //
2 // time_traits.hpp
3 // ~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_TIME_TRAITS_HPP
12 #define ASIO_TIME_TRAITS_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/socket_types.hpp" // Must come before posix_time.
19 
20 #if defined(ASIO_HAS_BOOST_DATE_TIME) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <boost/date_time/posix_time/posix_time_types.hpp>
24 
26 
27 namespace asio {
28 
30 template <typename Time>
31 struct time_traits;
32 
34 template <>
35 struct time_traits<boost::posix_time::ptime>
36 {
38  typedef boost::posix_time::ptime time_type;
39 
41  typedef boost::posix_time::time_duration duration_type;
42 
44  static time_type now()
45  {
46 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
47  return boost::posix_time::microsec_clock::universal_time();
48 #else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
49  return boost::posix_time::second_clock::universal_time();
50 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
51  }
52 
54  static time_type add(const time_type& t, const duration_type& d)
55  {
56  return t + d;
57  }
58 
60  static duration_type subtract(const time_type& t1, const time_type& t2)
61  {
62  return t1 - t2;
63  }
64 
66  static bool less_than(const time_type& t1, const time_type& t2)
67  {
68  return t1 < t2;
69  }
70 
72  static boost::posix_time::time_duration to_posix_duration(
73  const duration_type& d)
74  {
75  return d;
76  }
77 };
78 
79 } // namespace asio
80 
82 
83 #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
84  // || defined(GENERATING_DOCUMENTATION)
85 
86 #endif // ASIO_TIME_TRAITS_HPP