Generic state machine implementation. More...
#include <StateMachine.h>
Public Member Functions | |
void | addState (StateEnumT state, std::string name) |
Register a new state id and its description. Used by ADD_MACHINE_STATE() | |
StateEnumT | historyState (unsigned steps) |
std::string | info () |
void | setHistoryLength (unsigned historyLength) |
Set maximal number of entries in state history. | |
void | setLastState () |
Reverse state to previous one. | |
void | setName (std::string name) |
Set machine name. | |
void | setState (StateEnumT state) |
Change the machine's state. | |
StateEnumT | state () |
StateMachine () | |
The constructor. | |
std::string | stateString () |
std::string | stateString (StateEnumT state) |
unsigned | timeSinceStateChange () |
Milliseconds since last state change. | |
~StateMachine () | |
The destructor. | |
Private Attributes | |
unsigned | m_HistoryLength |
unsigned | m_LastStateChange |
std::string | m_Name |
StateEnumT | m_State |
std::deque< StateEnumT > | m_StateHistory |
std::map< StateEnumT, std::string > | m_StateNames |
Generic state machine implementation.
Definition at line 31 of file StateMachine.h.
StateMachine< StateEnumT >::StateMachine | ( | ) |
The constructor.
Definition at line 96 of file StateMachine.h.
StateMachine< StateEnumT >::~StateMachine | ( | ) |
The destructor.
Definition at line 105 of file StateMachine.h.
void StateMachine< StateEnumT >::addState | ( | StateEnumT | state, |
std::string | name | ||
) | [inline] |
Register a new state id and its description. Used by ADD_MACHINE_STATE()
Definition at line 48 of file StateMachine.h.
StateEnumT StateMachine< StateEnumT >::historyState | ( | unsigned | steps | ) |
Definition at line 122 of file StateMachine.h.
std::string StateMachine< StateEnumT >::info | ( | ) |
Definition at line 182 of file StateMachine.h.
void StateMachine< StateEnumT >::setHistoryLength | ( | unsigned | historyLength | ) | [inline] |
Set maximal number of entries in state history.
Definition at line 45 of file StateMachine.h.
void StateMachine< StateEnumT >::setLastState | ( | ) |
Reverse state to previous one.
Definition at line 168 of file StateMachine.h.
void StateMachine< StateEnumT >::setName | ( | std::string | name | ) | [inline] |
Set machine name.
Definition at line 42 of file StateMachine.h.
void StateMachine< StateEnumT >::setState | ( | StateEnumT | state | ) |
Change the machine's state.
Definition at line 139 of file StateMachine.h.
StateEnumT StateMachine< StateEnumT >::state | ( | ) | [inline] |
Definition at line 51 of file StateMachine.h.
std::string StateMachine< StateEnumT >::stateString | ( | ) | [inline] |
Definition at line 57 of file StateMachine.h.
std::string StateMachine< StateEnumT >::stateString | ( | StateEnumT | state | ) |
Definition at line 110 of file StateMachine.h.
unsigned StateMachine< StateEnumT >::timeSinceStateChange | ( | ) |
Milliseconds since last state change.
Definition at line 90 of file StateMachine.h.
unsigned StateMachine< StateEnumT >::m_HistoryLength [private] |
Definition at line 85 of file StateMachine.h.
unsigned StateMachine< StateEnumT >::m_LastStateChange [private] |
Definition at line 82 of file StateMachine.h.
std::string StateMachine< StateEnumT >::m_Name [private] |
Definition at line 80 of file StateMachine.h.
StateEnumT StateMachine< StateEnumT >::m_State [private] |
Definition at line 76 of file StateMachine.h.
std::deque<StateEnumT> StateMachine< StateEnumT >::m_StateHistory [private] |
Definition at line 84 of file StateMachine.h.
std::map< StateEnumT, std::string > StateMachine< StateEnumT >::m_StateNames [private] |
Definition at line 78 of file StateMachine.h.