• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   enqueued_record.hpp
9  * \author Andrey Semashev
10  * \date   01.04.2014
11  *
12  * \brief  This header is the Boost.Log library implementation, see the library documentation
13  *         at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file
14  *         internal configuration macros are defined.
15  */
16 
17 #ifndef BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_
18 #define BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_
19 
20 #include <boost/move/core.hpp>
21 #include <boost/move/utility_core.hpp>
22 #include <boost/log/detail/config.hpp>
23 #include <boost/log/detail/timestamp.hpp>
24 #include <boost/log/core/record_view.hpp>
25 #include <boost/log/detail/header.hpp>
26 
27 #ifdef BOOST_HAS_PRAGMA_ONCE
28 #pragma once
29 #endif
30 
31 namespace boost {
32 
33 BOOST_LOG_OPEN_NAMESPACE
34 
35 namespace sinks {
36 
37 namespace aux {
38 
39 //! Log record with enqueueing timestamp
40 class enqueued_record
41 {
42     BOOST_COPYABLE_AND_MOVABLE(enqueued_record)
43 
44 public:
45     //! Ordering predicate
46     template< typename OrderT >
47     struct order :
48         public OrderT
49     {
50         typedef typename OrderT::result_type result_type;
51 
orderboost::sinks::aux::enqueued_record::order52         order() {}
orderboost::sinks::aux::enqueued_record::order53         order(order const& that) : OrderT(static_cast< OrderT const& >(that)) {}
orderboost::sinks::aux::enqueued_record::order54         order(OrderT const& that) : OrderT(that) {}
55 
operator ()boost::sinks::aux::enqueued_record::order56         result_type operator() (enqueued_record const& left, enqueued_record const& right) const
57         {
58             // std::priority_queue requires ordering with semantics of std::greater, so we swap arguments
59             return OrderT::operator() (right.m_record, left.m_record);
60         }
61     };
62 
63     boost::log::aux::timestamp m_timestamp;
64     record_view m_record;
65 
enqueued_record(enqueued_record const & that)66     enqueued_record(enqueued_record const& that) BOOST_NOEXCEPT : m_timestamp(that.m_timestamp), m_record(that.m_record)
67     {
68     }
enqueued_record(BOOST_RV_REF (enqueued_record)that)69     enqueued_record(BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT :
70         m_timestamp(that.m_timestamp),
71         m_record(boost::move(that.m_record))
72     {
73     }
enqueued_record(record_view const & rec)74     explicit enqueued_record(record_view const& rec) :
75         m_timestamp(boost::log::aux::get_timestamp()),
76         m_record(rec)
77     {
78     }
operator =(BOOST_COPY_ASSIGN_REF (enqueued_record)that)79     enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that) BOOST_NOEXCEPT
80     {
81         m_timestamp = that.m_timestamp;
82         m_record = that.m_record;
83         return *this;
84     }
operator =(BOOST_RV_REF (enqueued_record)that)85     enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT
86     {
87         m_timestamp = that.m_timestamp;
88         m_record = boost::move(that.m_record);
89         return *this;
90     }
91 };
92 
93 } // namespace aux
94 
95 } // namespace sinks
96 
97 BOOST_LOG_CLOSE_NAMESPACE // namespace log
98 
99 } // namespace boost
100 
101 #include <boost/log/detail/footer.hpp>
102 
103 #endif // BOOST_LOG_DETAIL_ENQUEUED_RECORD_HPP_INCLUDED_
104