Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::attribute_value_set Class Reference

A set of attribute values. More...

#include <attribute_value_set.hpp>

Classes

class  const_iterator
 

Public Types

typedef attribute_name key_type
 Key type. More...
 
typedef attribute_value mapped_type
 Mapped attribute type. More...
 
typedef std::pair< const
key_type, mapped_type
value_type
 Value type. More...
 
typedef value_typereference
 Reference type. More...
 
typedef value_type const & const_reference
 Const reference type. More...
 
typedef value_typepointer
 Pointer type. More...
 
typedef value_type const * const_pointer
 Const pointer type. More...
 
typedef std::size_t size_type
 Size type. More...
 
typedef std::ptrdiff_t difference_type
 Pointer difference type. More...
 

Public Member Functions

BOOST_LOG_API attribute_value_set (size_type reserve_count=8)
 Default constructor. More...
 
 attribute_value_set (BOOST_RV_REF(attribute_value_set) that) BOOST_NOEXCEPT
 Move constructor. More...
 
BOOST_LOG_API attribute_value_set (attribute_set const &source_attrs, attribute_set const &thread_attrs, attribute_set const &global_attrs, size_type reserve_count=8)
 The constructor adopts three attribute sets into the value set. More...
 
BOOST_LOG_API attribute_value_set (attribute_value_set const &source_attrs, attribute_set const &thread_attrs, attribute_set const &global_attrs, size_type reserve_count=8)
 The constructor adopts three attribute sets into the value set. More...
 
 attribute_value_set (BOOST_RV_REF(attribute_value_set) source_attrs, attribute_set const &thread_attrs, attribute_set const &global_attrs, size_type reserve_count=8)
 The constructor adopts three attribute sets into the value set. More...
 
BOOST_LOG_API attribute_value_set (attribute_value_set const &that)
 Copy constructor. More...
 
BOOST_LOG_API ~attribute_value_set () BOOST_NOEXCEPT
 Destructor. More...
 
attribute_value_setoperator= (attribute_value_set that) BOOST_NOEXCEPT
 Assignment operator. More...
 
void swap (attribute_value_set &that) BOOST_NOEXCEPT
 Swaps two sets. More...
 
BOOST_LOG_API const_iterator begin () const
 
BOOST_LOG_API const_iterator end () const
 
BOOST_LOG_API size_type size () const
 
bool empty () const
 
BOOST_LOG_API const_iterator find (key_type key) const
 The method finds the attribute value by name. More...
 
mapped_type operator[] (key_type key) const
 Alternative lookup syntax. More...
 
template<typename DescriptorT , template< typename > class ActorT>
result_of::extract< typename
expressions::attribute_keyword
< DescriptorT, ActorT >
::value_type, DescriptorT >
::type 
operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const &keyword) const
 Alternative lookup syntax. More...
 
size_type count (key_type key) const
 The method counts the number of the attribute value occurrences in the set. More...
 
BOOST_LOG_API void freeze ()
 The method acquires values of all adopted attributes. More...
 
BOOST_LOG_API std::pair
< const_iterator, bool > 
insert (key_type key, mapped_type const &mapped)
 Inserts an element into the set. More...
 
std::pair< const_iterator, bool > insert (const_reference value)
 Inserts an element into the set. More...
 
template<typename FwdIteratorT >
void insert (FwdIteratorT begin, FwdIteratorT end)
 Mass insertion method. More...
 
template<typename FwdIteratorT , typename OutputIteratorT >
void insert (FwdIteratorT begin, FwdIteratorT end, OutputIteratorT out)
 Mass insertion method with ability to acquire iterators to the inserted elements. More...
 

Friends

struct implementation
 
struct node
 
class const_iterator
 

Detailed Description

A set of attribute values.

The set of attribute values is an associative container with attribute name as a key and a pointer to attribute value object as a mapped type. This is a collection of elements with unique keys, that is, there can be only one attribute value with a given name in the set. With respect to read-only capabilities, the set interface is close to std::unordered_map.

The set is designed to be only capable of adding elements to it. Once added, the attribute value cannot be removed from the set.

An instance of attribute value set can be constructed from three attribute sets. The constructor attempts to accommodate values of all attributes from the sets. The situation when a same-named attribute is found in more than one attribute set is possible. This problem is solved on construction of the value set: the three attribute sets have different priorities when it comes to solving conflicts.

