Boost C++ Libraries

PrevUpHomeNext

Class template basic_attribute_value

boost::log::attributes::basic_attribute_value — Basic attribute value class.

Synopsis

// 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;
};

Description

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 construct/copy/destruct

  1. explicit basic_attribute_value(held_type const & v);

    Constructor with initialization of the stored value

basic_attribute_value public member functions

  1. bool dispatch(type_dispatcher & dispatcher);

    The method dispatches the value to the given object.

    Parameters:
    dispatcher

    The object that attempts to dispatch the stored value.

    Returns:

    true if dispatcher was capable to consume the real attribute value type and false otherwise.

  2. 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.

  3. held_type const & get() const;

    Returns:

    Reference to the contained value.


PrevUpHomeNext