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_value & | operator= (BOOST_COPY_ASSIGN_REF(attribute_value) that) BOOST_NOEXCEPT |
Copy assignment. More... | |
attribute_value & | operator= (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 |
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.
|
inline |
Default constructor.
Creates an empty (absent) attribute value.
Copy constructor
Referenced by boost::attribute_value::impl::get_value().
|
inline |
Move constructor.
References boost::intrusive_ptr< T >::swap().
|
inlineexplicit |
Initializing constructor.
Creates an attribute value that refers to the specified holder.
p | A pointer to the attribute value holder. |
References boost::multiprecision::backends::p, and boost::intrusive_ptr< T >::swap().
|
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.
References boost::attribute_value::impl::detach_from_thread(), and boost::intrusive_ptr< T >::get().
|
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.
dispatcher | The object that attempts to dispatch the stored value. |
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()().
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.
value_extraction.hpp
prior to using this method.result_of::extract
metafunction for information on the nature of the result value.
|
inline |
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.
value_extraction.hpp
prior to using this method.def_value | Default value. |
result_of::extract_or_default
metafunction for information on the nature of the result value. 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.
value_extraction.hpp
prior to using this method.def_value | Default value. |
result_of::extract_or_default
metafunction for information on the nature of the result value.
|
inline |
|
inline |
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.
value_extraction.hpp
prior to using this method.result_of::extract_or_throw
metafunction for information on the nature of the result value.
|
inline |
|
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()().
|
inline |
The operator checks if the attribute value is empty.
The operator checks if the attribute value is empty
|
inline |
Copy assignment.
|
inline |
Move assignment.
References boost::intrusive_ptr< T >::swap().
|
inline |
The method swaps two attribute values.
References boost::intrusive_ptr< T >::swap().
|
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.
value_visitation.hpp
prior to using this method.visitor | A 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 . |
References boost::visitor().