123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- #ifndef BOOST_LOG_ATTRIBUTE_VALUE_HPP_INCLUDED_
- #define BOOST_LOG_ATTRIBUTE_VALUE_HPP_INCLUDED_
- #include <boost/type_index.hpp>
- #include <boost/move/core.hpp>
- #include <boost/smart_ptr/intrusive_ptr.hpp>
- #include <boost/core/explicit_operator_bool.hpp>
- #include <boost/log/detail/config.hpp>
- #include <boost/log/utility/type_dispatch/type_dispatcher.hpp>
- #include <boost/log/attributes/attribute.hpp>
- #include <boost/log/attributes/value_extraction_fwd.hpp>
- #include <boost/log/attributes/value_visitation_fwd.hpp>
- #include <boost/log/detail/header.hpp>
- #ifdef BOOST_HAS_PRAGMA_ONCE
- #pragma once
- #endif
- namespace boost {
- BOOST_LOG_OPEN_NAMESPACE
- class attribute_value
- {
- BOOST_COPYABLE_AND_MOVABLE(attribute_value)
- public:
-
- struct BOOST_LOG_NO_VTABLE impl :
- public attribute::impl
- {
- public:
-
- virtual bool dispatch(type_dispatcher& dispatcher) = 0;
-
- virtual intrusive_ptr< impl > detach_from_thread()
- {
- return this;
- }
-
- attribute_value get_value() BOOST_OVERRIDE { return attribute_value(this); }
-
- virtual typeindex::type_index get_type() const { return typeindex::type_index(); }
- };
- private:
-
- intrusive_ptr< impl > m_pImpl;
- public:
-
- BOOST_DEFAULTED_FUNCTION(attribute_value(), BOOST_NOEXCEPT {})
-
- attribute_value(attribute_value const& that) BOOST_NOEXCEPT : m_pImpl(that.m_pImpl) {}
-
- attribute_value(BOOST_RV_REF(attribute_value) that) BOOST_NOEXCEPT { m_pImpl.swap(that.m_pImpl); }
-
- explicit attribute_value(intrusive_ptr< impl > p) BOOST_NOEXCEPT { m_pImpl.swap(p); }
-
- attribute_value& operator= (BOOST_COPY_ASSIGN_REF(attribute_value) that) BOOST_NOEXCEPT
- {
- m_pImpl = that.m_pImpl;
- return *this;
- }
-
- attribute_value& operator= (BOOST_RV_REF(attribute_value) that) BOOST_NOEXCEPT
- {
- m_pImpl.swap(that.m_pImpl);
- return *this;
- }
-
- BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
-
- bool operator! () const BOOST_NOEXCEPT { return !m_pImpl; }
-
- typeindex::type_index get_type() const
- {
- if (m_pImpl.get())
- return m_pImpl->get_type();
- else
- return typeindex::type_index();
- }
-
- void detach_from_thread()
- {
- if (m_pImpl.get())
- m_pImpl->detach_from_thread().swap(m_pImpl);
- }
-
- bool dispatch(type_dispatcher& dispatcher) const
- {
- if (m_pImpl.get())
- return m_pImpl->dispatch(dispatcher);
- else
- return false;
- }
- #if !defined(BOOST_LOG_DOXYGEN_PASS)
- #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
- #define BOOST_LOG_AUX_VOID_DEFAULT = void
- #else
- #define BOOST_LOG_AUX_VOID_DEFAULT
- #endif
- #endif
-
- template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
- typename result_of::extract< T, TagT >::type extract() const;
-
- template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
- typename result_of::extract_or_throw< T, TagT >::type extract_or_throw() const;
-
- template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
- typename result_of::extract_or_default< T, T, TagT >::type extract_or_default(T const& def_value) const;
-
- template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
- typename result_of::extract_or_default< T, DefaultT, TagT >::type extract_or_default(DefaultT const& def_value) const;
- #if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
-
- template< typename T >
- typename result_of::extract< T >::type extract() const;
-
- template< typename T >
- typename result_of::extract_or_throw< T >::type extract_or_throw() const;
-
- template< typename T >
- typename result_of::extract_or_default< T, T >::type extract_or_default(T const& def_value) const;
-
- template< typename T, typename DefaultT >
- typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(DefaultT const& def_value) const;
- #endif
- #undef BOOST_LOG_AUX_VOID_DEFAULT
-
- template< typename T, typename VisitorT >
- visitation_result visit(VisitorT visitor) const;
-
- void swap(attribute_value& that) BOOST_NOEXCEPT
- {
- m_pImpl.swap(that.m_pImpl);
- }
- };
- inline void swap(attribute_value& left, attribute_value& right) BOOST_NOEXCEPT
- {
- left.swap(right);
- }
- BOOST_LOG_CLOSE_NAMESPACE
- }
- #include <boost/log/detail/footer.hpp>
- #if defined(BOOST_LOG_ATTRIBUTES_ATTRIBUTE_HPP_INCLUDED_)
- #include <boost/log/detail/attribute_get_value_impl.hpp>
- #endif
- #endif
|