Warning, file /include/boost/log/core/record_view.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_CORE_RECORD_VIEW_HPP_INCLUDED_
0016 #define BOOST_LOG_CORE_RECORD_VIEW_HPP_INCLUDED_
0017
0018 #include <boost/smart_ptr/intrusive_ptr.hpp>
0019 #include <boost/move/core.hpp>
0020 #include <boost/move/utility_core.hpp>
0021 #include <boost/core/explicit_operator_bool.hpp>
0022 #include <boost/log/detail/config.hpp>
0023 #include <boost/log/attributes/attribute_value_set.hpp>
0024 #include <boost/log/expressions/keyword_fwd.hpp>
0025 #ifndef BOOST_LOG_NO_THREADS
0026 #include <boost/memory_order.hpp>
0027 #include <boost/atomic/atomic.hpp>
0028 #endif
0029 #include <boost/log/detail/header.hpp>
0030
0031 #ifdef BOOST_HAS_PRAGMA_ONCE
0032 #pragma once
0033 #endif
0034
0035 namespace boost {
0036
0037 BOOST_LOG_OPEN_NAMESPACE
0038
0039 #ifndef BOOST_LOG_DOXYGEN_PASS
0040 class core;
0041 class record;
0042 #endif
0043
0044
0045
0046
0047
0048
0049
0050
0051 class record_view
0052 {
0053 BOOST_COPYABLE_AND_MOVABLE(record_view)
0054
0055 friend class core;
0056 friend class record;
0057
0058 #ifndef BOOST_LOG_DOXYGEN_PASS
0059 private:
0060
0061 struct private_data;
0062 friend struct private_data;
0063
0064
0065 struct public_data
0066 {
0067 private:
0068
0069 #ifndef BOOST_LOG_NO_THREADS
0070 mutable boost::atomic< unsigned int > m_ref_counter;
0071
0072 friend void intrusive_ptr_add_ref(const public_data* p) BOOST_NOEXCEPT
0073 {
0074 p->m_ref_counter.opaque_add(1u, boost::memory_order_relaxed);
0075 }
0076 friend void intrusive_ptr_release(const public_data* p) BOOST_NOEXCEPT
0077 {
0078 if (!p->m_ref_counter.sub_and_test(1u, boost::memory_order_acq_rel))
0079 public_data::destroy(p);
0080 }
0081 #else
0082 mutable unsigned int m_ref_counter;
0083
0084 friend void intrusive_ptr_add_ref(const public_data* p) BOOST_NOEXCEPT { ++p->m_ref_counter; }
0085 friend void intrusive_ptr_release(const public_data* p) BOOST_NOEXCEPT { if (--p->m_ref_counter == 0u) public_data::destroy(p); }
0086 #endif
0087
0088 public:
0089
0090 attribute_value_set m_attribute_values;
0091
0092
0093 explicit public_data(BOOST_RV_REF(attribute_value_set) values) BOOST_NOEXCEPT :
0094 m_ref_counter(1u),
0095 m_attribute_values(boost::move(values))
0096 {
0097 }
0098
0099
0100 BOOST_LOG_API static void destroy(const public_data* p) BOOST_NOEXCEPT;
0101
0102 protected:
0103 ~public_data() {}
0104
0105 BOOST_DELETED_FUNCTION(public_data(public_data const&))
0106 BOOST_DELETED_FUNCTION(public_data& operator= (public_data const&))
0107 };
0108
0109 private:
0110
0111 intrusive_ptr< public_data > m_impl;
0112
0113 private:
0114
0115 explicit record_view(public_data* impl) BOOST_NOEXCEPT : m_impl(impl, false) {}
0116
0117 #endif
0118
0119 public:
0120
0121
0122
0123
0124
0125 BOOST_CONSTEXPR record_view() BOOST_NOEXCEPT
0126 #if !defined(BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS) && !defined(BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS)
0127 = default;
0128 #else
0129 {}
0130 #endif
0131
0132
0133
0134
0135 record_view(record_view const& that) BOOST_NOEXCEPT : m_impl(that.m_impl) {}
0136
0137
0138
0139
0140 record_view(BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT
0141 {
0142 m_impl.swap(that.m_impl);
0143 }
0144
0145
0146
0147
0148 ~record_view() BOOST_NOEXCEPT {}
0149
0150
0151
0152
0153 record_view& operator= (BOOST_COPY_ASSIGN_REF(record_view) that) BOOST_NOEXCEPT
0154 {
0155 m_impl = that.m_impl;
0156 return *this;
0157 }
0158
0159
0160
0161
0162 record_view& operator= (BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT
0163 {
0164 m_impl.swap(that.m_impl);
0165 return *this;
0166 }
0167
0168
0169
0170
0171
0172
0173 attribute_value_set const& attribute_values() const BOOST_NOEXCEPT
0174 {
0175 return m_impl->m_attribute_values;
0176 }
0177
0178
0179
0180
0181
0182
0183
0184
0185 bool operator== (record_view const& that) const BOOST_NOEXCEPT
0186 {
0187 return m_impl == that.m_impl;
0188 }
0189
0190
0191
0192
0193
0194
0195
0196 bool operator!= (record_view const& that) const BOOST_NOEXCEPT
0197 {
0198 return !operator== (that);
0199 }
0200
0201
0202
0203
0204
0205
0206 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
0207
0208
0209
0210
0211
0212
0213 bool operator! () const BOOST_NOEXCEPT
0214 {
0215 return !m_impl;
0216 }
0217
0218
0219
0220
0221
0222
0223
0224 void swap(record_view& that) BOOST_NOEXCEPT
0225 {
0226 m_impl.swap(that.m_impl);
0227 }
0228
0229
0230
0231
0232
0233
0234
0235 void reset() BOOST_NOEXCEPT
0236 {
0237 m_impl.reset();
0238 }
0239
0240
0241
0242
0243
0244
0245
0246 attribute_value_set::mapped_type operator[] (attribute_value_set::key_type name) const
0247 {
0248 return m_impl->m_attribute_values[name];
0249 }
0250
0251
0252
0253
0254
0255
0256
0257 template< typename DescriptorT, template< typename > class ActorT >
0258 typename result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type
0259 operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const& keyword) const
0260 {
0261 return m_impl->m_attribute_values[keyword];
0262 }
0263 };
0264
0265
0266
0267
0268 inline void swap(record_view& left, record_view& right) BOOST_NOEXCEPT
0269 {
0270 left.swap(right);
0271 }
0272
0273 BOOST_LOG_CLOSE_NAMESPACE
0274
0275 }
0276
0277 #include <boost/log/detail/footer.hpp>
0278
0279 #endif