Kea: isc::util::State Class Reference

| Kea 3.0.0

isc::util::State Class Reference

Defines a State within the State Model. More...

`#include <state_model.h>`

Inheritance diagram for isc::util::State:
[legend]

## Public Member Functions
| State (const int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
| Constructor.
virtual | ~State ()
| Destructor.
void | run ()
| Invokes the State's handler.
bool | shouldPause ()
| Indicates if the state model should pause upon entering this state.
Public Member Functions inherited from isc::util::LabeledValue
| LabeledValue (const int value, const std::string &label)
| Constructor.
virtual | ~LabeledValue ()
| Destructor.
std::string | getLabel () const
| Gets the text label of this instance.
int | getValue () const
| Gets the integer value of this instance.
bool | operator!= (const LabeledValue &other) const
| Inequality operator.
bool | operator< (const LabeledValue &other) const
| Less-than operator.
bool | operator== (const LabeledValue &other) const
| Equality operator.

## Detailed Description

Defines a State within the State Model.

This class provides the means to define a state within a set or dictionary of states, and assign the state an handler method to execute the state's actions. It derives from LabeledValue which allows a set of states to be keyed by integer constants.

Because a state model can be paused in selected states, this class also provides the means for specifying a pausing mode and for checking whether the state model should be paused when entering this state.

Definition at line 61 of file state_model.h.

## Constructor & Destructor Documentation

## ◆ State()

isc::util::State::State | ( | const int | value,
|  | const std::string & | label,
|  | StateHandler | handler,
|  | const StatePausing & | state_pausing = STATE_PAUSE_NEVER )

Constructor.

Parameters

  value | is the numeric value of the state
  label | is the text label to assign to the state
  handler | is the bound instance method which handles the state's action.
  state_pausing | pausing mode selected for the given state. The default value is `STATE_PAUSE_NEVER`.

A typical invocation might look this:

State(SOME_INT_VAL, "SOME_INT_VAL",
std::bind(&StateModelDerivation::someHandler, this));
isc::util::State::State
State(const int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
Constructor.
Definition state_model.cc:16

Exceptions

  StateModelError | if label is null or blank.

Definition at line 16 of file state_model.cc.

References isc::util::LabeledValue::LabeledValue().

Here is the call graph for this function:

## ◆ ~State()

isc::util::State::~State | ( |  | ) |
| virtual

Destructor.

Definition at line 22 of file state_model.cc.

## Member Function Documentation

## ◆ run()

void isc::util::State::run | ( |  | ) |

Invokes the State's handler.

Definition at line 26 of file state_model.cc.

## ◆ shouldPause()

bool isc::util::State::shouldPause | ( |  | ) |

Indicates if the state model should pause upon entering this state.

It modifies the `was_paused_` flag if the state model should pause. That way, it keeps track of visits in this particular state, making it possible to pause only upon the first transition to the state when `STATE_PAUSE_ONCE` mode is used.

Definition at line 31 of file state_model.cc.

References isc::util::STATE_PAUSE_ALWAYS, and isc::util::STATE_PAUSE_ONCE.

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

- state_model.h
- state_model.cc