#include <StateMachine.h>
|
template<class SM , class Data , void(SM::*)(const Data *, const bool, const bool) Func> |
void | registerState (unsigned int stateId) |
| register state processing functions from deriving class More...
|
|
- Transfer id of initial state in constructor of StateMachine
- Define state functions like: void <name>(const sm::EventData* data);
- call registerState in constructor which maps a state function to an state id
Definition at line 78 of file StateMachine.h.
◆ StateMachine()
sm::StateMachine::StateMachine |
( |
unsigned int |
initialStateId | ) |
|
|
explicit |
◆ ~StateMachine()
sm::StateMachine::~StateMachine |
( |
| ) |
|
|
virtual |
Definition at line 25 of file StateMachine.cpp.
std::map< unsigned int, sm::StateBase * > _stateActions
◆ getPrintableState()
virtual std::string sm::StateMachine::getPrintableState |
( |
unsigned int |
state | ) |
|
|
pure virtual |
◆ registerState()
template<class SM , class Data , void(SM::*)(const Data *, const bool, const bool) Func>
void sm::StateMachine::registerState |
( |
unsigned int |
stateId | ) |
|
|
inlineprotected |
register state processing functions from deriving class
Definition at line 96 of file StateMachine.h.
◆ update()
bool sm::StateMachine::update |
( |
| ) |
|
process events and update current state
Definition at line 33 of file StateMachine.cpp.
36 bool stateEntry =
false;
37 bool stateWasUpdated =
false;
45 data = e->getEventData();
64 itStateAction->second->invokeStateAction(
this,
72 ss <<
"You forgot to register state "
87 itStateAction->second->invokeStateAction(
this,
95 ss <<
"You forgot to register state "
103 stateWasUpdated =
true;
115 if (!stateWasUpdated)
#define LOG_STATEMACHINE_DEBUG(...)
std::queue< Event * > _events
virtual std::string getPrintableState(unsigned int state)=0
void exitMsg(const char *tag, const char *msg, const int line, const char *file)
Terminates the application with a message. No leak checking.
◆ _currentStateId
unsigned int sm::StateMachine::_currentStateId = 0 |
|
private |
◆ _stateActions
std::map<unsigned int, sm::StateBase*> sm::StateMachine::_stateActions |
|
private |
The documentation for this class was generated from the following files: