rtop
|
statemachine that uses integer corresponding to object uuids to represent states More...
#include <sm.h>
Public Member Functions | |
StateMachine (std::map< int, std::map< int, int >> &trans) | |
StateMachine constructor. Instantiates state machine with provided state transition table. More... | |
StateMachine () | |
StateMachine constructor. More... | |
~StateMachine () | |
void | addTransition (int, int, int) |
add a single transition i.e. tuple (key_input, curr_state, next_state) More... | |
void | next (int) |
updates current state with next state based on key input and encoded state transition table More... | |
void | next () |
same as StateMachine::next(int) except that reads key input from global More... | |
void | reset () |
resets state machine into base state as specified in transition table tuple entry (base_state, -1, base_state) More... | |
void | setCurrState (int state) |
sets current state More... | |
int | currState () const |
returns current state More... | |
int | prevState () const |
returns previous state More... | |
bool | isChanged () const |
returns true if prev_state and curr_state are different More... | |
void | stale () |
sets changed to false More... | |
Private Attributes | |
std::map< int, std::map< int, int > > | state_transitions |
state transition table More... | |
int | curr_state |
state variable holding current state value More... | |
int | prev_state |
state variable holding previous state value More... | |
bool | changed = false |
indicates whether state has changed More... | |
Friends | |
class | XMLTree |
statemachine that uses integer corresponding to object uuids to represent states
provides API to change state, based on key input
and reading state information
|
inline |
StateMachine constructor. Instantiates state machine with provided state transition table.
|
inline |
StateMachine constructor.
void rtop::StateMachine::addTransition | ( | int | key, |
int | curr_st, | ||
int | next_st | ||
) |
|
inline |
|
inline |
void rtop::StateMachine::next | ( | int | ch | ) |
void rtop::StateMachine::next | ( | ) |
same as StateMachine::next(int) except that reads key input from global
|
inline |
void rtop::StateMachine::reset | ( | ) |
|
inline |
|
private |
|
private |
|
private |
|
private |