6 int State::_id_counter = 0;
14 _transitions.push_back(
Transition(event_name, from, to));
15 to._state_machine_ptr =
this;
16 from._state_machine_ptr =
this;
21 for (
auto transition : _transitions ) {
22 watch(transition.event_name(), [
this, transition](
Event& e) {
23 if ( _current->
id() == transition.from().id() ) {
25 _current = &transition.to();
36 if ( _initial == NULL ) {
37 throw(
Exception(
"State machine started without an initial state (call set_initial(...) first)"));
void start()
Do not override init() for a state machine.
void update()
Do not override init() for a state machine.
StateMachine & add_transition(std::string event_name, State &from, State &to)
virtual void entry(const Event &e)=0
void init()
Do not override init() for a state machine.
StateMachine & set_initial(State &s)
Events that can be emitted, watched, and responded to with event handlers.
States for finite state machines (FSM)
States for the StateMachine class.
virtual void exit(const Event &e)=0
void stop()
Do not override init() for a state machine.
An exception class for Elma.
A finite state machine class.