Kea 2.7.5
isc::util::State Class Reference

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

#include <state_model.h>

+ Inheritance diagram for isc::util::State:

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
valueis the numeric value of the state
labelis the text label to assign to the state
handleris the bound instance method which handles the state's action.
state_pausingpausing 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));
State(const int value, const std::string &label, StateHandler handler, const StatePausing &state_pausing=STATE_PAUSE_NEVER)
Constructor.
Exceptions
StateModelErrorif label is null or blank.

Definition at line 16 of file state_model.cc.

◆ ~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: