boost::log::attribute — A base class for an attribute value factory.
// 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 intrusive_ref_counter { // 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 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 &); };
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 considirable 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/destructattribute() = default;
Default constructor. Creates an empty attribute value factory, which is not usable until set_impl
is called.
attribute(attribute const & that);
Copy constructor
attribute(attribute && that);
Move constructor
explicit attribute(intrusive_ptr< impl > p);
Initializing constructor
Parameters: |
|
attribute& operator=(attribute const & that);
Copy assignment
attribute& operator=(attribute && that);
Move assignment
attribute
public member functionsbool operator!() const;
Verifies that the factory is not in empty state
Verifies that the factory is in empty state
attribute_value get_value() const;
Returns: |
The actual attribute value. It shall not return empty values (exceptions shall be used to indicate errors). |
void swap(attribute & that);
The method swaps two factories (i.e. their implementations).
attribute
friend functionstemplate<typename T> friend T attribute_cast(attribute const &);
The function casts one attribute factory to another