Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file time_traits.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 01.12.2007 Chris@16: * Chris@16: * The header contains implementation of time traits that are used in various parts of the Chris@16: * library to acquire current time. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace attributes { Chris@16: Chris@16: //! Base class for time traits involving Boost.DateTime. Chris@16: struct basic_time_traits Chris@16: { Chris@16: //! Time type Chris@16: typedef posix_time::ptime time_type; Chris@16: Chris@16: //! Current time source Chris@16: #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) Chris@16: typedef posix_time::microsec_clock clock_source; Chris@16: #else Chris@16: typedef posix_time::second_clock clock_source; Chris@16: #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) Chris@16: }; Chris@16: Chris@16: //! Time traits that describes UTC time acquirement via Boost.DateTime facilities Chris@16: struct utc_time_traits : Chris@16: public basic_time_traits Chris@16: { Chris@16: /*! Chris@16: * \return Current time stamp Chris@16: */ Chris@16: static time_type get_clock() Chris@16: { Chris@16: return clock_source::universal_time(); Chris@16: } Chris@16: }; Chris@16: Chris@16: //! Time traits that describes local time acquirement via Boost.DateTime facilities Chris@16: struct local_time_traits : Chris@16: public basic_time_traits Chris@16: { Chris@16: /*! Chris@16: * \return Current time stamp Chris@16: */ Chris@16: static time_type get_clock() Chris@16: { Chris@16: return clock_source::local_time(); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace attributes Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_