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)
9 * \author Andrey Semashev
12 * This header contains a logging record class definition.
15 #ifndef BOOST_LOG_CORE_RECORD_HPP_INCLUDED_
16 #define BOOST_LOG_CORE_RECORD_HPP_INCLUDED_
18 #include <boost/move/core.hpp>
19 #include <boost/core/explicit_operator_bool.hpp>
20 #include <boost/log/detail/config.hpp>
21 #include <boost/log/attributes/attribute_value_set.hpp>
22 #include <boost/log/expressions/keyword_fwd.hpp>
23 #include <boost/log/core/record_view.hpp>
24 #include <boost/log/detail/header.hpp>
26 #ifdef BOOST_HAS_PRAGMA_ONCE
32 BOOST_LOG_OPEN_NAMESPACE
37 * \brief Logging record class
39 * The logging record encapsulates all information related to a single logging statement,
40 * in particular, attribute values view and the log message string. The record can be updated before pushing
41 * for further processing to the logging core.
45 BOOST_MOVABLE_BUT_NOT_COPYABLE(record)
49 #ifndef BOOST_LOG_DOXYGEN_PASS
52 typedef record_view::public_data public_data;
55 //! A pointer to the log record implementation
59 // A private constructor, accessible from core
60 BOOST_CONSTEXPR explicit record(public_data* impl) BOOST_NOEXCEPT : m_impl(impl) {}
62 #endif // BOOST_LOG_DOXYGEN_PASS
66 * Default constructor. Creates an empty record that is equivalent to the invalid record handle.
68 * \post <tt>!*this == true</tt>
70 BOOST_CONSTEXPR record() BOOST_NOEXCEPT : m_impl(NULL) {}
73 * Move constructor. Source record contents unspecified after the operation.
75 record(BOOST_RV_REF(record) that) BOOST_NOEXCEPT : m_impl(that.m_impl)
81 * Destructor. Destroys the record, releases any sinks and attribute values that were involved in processing this record.
83 ~record() BOOST_NOEXCEPT
89 * Move assignment. Source record contents unspecified after the operation.
91 record& operator= (BOOST_RV_REF(record) that) BOOST_NOEXCEPT
93 swap(static_cast< record& >(that));
98 * \return A reference to the set of attribute values attached to this record
100 * \pre <tt>!!*this</tt>
102 attribute_value_set& attribute_values() BOOST_NOEXCEPT
104 return m_impl->m_attribute_values;
108 * \return A reference to the set of attribute values attached to this record
110 * \pre <tt>!!*this</tt>
112 attribute_value_set const& attribute_values() const BOOST_NOEXCEPT
114 return m_impl->m_attribute_values;
118 * Conversion to an unspecified boolean type
120 * \return \c true, if the <tt>*this</tt> identifies a log record, \c false, if the <tt>*this</tt> is not valid
122 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
125 * Inverted conversion to an unspecified boolean type
127 * \return \c false, if the <tt>*this</tt> identifies a log record, \c true, if the <tt>*this</tt> is not valid
129 bool operator! () const BOOST_NOEXCEPT
137 * \param that Another record to swap with
138 * <b>Throws:</b> Nothing
140 void swap(record& that) BOOST_NOEXCEPT
142 public_data* p = m_impl;
143 m_impl = that.m_impl;
148 * Resets the log record handle. If there are no other handles left, the log record is closed
149 * and all resources referenced by the record are released.
151 * \post <tt>!*this == true</tt>
153 void reset() BOOST_NOEXCEPT
157 public_data::destroy(m_impl);
163 * Attribute value lookup.
165 * \param name Attribute name.
166 * \return An \c attribute_value, non-empty if it is found, empty otherwise.
168 attribute_value_set::mapped_type operator[] (attribute_value_set::key_type name) const
170 return m_impl->m_attribute_values[name];
174 * Attribute value lookup.
176 * \param keyword Attribute keyword.
177 * \return A \c value_ref with extracted attribute value if it is found, empty \c value_ref otherwise.
179 template< typename DescriptorT, template< typename > class ActorT >
180 typename result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type
181 operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const& keyword) const
183 return m_impl->m_attribute_values[keyword];
187 * The function ensures that the log record does not depend on any thread-specific data. Then the record contents
188 * are used to construct a \c record_view which is returned from the function. The record is no longer valid after the call.
190 * \pre <tt>!!*this</tt>
191 * \post <tt>!*this</tt>
192 * \returns The record view that contains all attribute values from the original record.
194 BOOST_LOG_API record_view lock();
198 * A free-standing swap function overload for \c record
200 inline void swap(record& left, record& right) BOOST_NOEXCEPT
205 BOOST_LOG_CLOSE_NAMESPACE // namespace log
209 #include <boost/log/detail/footer.hpp>
211 #endif // BOOST_LOG_CORE_RECORD_HPP_INCLUDED_