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