14 #include <boost/shared_ptr.hpp> 80 State(
const int value,
const std::string& label, StateHandler handler,
100 StateHandler handler_;
135 void add(
const int value,
const std::string& label, StateHandler handler,
146 const StatePtr getState(
int value);
278 static const int NEW_ST = 0;
282 static const int END_ST = 1;
285 static const int SM_DERIVED_STATE_MIN = 11;
289 static const int NOP_EVT = 0;
295 static const int START_EVT = 1;
298 static const int END_EVT = 2;
301 static const int FAIL_EVT = 3;
304 static const int SM_DERIVED_EVENT_MIN = 11;
324 void startModel(
const int start_state);
348 virtual void runModel(
unsigned int event);
367 void nopStateHandler();
379 void initDictionaries();
405 virtual void defineEvents();
417 void defineEvent(
unsigned int value,
const std::string& label);
428 const EventPtr& getEvent(
unsigned int value);
456 virtual void verifyEvents();
482 virtual void defineStates();
498 void defineState(
unsigned int value,
const std::string& label,
499 StateHandler handler,
509 const StatePtr getState(
unsigned int value);
536 virtual void verifyStates();
548 virtual void onModelFailure(
const std::string& explanation);
561 void transition(
unsigned int state,
unsigned int event);
572 void abortModel(
const std::string& explanation);
585 void setState(
unsigned int state);
596 void postNextEvent(
unsigned int event);
629 unsigned int getCurrState()
const;
634 unsigned int getPrevState()
const;
639 unsigned int getLastEvent()
const;
648 unsigned int getNextEvent()
const;
653 bool isModelNew()
const;
659 bool isModelRunning()
const;
665 bool isModelWaiting()
const;
670 bool isModelDone()
const;
675 bool isModelPaused()
const;
681 bool didModelFail()
const;
689 std::string getEventLabel(
const int event)
const;
697 std::string getStateLabel(
const int state)
const;
707 std::string getContextStr()
const;
717 std::string getPrevContextStr()
const;
730 const StatePtr getStateInternal(
unsigned int value);
746 void setStateInternal(
unsigned int state);
758 void postNextEventInternal(
unsigned int event);
765 bool isModelNewInternal()
const;
775 std::string getEventLabelInternal(
const int event)
const;
785 std::string getStateLabelInternal(
const int state)
const;
797 std::string getContextStrInternal()
const;
809 std::string getPrevContextStrInternal()
const;
818 bool dictionaries_initted_;
821 unsigned int curr_state_;
824 unsigned int prev_state_;
827 unsigned int last_event_;
830 unsigned int next_event_;
842 boost::shared_ptr<std::mutex> mutex_;
This file defines classes: LabeledValue and LabeledValueSet.
StatePausing
State machine pausing modes.
Implements a finite state machine.
std::function< void()> StateHandler
Defines a pointer to an instance method for handling a state.
StateModelError(const char *file, size_t line, const char *what)
LabeledValuePtr EventPtr
Define Event pointer.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
boost::shared_ptr< StateModel > StateModelPtr
Defines a pointer to a StateModel.
boost::shared_ptr< State > StatePtr
Defines a shared pointer to a State.
boost::shared_ptr< LabeledValue > LabeledValuePtr
Defines a shared pointer to a LabeledValue instance.
Implements the concept of a constant value with a text label.
LabeledValue Event
Define an Event.
Defines a State within the State Model.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
Implements a set of unique LabeledValues.
Implements a unique set or dictionary of states.
Thrown if the state machine encounters a general error.