Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Class attribute

boost::log::attribute — A base class for an attribute value factory.

Synopsis

// In header: <boost/log/attributes/attribute.hpp>


class attribute {
public:
  // member classes/structs/unions

  // A base class for an attribute value factory.

  struct impl : public boost::intrusive_ref_counter< impl > {
    // construct/copy/destruct
    ~impl();

    // public member functions
    attribute_value get_value();

    // public static functions
    static void * operator new(std::size_t);
    static void operator delete(void *, std::size_t);
  };
  // construct/copy/destruct
  attribute() = default;
  attribute(attribute const &);
  attribute(attribute &&);
  explicit attribute(intrusive_ptr< impl >);
  attribute& operator=(attribute const &);
  attribute& operator=(attribute &&);

  // public member functions
  explicit operator bool() const;
  bool operator!() const;
  attribute_value get_value() const;
  void swap(attribute &);

  // protected member functions
  impl * get_impl() const;
  void set_impl(intrusive_ptr< impl >);

  // friend functions
  template<typename T> friend T attribute_cast(attribute const &);
};

Description

Every attribute is represented with a factory that is basically an attribute value generator. The sole purpose of an attribute is to return an actual value when requested. A simplest attribute can always return the same value that it stores internally, but more complex ones can perform a considerable amount of work to return a value, and the returned values may differ each time requested.

A word about thread safety. An attribute should be prepared to be requested a value from multiple threads concurrently.

attribute public construct/copy/destruct

  1. attribute() = default;

    Default constructor. Creates an empty attribute value factory, which is not usable until set_impl is called.

  2. attribute(attribute const & that);

    Copy constructor

  3. attribute(attribute && that);

    Move constructor

  4. explicit attribute(intrusive_ptr< impl > p);

    Initializing constructor

    Parameters:

    p

    Pointer to the implementation. Must not be NULL.

  5. attribute& operator=(attribute const & that);

    Copy assignment

  6. attribute& operator=(attribute && that);

    Move assignment

attribute public member functions

  1. explicit operator bool() const;

    Verifies that the factory is not in empty state

  2. bool operator!() const;

    Verifies that the factory is in empty state

  3. attribute_value get_value() const;

    Returns:

    The actual attribute value. It shall not return empty values (exceptions shall be used to indicate errors).

  4. void swap(attribute & that);

    The method swaps two factories (i.e. their implementations).

attribute protected member functions

  1. impl * get_impl() const;

    Returns:

    The pointer to the implementation

  2. void set_impl(intrusive_ptr< impl > p);

    Sets the pointer to the factory implementation.

    Parameters:

    p

    Pointer to the implementation. Must not be NULL.

attribute friend functions

  1. template<typename T> friend T attribute_cast(attribute const &);

    The function casts one attribute factory to another


PrevUpHomeNext