Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

time_traits.hpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef ASIO_TIME_TRAITS_HPP
  11. #define ASIO_TIME_TRAITS_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/socket_types.hpp" // Must come before posix_time.
  16. #if defined(ASIO_HAS_BOOST_DATE_TIME) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <boost/date_time/posix_time/posix_time_types.hpp>
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. /// Time traits suitable for use with the deadline timer.
  22. template <typename Time>
  23. struct time_traits;
  24. /// Time traits specialised for posix_time.
  25. template <>
  26. struct time_traits<boost::posix_time::ptime>
  27. {
  28. /// The time type.
  29. typedef boost::posix_time::ptime time_type;
  30. /// The duration type.
  31. typedef boost::posix_time::time_duration duration_type;
  32. /// Get the current time.
  33. static time_type now()
  34. {
  35. #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
  36. return boost::posix_time::microsec_clock::universal_time();
  37. #else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
  38. return boost::posix_time::second_clock::universal_time();
  39. #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
  40. }
  41. /// Add a duration to a time.
  42. static time_type add(const time_type& t, const duration_type& d)
  43. {
  44. return t + d;
  45. }
  46. /// Subtract one time from another.
  47. static duration_type subtract(const time_type& t1, const time_type& t2)
  48. {
  49. return t1 - t2;
  50. }
  51. /// Test whether one time is less than another.
  52. static bool less_than(const time_type& t1, const time_type& t2)
  53. {
  54. return t1 < t2;
  55. }
  56. /// Convert to POSIX duration type.
  57. static boost::posix_time::time_duration to_posix_duration(
  58. const duration_type& d)
  59. {
  60. return d;
  61. }
  62. };
  63. } // namespace asio
  64. #include "asio/detail/pop_options.hpp"
  65. #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
  66. // || defined(GENERATING_DOCUMENTATION)
  67. #endif // ASIO_TIME_TRAITS_HPP