Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT > Class Template Reference

A class of an attribute that holds a single constant value with ability to change it. More...

#include <mutable_constant.hpp>

Inheritance diagram for boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >:
Collaboration diagram for boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >:

Classes

class  impl
 Factory implementation. More...
 

Public Types

typedef T value_type
 The attribute value type. More...
 

Public Member Functions

 mutable_constant (value_type const &value)
 Constructor with the stored value initialization. More...
 
 mutable_constant (BOOST_RV_REF(value_type) value)
 Constructor with the stored value initialization. More...
 
 mutable_constant (cast_source const &source)
 Constructor for casting support. More...
 
void set (value_type const &value)
 The method sets a new attribute value. More...
 
void set (BOOST_RV_REF(value_type) value)
 The method sets a new attribute value. More...
 
value_type get () const
 The method acquires the current attribute value. More...
 
bool operator! () const BOOST_NOEXCEPT
 Verifies that the factory is not in empty state. More...
 
attribute_value get_value () const
 
void swap (attribute &that) BOOST_NOEXCEPT
 The method swaps two factories (i.e. More...
 

Protected Member Functions

implget_impl () const
 
void set_impl (intrusive_ptr< impl > p) BOOST_NOEXCEPT
 Sets the pointer to the factory implementation. More...
 

Detailed Description

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
class boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >

A class of an attribute that holds a single constant value with ability to change it.

The mutable_constant attribute stores a single value of type, specified as the first template argument. This value is returned on each attribute value acquisition.

The attribute also allows to modify the stored value, even if the attribute is registered in an attribute set. In order to ensure thread safety of such modifications the mutable_constant class is also parametrized with three additional template arguments: mutex type, scoped write and scoped read lock types. If not specified, the lock types are automatically deduced based on the mutex type.

The implementation may avoid using these types to actually create and use the mutex, if a more efficient synchronization method is available (such as atomic operations on the value type). By default no synchronization is done.

Member Typedef Documentation

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
typedef T boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::value_type

The attribute value type.

Constructor & Destructor Documentation

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::mutable_constant ( value_type const &  value)
inlineexplicit

Constructor with the stored value initialization.

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::mutable_constant ( BOOST_RV_REF(value_type value)
inlineexplicit

Constructor with the stored value initialization.

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::mutable_constant ( cast_source const &  source)
inlineexplicit

Constructor for casting support.

Member Function Documentation

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
value_type boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::get ( ) const
inline

The method acquires the current attribute value.

The implementation non-exclusively locks the mutex in order to protect the value acquisition.

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
impl* boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::get_impl ( ) const
inlineprotected
attribute_value boost::attribute::get_value ( ) const
inherited
Returns
The actual attribute value. It shall not return empty values (exceptions shall be used to indicate errors).
bool boost::attribute::operator! ( ) const
inlineinherited

Verifies that the factory is not in empty state.

Verifies that the factory is in empty state

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
void boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::set ( value_type const &  value)
inline

The method sets a new attribute value.

The implementation exclusively locks the mutex in order to protect the value assignment.

template<typename T, typename MutexT = void, typename ScopedWriteLockT = typename mpl::if_c< boost::log::aux::is_exclusively_lockable< MutexT >::value, boost::log::aux::exclusive_lock_guard< MutexT >, void >::type, typename ScopedReadLockT = typename mpl::if_c< boost::log::aux::is_shared_lockable< MutexT >::value, boost::log::aux::shared_lock_guard< MutexT >, ScopedWriteLockT >::type>
void boost::attributes::mutable_constant< T, MutexT, ScopedWriteLockT, ScopedReadLockT >::set ( BOOST_RV_REF(value_type value)
inline

The method sets a new attribute value.

void boost::attribute::set_impl ( intrusive_ptr< impl p)
inlineprotectedinherited

Sets the pointer to the factory implementation.

Parameters
pPointer to the implementation. Must not be NULL.

References boost::multiprecision::backends::p, and boost::intrusive_ptr< T >::swap().

Referenced by boost::attributes::counter< T >::counter().

void boost::attribute::swap ( attribute that)
inlineinherited

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