From the library perspective the three source attribute sets are global, thread-specific and source-specific attributes, with the latter having the highest priority. This feature allows to override attributes of wider scopes with the more specific ones.

For sake of performance, the attribute values are not immediately acquired from attribute sets at construction. Instead, on-demand acquisition is performed either on iterator dereferencing or on call to the freeze method. Once acquired, the attribute value stays within the set until its destruction. This nuance does not affect other set properties, such as size or lookup ability. The logging core automatically freezes the set at the right point, so users should not be bothered unless they manually create attribute value sets.

Note
The attribute sets that were used for the value set construction must not be modified or destroyed until the value set is frozen. Otherwise the behavior is undefined.

Member Typedef Documentation

Const pointer type.

Const reference type.

Pointer difference type.

Size type.

Value type.

Constructor & Destructor Documentation

BOOST_LOG_API boost::attribute_value_set::attribute_value_set ( size_type  reserve_count = 8)
explicit

Default constructor.

The constructor creates an empty set which can be filled later by subsequent calls of insert method. Optionally, the amount of storage reserved for elements to be inserted may be passed to the constructor. The constructed set is frozen.

Parameters
reserve_countNumber of elements to reserve space for.
boost::attribute_value_set::attribute_value_set ( BOOST_RV_REF(attribute_value_set that)
inline

Move constructor.

BOOST_LOG_API boost::attribute_value_set::attribute_value_set ( attribute_set const &  source_attrs,
attribute_set const &  thread_attrs,
attribute_set const &  global_attrs,
size_type  reserve_count = 8 
)

The constructor adopts three attribute sets into the value set.

The source_attrs attributes have the greatest preference when a same-named attribute is found in several sets, global_attrs has the least. The constructed set is not frozen.

Parameters
source_attrsA set of source-specific attributes.
thread_attrsA set of thread-specific attributes.
global_attrsA set of global attributes.
reserve_countAmount of elements to reserve space for, in addition to the elements in the three attribute sets provided.
BOOST_LOG_API boost::attribute_value_set::attribute_value_set ( attribute_value_set const &  source_attrs,
attribute_set const &  thread_attrs,
attribute_set const &  global_attrs,
size_type  reserve_count = 8 
)

The constructor adopts three attribute sets into the value set.

The source_attrs attributes have the greatest preference when a same-named attribute is found in several sets, global_attrs has the least. The constructed set is not frozen.

Precondition
The source_attrs set is frozen.
Parameters
source_attrsA set of source-specific attributes.
thread_attrsA set of thread-specific attributes.
global_attrsA set of global attributes.
reserve_countAmount of elements to reserve space for, in addition to the elements in the three attribute sets provided.
boost::attribute_value_set::attribute_value_set ( BOOST_RV_REF(attribute_value_set source_attrs,
attribute_set const &  thread_attrs,
attribute_set const &  global_attrs,
size_type  reserve_count = 8 
)
inline

The constructor adopts three attribute sets into the value set.

The source_attrs attributes have the greatest preference when a same-named attribute is found in several sets, global_attrs has the least. The constructed set is not frozen.

Precondition
The source_attrs set is frozen.
Parameters
source_attrsA set of source-specific attributes.
thread_attrsA set of thread-specific attributes.
global_attrsA set of global attributes.
reserve_countAmount of elements to reserve space for, in addition to the elements in the three attribute sets provided.
BOOST_LOG_API boost::attribute_value_set::attribute_value_set ( attribute_value_set const &  that)

Copy constructor.

Precondition
The original set is frozen.
Postcondition
The constructed set is frozen, std::equal(begin(), end(), that.begin()) == true
BOOST_LOG_API boost::attribute_value_set::~attribute_value_set ( )

Destructor.

Releases all referenced attribute values.

Member Function Documentation

BOOST_LOG_API const_iterator boost::attribute_value_set::begin ( ) const
Returns
Iterator to the first element of the set.

Referenced by insert().

size_type boost::attribute_value_set::count ( key_type  key) const
inline

The method counts the number of the attribute value occurrences in the set.

Since there can be only one attribute value with a particular key, the method always return 0 or 1.

Parameters
keyAttribute name.
Returns
The number of times the attribute value is found in the container.

References end(), and find().

bool boost::attribute_value_set::empty ( void  ) const
inline
Returns
true if there are no elements in the container, false otherwise.

References size().

BOOST_LOG_API const_iterator boost::attribute_value_set::find ( key_type  key) const

The method finds the attribute value by name.

Parameters
keyAttribute name.
Returns
Iterator to the found element or end() if the attribute with such name is not found.

Referenced by count(), boost::expressions::has_attribute< void >::operator()(), boost::value_visitor_invoker< channel_value_type, channel_fallback_policy >::operator()(), boost::value_extractor< T, FallbackPolicyT, TagT >::operator()(), and operator[]().

BOOST_LOG_API void boost::attribute_value_set::freeze ( )

The method acquires values of all adopted attributes.

Postcondition
The set is frozen.
BOOST_LOG_API std::pair< const_iterator, bool > boost::attribute_value_set::insert ( key_type  key,
mapped_type const &  mapped 
)

Inserts an element into the set.

The complexity of the operation is amortized constant.

Precondition
The set is frozen.
Parameters
keyThe attribute name.
mappedThe attribute value.
Returns
An iterator to the inserted element and true if insertion succeeded. Otherwise, if the set already contains a same-named attribute value, iterator to the existing element and false.

Referenced by insert(), and boost::operator<<().

std::pair< const_iterator, bool > boost::attribute_value_set::insert ( const_reference  value)
inline

Inserts an element into the set.

The complexity of the operation is amortized constant.

Precondition
The set is frozen.
Parameters
valueThe attribute name and value.
Returns
An iterator to the inserted element and true if insertion succeeded. Otherwise, if the set already contains a same-named attribute value, iterator to the existing element and false.

References insert().

Referenced by insert().

template<typename FwdIteratorT >
void boost::attribute_value_set::insert ( FwdIteratorT  begin,
FwdIteratorT  end 
)
inline

Mass insertion method.

The complexity of the operation is linear to the number of elements inserted.

Precondition
The set is frozen.
Parameters
beginA forward iterator that points to the first element to be inserted.
endA forward iterator that points to the after-the-last element to be inserted.

References begin(), end(), and insert().

template<typename FwdIteratorT , typename OutputIteratorT >
void boost::attribute_value_set::insert ( FwdIteratorT  begin,
FwdIteratorT  end,
OutputIteratorT  out 
)
inline

Mass insertion method with ability to acquire iterators to the inserted elements.

The complexity of the operation is linear to the number of elements inserted times the complexity of filling the out iterator.

Precondition
The set is frozen.
Parameters
beginA forward iterator that points to the first element to be inserted.
endA forward iterator that points to the after-the-last element to be inserted.
outAn output iterator that receives results of insertion of the elements.

References begin(), end(), insert(), and boost::out.

attribute_value_set& boost::attribute_value_set::operator= ( attribute_value_set  that)
inline

Assignment operator.

References swap().

mapped_type boost::attribute_value_set::operator[] ( key_type  key) const
inline

Alternative lookup syntax.

Parameters
keyAttribute name.
Returns
A pointer to the attribute value if it is found with key, default-constructed mapped value otherwise.

References end(), find(), and boost::it.

template<typename DescriptorT , template< typename > class ActorT>
result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type boost::attribute_value_set::operator[] ( expressions::attribute_keyword< DescriptorT, ActorT > const &  keyword) const
inline

Alternative lookup syntax.

Parameters
keywordAttribute keyword.
Returns
A value_ref with extracted attribute value if it is found, empty value_ref otherwise.

References end(), find(), boost::expressions::attribute_keyword< DescriptorT, ActorT >::get_name(), boost::it, and boost::detail::type.

BOOST_LOG_API size_type boost::attribute_value_set::size ( ) const
Returns
Number of elements in the set.

Referenced by empty().

void boost::attribute_value_set::swap ( attribute_value_set that)
inline

Swaps two sets.

Throws: Nothing.

References implementation, and boost::multiprecision::backends::p.

Referenced by operator=().

Friends And Related Function Documentation

friend class const_iterator
friend
friend struct implementation
friend

Referenced by swap().


The documentation for this class was generated from the following file: