boost::log::attributes::basic_attribute_value — Basic attribute value class.
// In header: <boost/log/attributes/basic_attribute_value.hpp> template<typename T> class basic_attribute_value : public attribute_value, public templated_shared_from_this { public: // types typedef T held_type; // Value type. // construct/copy/destruct explicit basic_attribute_value(held_type const &); // public member functions bool dispatch(type_dispatcher &); shared_ptr< attribute_value > detach_from_thread(); held_type const & get() const; };
This class can be used as a boilerplate for simple attribute values. The class implements all needed interfaces of attribute values and allows to store a single value of the type specified as a template parameter. The stored value can be dispatched with type dispatching mechanism.
basic_attribute_value
public member functionsbool dispatch(type_dispatcher & dispatcher);
The method dispatches the value to the given object.
Parameters: |
|
||
Returns: | true if dispatcher was capable to consume the real attribute value type and false otherwise. |
shared_ptr< attribute_value > detach_from_thread();
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.
Returns: | An actual pointer to the attribute value. It may either point to this object or another. In the latter case the returned pointer replaces the pointer used by caller to invoke this method and is considered to be a functional equivalent to the previous pointer. |
held_type const & get() const;
Returns: | Reference to the contained value. |