Kea  2.3.5-git
isc::util::StagedValue< ValueType > Class Template Reference

This class implements set/commit mechanism for a single object. More...

#include <staged_value.h>

+ Inheritance diagram for isc::util::StagedValue< ValueType >:

Public Member Functions

 StagedValue ()
 Constructor. More...
 
void commit ()
 Commits a value. More...
 
const ValueType & getValue () const
 Retrieves current value. More...
 
 operator const ValueType & () const
 Conversion operator to value type. More...
 
StagedValueoperator= (const ValueType &value)
 Assignment operator. More...
 
void reset ()
 Resets value to defaults. More...
 
void revert ()
 Reverts any modifications since last commit. More...
 
void setValue (const ValueType &new_value)
 Sets new value. More...
 

Detailed Description

template<typename ValueType>
class isc::util::StagedValue< ValueType >

This class implements set/commit mechanism for a single object.

In some cases it is desired to set value for an object while keeping ability to revert to an original value under certain conditions. This is often desired for objects holding some part of application's configuration. Configuration is usually a multi-step process and may fail on almost any stage. If this happens, the last good configuration should be used. This implies that some of the state of some of the objects needs to be reverted.

This class implements a mechanism for setting and committing a value. Until the new value has been committed it is possible to revert to an original value.

Template Parameters
ValueTypeType of the value represented by this class.

Definition at line 32 of file staged_value.h.

Constructor & Destructor Documentation

◆ StagedValue()

template<typename ValueType>
isc::util::StagedValue< ValueType >::StagedValue ( )
inline

Constructor.

Initializes the default value.

Definition at line 38 of file staged_value.h.

Member Function Documentation

◆ commit()

template<typename ValueType>
void isc::util::StagedValue< ValueType >::commit ( )
inline

Commits a value.

Definition at line 61 of file staged_value.h.

◆ getValue()

template<typename ValueType>
const ValueType& isc::util::StagedValue< ValueType >::getValue ( ) const
inline

Retrieves current value.

If the value hasn't been modified since last commit, reset or revert operation, a committed value is returned. If the value has been modified, the modified value is returned.

Definition at line 48 of file staged_value.h.

Referenced by isc::util::StagedValue< ValueType >::operator const ValueType &().

◆ operator const ValueType &()

template<typename ValueType>
isc::util::StagedValue< ValueType >::operator const ValueType & ( ) const
inline

Conversion operator to value type.

Returns
Reference to value represented by this object.

Definition at line 93 of file staged_value.h.

References isc::util::StagedValue< ValueType >::getValue().

+ Here is the call graph for this function:

◆ operator=()

template<typename ValueType>
StagedValue& isc::util::StagedValue< ValueType >::operator= ( const ValueType &  value)
inline

Assignment operator.

Parameters
valueNew value to be assigned.
Returns
Reference to this.

Definition at line 85 of file staged_value.h.

◆ reset()

template<typename ValueType>
void isc::util::StagedValue< ValueType >::reset ( )
inline

Resets value to defaults.

Definition at line 70 of file staged_value.h.

◆ revert()

template<typename ValueType>
void isc::util::StagedValue< ValueType >::revert ( )
inline

◆ setValue()

template<typename ValueType>
void isc::util::StagedValue< ValueType >::setValue ( const ValueType &  new_value)
inline

Sets new value.

Parameters
new_valueNew value to be assigned.

Definition at line 55 of file staged_value.h.

Referenced by isc::util::StagedValue< isc::dhcp::OptionDefSpaceContainer >::operator=().


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