Kea: isc::util::StagedValue< ValueType > Class Template Reference

| Kea 3.2.0-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 >:
[legend]

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

## 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

  ValueType | Type 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.

Referenced by operator=().

## 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.

References revert().

Here is the call graph for this function:

## ◆ 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< isc::dhcp::OptionDefSpaceContainer >::operator const isc::dhcp::OptionDefSpaceContainer &().

## ◆ 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.

## ◆ operator=()

template<typename ValueType>

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

Assignment operator.

Parameters

  value | New value to be assigned.

Returns
  Reference to this.

Definition at line 85 of file staged_value.h.

References StagedValue(), and setValue().

Here is the call graph for this function:

## ◆ reset()

template<typename ValueType>

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

Resets value to defaults.

Definition at line 70 of file staged_value.h.

References revert().

Here is the call graph for this function:

## ◆ revert()

template<typename ValueType>

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

Reverts any modifications since last commit.

Definition at line 76 of file staged_value.h.

Referenced by commit(), and reset().

## ◆ setValue()

template<typename ValueType>

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

Sets new value.

Parameters

  new_value | New value to be assigned.

Definition at line 55 of file staged_value.h.

Referenced by operator=().

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

- staged_value.h