Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:19

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   time_traits.hpp
0009  * \author Andrey Semashev
0010  * \date   01.12.2007
0011  *
0012  * The header contains implementation of time traits that are used in various parts of the
0013  * library to acquire current time.
0014  */
0015 
0016 #ifndef BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
0017 #define BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
0018 
0019 #include <boost/date_time/posix_time/posix_time_types.hpp>
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/log/detail/header.hpp>
0022 
0023 #ifdef BOOST_HAS_PRAGMA_ONCE
0024 #pragma once
0025 #endif
0026 
0027 namespace boost {
0028 
0029 BOOST_LOG_OPEN_NAMESPACE
0030 
0031 namespace attributes {
0032 
0033 //! Base class for time traits involving Boost.DateTime.
0034 struct basic_time_traits
0035 {
0036     //! Time type
0037     typedef posix_time::ptime time_type;
0038 
0039     //! Current time source
0040 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
0041     typedef posix_time::microsec_clock clock_source;
0042 #else
0043     typedef posix_time::second_clock clock_source;
0044 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
0045 };
0046 
0047 //! Time traits that describes UTC time acquirement via Boost.DateTime facilities
0048 struct utc_time_traits :
0049     public basic_time_traits
0050 {
0051     /*!
0052      * \return Current time stamp
0053      */
0054     static time_type get_clock()
0055     {
0056         return clock_source::universal_time();
0057     }
0058 };
0059 
0060 //! Time traits that describes local time acquirement via Boost.DateTime facilities
0061 struct local_time_traits :
0062     public basic_time_traits
0063 {
0064     /*!
0065      * \return Current time stamp
0066      */
0067     static time_type get_clock()
0068     {
0069         return clock_source::local_time();
0070     }
0071 };
0072 
0073 } // namespace attributes
0074 
0075 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0076 
0077 } // namespace boost
0078 
0079 #include <boost/log/detail/footer.hpp>
0080 
0081 #endif // BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_