File indexing completed on 2025-01-18 09:39:19
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/detail/atomic_count.hpp>
0027 #endif
0028 #include <boost/log/detail/header.hpp>
0029
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033
0034 namespace boost {
0035
0036 BOOST_LOG_OPEN_NAMESPACE
0037
0038 #ifndef BOOST_LOG_DOXYGEN_PASS
0039 class core;
0040 class record;
0041 #endif
0042
0043
0044
0045
0046
0047
0048
0049
0050 class record_view
0051 {
0052 BOOST_COPYABLE_AND_MOVABLE(record_view)
0053
0054 friend class core;
0055 friend class record;
0056
0057 #ifndef BOOST_LOG_DOXYGEN_PASS
0058 private:
0059
0060 struct private_data;
0061 friend struct private_data;
0062
0063
0064 struct public_data
0065 {
0066
0067 #ifndef BOOST_LOG_NO_THREADS
0068 mutable boost::detail::atomic_count m_ref_counter;
0069 #else
0070 mutable unsigned int m_ref_counter;
0071 #endif
0072
0073
0074 attribute_value_set m_attribute_values;
0075
0076
0077 explicit public_data(BOOST_RV_REF(attribute_value_set) values) BOOST_NOEXCEPT :
0078 m_ref_counter(1),
0079 m_attribute_values(boost::move(values))
0080 {
0081 }
0082
0083
0084 BOOST_LOG_API static void destroy(const public_data* p) BOOST_NOEXCEPT;
0085
0086 protected:
0087 ~public_data() {}
0088
0089 BOOST_DELETED_FUNCTION(public_data(public_data const&))
0090 BOOST_DELETED_FUNCTION(public_data& operator= (public_data const&))
0091
0092 friend void intrusive_ptr_add_ref(const public_data* p) BOOST_NOEXCEPT { ++p->m_ref_counter; }
0093 friend void intrusive_ptr_release(const public_data* p) BOOST_NOEXCEPT { if (--p->m_ref_counter == 0) public_data::destroy(p); }
0094 };
0095
0096 private:
0097
0098 intrusive_ptr< public_data > m_impl;
0099
0100 private:
0101
0102 explicit record_view(public_data* impl) BOOST_NOEXCEPT : m_impl(impl, false) {}
0103
0104 #endif
0105
0106 public:
0107
0108
0109
0110
0111
0112 BOOST_CONSTEXPR record_view() BOOST_NOEXCEPT
0113 #if !defined(BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS) && !defined(BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS)
0114 = default;
0115 #else
0116 {}
0117 #endif
0118
0119
0120
0121
0122 record_view(record_view const& that) BOOST_NOEXCEPT : m_impl(that.m_impl) {}
0123
0124
0125
0126
0127 record_view(BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT
0128 {
0129 m_impl.swap(that.m_impl);
0130 }
0131
0132
0133
0134
0135 ~record_view() BOOST_NOEXCEPT {}
0136
0137
0138
0139
0140 record_view& operator= (BOOST_COPY_ASSIGN_REF(record_view) that) BOOST_NOEXCEPT
0141 {
0142 m_impl = that.m_impl;
0143 return *this;
0144 }
0145
0146
0147
0148
0149 record_view& operator= (BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT
0150 {
0151 m_impl.swap(that.m_impl);
0152 return *this;
0153 }
0154
0155
0156
0157
0158
0159
0160 attribute_value_set const& attribute_values() const BOOST_NOEXCEPT
0161 {
0162 return m_impl->m_attribute_values;
0163 }
0164
0165
0166
0167
0168
0169
0170
0171
0172 bool operator== (record_view const& that) const BOOST_NOEXCEPT
0173 {
0174 return m_impl == that.m_impl;
0175 }
0176
0177
0178
0179
0180
0181
0182
0183 bool operator!= (record_view const& that) const BOOST_NOEXCEPT
0184 {
0185 return !operator== (that);
0186 }
0187
0188
0189
0190
0191
0192
0193 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
0194
0195
0196
0197
0198
0199
0200 bool operator! () const BOOST_NOEXCEPT
0201 {
0202 return !m_impl;
0203 }
0204
0205
0206
0207
0208
0209
0210
0211 void swap(record_view& that) BOOST_NOEXCEPT
0212 {
0213 m_impl.swap(that.m_impl);
0214 }
0215
0216
0217
0218
0219
0220
0221
0222 void reset() BOOST_NOEXCEPT
0223 {
0224 m_impl.reset();
0225 }
0226
0227
0228
0229
0230
0231
0232
0233 attribute_value_set::mapped_type operator[] (attribute_value_set::key_type name) const
0234 {
0235 return m_impl->m_attribute_values[name];
0236 }
0237
0238
0239
0240
0241
0242
0243
0244 template< typename DescriptorT, template< typename > class ActorT >
0245 typename result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type
0246 operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const& keyword) const
0247 {
0248 return m_impl->m_attribute_values[keyword];
0249 }
0250 };
0251
0252
0253
0254
0255 inline void swap(record_view& left, record_view& right) BOOST_NOEXCEPT
0256 {
0257 left.swap(right);
0258 }
0259
0260 BOOST_LOG_CLOSE_NAMESPACE
0261
0262 }
0263
0264 #include <boost/log/detail/footer.hpp>
0265
0266 #endif