Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file time_traits.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 01.12.2007
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of time traits that are used in various parts of the
|
Chris@16
|
13 * library to acquire current time.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/date_time/posix_time/posix_time_types.hpp>
|
Chris@16
|
20 #include <boost/log/detail/config.hpp>
|
Chris@16
|
21 #include <boost/log/detail/header.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
24 #pragma once
|
Chris@16
|
25 #endif
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost {
|
Chris@16
|
28
|
Chris@16
|
29 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
30
|
Chris@16
|
31 namespace attributes {
|
Chris@16
|
32
|
Chris@16
|
33 //! Base class for time traits involving Boost.DateTime.
|
Chris@16
|
34 struct basic_time_traits
|
Chris@16
|
35 {
|
Chris@16
|
36 //! Time type
|
Chris@16
|
37 typedef posix_time::ptime time_type;
|
Chris@16
|
38
|
Chris@16
|
39 //! Current time source
|
Chris@16
|
40 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
|
Chris@16
|
41 typedef posix_time::microsec_clock clock_source;
|
Chris@16
|
42 #else
|
Chris@16
|
43 typedef posix_time::second_clock clock_source;
|
Chris@16
|
44 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
|
Chris@16
|
45 };
|
Chris@16
|
46
|
Chris@16
|
47 //! Time traits that describes UTC time acquirement via Boost.DateTime facilities
|
Chris@16
|
48 struct utc_time_traits :
|
Chris@16
|
49 public basic_time_traits
|
Chris@16
|
50 {
|
Chris@16
|
51 /*!
|
Chris@16
|
52 * \return Current time stamp
|
Chris@16
|
53 */
|
Chris@16
|
54 static time_type get_clock()
|
Chris@16
|
55 {
|
Chris@16
|
56 return clock_source::universal_time();
|
Chris@16
|
57 }
|
Chris@16
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60 //! Time traits that describes local time acquirement via Boost.DateTime facilities
|
Chris@16
|
61 struct local_time_traits :
|
Chris@16
|
62 public basic_time_traits
|
Chris@16
|
63 {
|
Chris@16
|
64 /*!
|
Chris@16
|
65 * \return Current time stamp
|
Chris@16
|
66 */
|
Chris@16
|
67 static time_type get_clock()
|
Chris@16
|
68 {
|
Chris@16
|
69 return clock_source::local_time();
|
Chris@16
|
70 }
|
Chris@16
|
71 };
|
Chris@16
|
72
|
Chris@16
|
73 } // namespace attributes
|
Chris@16
|
74
|
Chris@16
|
75 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
76
|
Chris@16
|
77 } // namespace boost
|
Chris@16
|
78
|
Chris@16
|
79 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
80
|
Chris@16
|
81 #endif // BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
|