Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::attribute_value Class Reference

An attribute value class. More...

#include <attribute_value.hpp>

Classes

struct  impl
 A base class for an attribute value implementation. More...
 

Public Member Functions

 attribute_value (attribute_value const &that) BOOST_NOEXCEPT
 Default constructor. More...
 
 attribute_value (BOOST_RV_REF(attribute_value) that) BOOST_NOEXCEPT
 Move constructor. More...
 
 attribute_value (intrusive_ptr< impl > p) BOOST_NOEXCEPT
 Initializing constructor. More...
 
attribute_valueoperator= (BOOST_COPY_ASSIGN_REF(attribute_value) that) BOOST_NOEXCEPT
 Copy assignment. More...
 
attribute_valueoperator= (BOOST_RV_REF(attribute_value) that) BOOST_NOEXCEPT
 Move assignment. More...
 
bool operator! () const BOOST_NOEXCEPT
 The operator checks if the attribute value is empty. More...
 
type_info_wrapper get_type () const
 The method returns the type information of the stored value of the attribute. More...
 
void detach_from_thread ()
 The method is called when the attribute value is passed to another thread (e.g. More...
 
bool dispatch (type_dispatcher &dispatcher) const
 The method dispatches the value to the given object. More...
 
template<typename T , typename TagT = void>
result_of::extract< T, TagT >::type extract () const
 The method attempts to extract the stored value, assuming the value has the specified type. More...
 
template<typename T , typename TagT = void>
result_of::extract_or_throw< T,
TagT >::type 
extract_or_throw () const
 The method attempts to extract the stored value, assuming the value has the specified type. More...
 
template<typename T , typename TagT = void>
result_of::extract_or_default
< T, T, TagT >::type 
extract_or_default (T const &def_value) const
 The method attempts to extract the stored value, assuming the value has the specified type. More...
 
template<typename T , typename TagT = void, typename DefaultT >
result_of::extract_or_default
< T, DefaultT, TagT >::type 
extract_or_default (DefaultT const &def_value) const
 The method attempts to extract the stored value, assuming the value has the specified type. More...
 
template<typename T , typename VisitorT >
visitation_result visit (VisitorT visitor) const
 The method attempts to extract the stored value, assuming the value has the specified type, and pass it to the visitor function object. More...
 
void swap (attribute_value &that) BOOST_NOEXCEPT
 The method swaps two attribute values. More...
 
template<typename T , typename TagT >
result_of::extract< T, TagT >::type extract () const
 
template<typename T , typename TagT >
result_of::extract_or_throw< T,
TagT >::type 
extract_or_throw () const
 
template<typename T , typename TagT >
result_of::extract_or_default
< T, T, TagT >::type 
extract_or_default (T const &def_value) const
 
template<typename T , typename TagT , typename DefaultT >
result_of::extract_or_default
< T, DefaultT, TagT >::type 
extract_or_default (DefaultT const &def_value) const
 

Detailed Description

An attribute value class.

An attribute value is an object that contains a piece of data that represents an attribute state at the point of the value acquisition. All major operations with log records, such as filtering and formatting, involve attribute values contained in a single view. Most likely an attribute value is implemented as a simple holder of some typed value. This holder implements the attribute_value::implementation interface and acts as a pimpl for the attribute_value object. The attribute_value class provides type dispatching support in order to allow to extract the value from the holder.

Normally, attributes and their values shall be designed in order to exclude as much interference as reasonable. Such approach allows to have more than one attribute value simultaneously, which improves scalability and allows to implement generating attributes.

However, there are cases when this approach does not help to achieve the required level of independency of attribute values and attribute itself from each other at a reasonable performance tradeoff. For example, an attribute or its values may use thread-specific data, which is global and shared between all the instances of the attribute/value. Passing such an attribute value to another thread would be a disaster. To solve this the library defines an additional method for attribute values, namely detach_from_thread. The attribute_value class forwards the call to its pimpl, which is supposed to ensure that it no longer refers to any thread-specific data after the call. The pimpl can create a new holder as a result of this method and return it to the attribute_value wrapper, which will keep the returned reference for any further calls. This method is called for all attribute values that are passed to another thread.

Constructor & Destructor Documentation

boost::attribute_value::attribute_value ( attribute_value const &  that)
inline

Default constructor.

Creates an empty (absent) attribute value.

Copy constructor

Referenced by boost::attribute_value::impl::get_value().

boost::attribute_value::attribute_value ( BOOST_RV_REF(attribute_value that)
inline

Move constructor.

References boost::intrusive_ptr< T >::swap().

boost::attribute_value::attribute_value ( intrusive_ptr< impl p)
inlineexplicit

Initializing constructor.

Creates an attribute value that refers to the specified holder.

Parameters
pA pointer to the attribute value holder.

References boost::multiprecision::backends::p, and boost::intrusive_ptr< T >::swap().

Member Function Documentation

void boost::attribute_value::detach_from_thread ( )
inline

The method is called when the attribute value is passed to another thread (e.g.

in case of asynchronous logging). The value should ensure it properly owns all thread-specific data.

Postcondition
The attribute value no longer refers to any thread-specific resources.

References boost::attribute_value::impl::detach_from_thread(), and boost::intrusive_ptr< T >::get().

bool boost::attribute_value::dispatch ( type_dispatcher dispatcher) const
inline

The method dispatches the value to the given object.

This method is a low level interface for attribute value visitation and extraction. For typical usage these interfaces may be more convenient.

Parameters
dispatcherThe object that attempts to dispatch the stored value.
Returns
true if the value is not empty and the dispatcher was capable to consume the real attribute value type and false otherwise.

References boost::attribute_value::impl::dispatch(), and boost::intrusive_ptr< T >::get().

Referenced by boost::value_visitor_invoker< channel_value_type, channel_fallback_policy >::operator()(), and boost::value_extractor< T, FallbackPolicyT, TagT >::operator()().

template<typename T , typename TagT = void>
result_of::extract< T, TagT >::type boost::attribute_value::extract ( ) const

The method attempts to extract the stored value, assuming the value has the specified type.

One can specify either a single type or an MPL type sequence, in which case the stored value is checked against every type in the sequence.

Note
Include value_extraction.hpp prior to using this method.
Returns
The extracted value, if the attribute value is not empty and the value is the same as specified. Otherwise returns an empty value. See description of the result_of::extract metafunction for information on the nature of the result value.
template<typename T , typename TagT >
result_of::extract< T, TagT >::type boost::attribute_value::extract ( ) const
inline
template<typename T , typename TagT = void>
result_of::extract_or_default< T, T, TagT >::type boost::attribute_value::extract_or_default ( T const &  def_value) const

The method attempts to extract the stored value, assuming the value has the specified type.

One can specify either a single type or an MPL type sequence, in which case the stored value is checked against every type in the sequence. If extraction fails, the default value is returned.

Note
Include value_extraction.hpp prior to using this method.
Parameters
def_valueDefault value.
Returns
The extracted value, if the attribute value is not empty and the value is the same as specified. Otherwise returns the default value. See description of the result_of::extract_or_default metafunction for information on the nature of the result value.
template<typename T , typename TagT = void, typename DefaultT >
result_of::extract_or_default< T, DefaultT, TagT >::type boost::attribute_value::extract_or_default ( DefaultT const &  def_value) const

The method attempts to extract the stored value, assuming the value has the specified type.

One can specify either a single type or an MPL type sequence, in which case the stored value is checked against every type in the sequence. If extraction fails, the default value is returned.

Note
Include value_extraction.hpp prior to using this method.
Parameters
def_valueDefault value.
Returns
The extracted value, if the attribute value is not empty and the value is the same as specified. Otherwise returns the default value. See description of the result_of::extract_or_default metafunction for information on the nature of the result value.
template<typename T , typename TagT >
result_of::extract_or_default< T, T, TagT >::type boost::attribute_value::extract_or_default ( T const &  def_value) const
inline
template<typename T , typename TagT , typename DefaultT >
result_of::extract_or_default< T, DefaultT, TagT >::type boost::attribute_value::extract_or_default ( DefaultT const &  def_value) const
inline
template<typename T , typename TagT = void>
result_of::extract_or_throw< T, TagT >::type boost::attribute_value::extract_or_throw ( ) const

The method attempts to extract the stored value, assuming the value has the specified type.

One can specify either a single type or an MPL type sequence, in which case the stored value is checked against every type in the sequence.

Note
Include value_extraction.hpp prior to using this method.
Returns
The extracted value, if the attribute value is not empty and the value is the same as specified. Otherwise an exception is thrown. See description of the result_of::extract_or_throw metafunction for information on the nature of the result value.
template<typename T , typename TagT >
result_of::extract_or_throw< T, TagT >::type boost::attribute_value::extract_or_throw ( ) const
inline
type_info_wrapper boost::attribute_value::get_type ( ) const
inline

The method returns the type information of the stored value of the attribute.

The returned type info wrapper may be empty if the attribute value is empty or the information cannot be provided. If the returned value is not empty, the type can be used for value extraction.

References boost::intrusive_ptr< T >::get(), and boost::attribute_value::impl::get_type().

Referenced by boost::value_visitor_invoker< channel_value_type, channel_fallback_policy >::operator()(), and boost::value_extractor< T, FallbackPolicyT, TagT >::operator()().

bool boost::attribute_value::operator! ( ) const
inline

The operator checks if the attribute value is empty.

The operator checks if the attribute value is empty

attribute_value& boost::attribute_value::operator= ( BOOST_COPY_ASSIGN_REF(attribute_value that)
inline

Copy assignment.

attribute_value& boost::attribute_value::operator= ( BOOST_RV_REF(attribute_value that)
inline

Move assignment.

References boost::intrusive_ptr< T >::swap().

void boost::attribute_value::swap ( attribute_value that)
inline

The method swaps two attribute values.

References boost::intrusive_ptr< T >::swap().

template<typename T , typename VisitorT >
visitation_result boost::attribute_value::visit ( VisitorT  visitor) const
inline

The method attempts to extract the stored value, assuming the value has the specified type, and pass it to the visitor function object.

One can specify either a single type or an MPL type sequence, in which case the stored value is checked against every type in the sequence.

Note
Include value_visitation.hpp prior to using this method.
Parameters
visitorA function object that will be invoked on the extracted attribute value. The visitor should be capable to be called with a single argument of any type of the specified types in T.
Returns
The result of visitation.

References boost::visitor().


The documentation for this class was generated from the following files: