30 #error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
51 #ifndef ETL_FSM_INCLUDED
52 #define ETL_FSM_INCLUDED
62 #include "message_router.h"
76 #if !defined(ETL_FSM_STATE_ID_TYPE)
92 fsm_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
106 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:null state", ETL_FILE
"A"), file_name_, line_number_)
119 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state id", ETL_FILE
"B"), file_name_, line_number_)
132 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state list", ETL_FILE
"C"), file_name_, line_number_)
145 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state list order", ETL_FILE
"D"), file_name_, line_number_)
174 : state_id(state_id_),
175 p_context(ETL_NULLPTR)
187 inline etl::fsm& get_fsm_context()
const
197 virtual void on_exit_state() {}
200 void set_fsm_context(
etl::fsm& context)
202 p_context = &context;
226 fsm(etl::message_router_id_t
id)
235 template <
typename TSize>
238 state_list = p_states;
247 state_list[i]->set_fsm_context(*
this);
257 void start(
bool call_on_enter_state =
true)
260 if (p_state == ETL_NULLPTR)
262 p_state = state_list[0];
265 if (call_on_enter_state)
272 p_last_state = p_state;
273 next_state_id = p_state->on_enter_state();
274 p_state = state_list[next_state_id];
276 }
while (p_last_state != p_state);
295 if ((destination_router_id == get_message_router_id()) || (destination_router_id == imessage_router::ALL_MESSAGE_ROUTERS))
312 if (p_next_state != p_state)
316 p_state->on_exit_state();
317 p_state = p_next_state;
319 next_state_id = p_state->on_enter_state();
322 p_next_state = state_list[next_state_id];
324 }
while (p_next_state != p_state);
328 using imessage_router::accepts;
371 return p_state != ETL_NULLPTR;
378 void reset(
bool call_on_exit_state =
false)
380 if ((p_state != ETL_NULLPTR) && call_on_exit_state)
382 p_state->on_exit_state();
385 p_state = ETL_NULLPTR;
389 ETL_DEPRECATED
bool is_null_router() const ETL_OVERRIDE
395 bool is_producer() const ETL_OVERRIDE
401 bool is_consumer() const ETL_OVERRIDE
417 typename T1 = void,
typename T2 = void,
typename T3 = void,
typename T4 = void,
418 typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
419 typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
420 typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 =
void>
441 inline TContext& get_fsm_context()
const
443 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
455 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
456 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
457 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
458 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
459 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
460 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
461 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
462 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
463 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
464 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
465 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
466 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T12&
>(
message));
break;
467 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T13&
>(
message));
break;
468 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T14&
>(
message));
break;
469 case T15::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T15&
>(
message));
break;
470 case T16::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T16&
>(
message));
break;
471 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
482 typename T1,
typename T2,
typename T3,
typename T4,
483 typename T5,
typename T6,
typename T7,
typename T8,
484 typename T9,
typename T10,
typename T11,
typename T12,
485 typename T13,
typename T14,
typename T15>
486 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, void> :
public ifsm_state
506 inline TContext& get_fsm_context()
const
508 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
520 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
521 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
522 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
523 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
524 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
525 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
526 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
527 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
528 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
529 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
530 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
531 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T12&
>(
message));
break;
532 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T13&
>(
message));
break;
533 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T14&
>(
message));
break;
534 case T15::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T15&
>(
message));
break;
535 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
546 typename T1,
typename T2,
typename T3,
typename T4,
547 typename T5,
typename T6,
typename T7,
typename T8,
548 typename T9,
typename T10,
typename T11,
typename T12,
549 typename T13,
typename T14>
550 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, void, void> :
public ifsm_state
570 inline TContext& get_fsm_context()
const
572 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
584 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
585 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
586 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
587 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
588 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
589 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
590 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
591 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
592 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
593 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
594 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
595 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T12&
>(
message));
break;
596 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T13&
>(
message));
break;
597 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T14&
>(
message));
break;
598 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
609 typename T1,
typename T2,
typename T3,
typename T4,
610 typename T5,
typename T6,
typename T7,
typename T8,
611 typename T9,
typename T10,
typename T11,
typename T12,
613 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, void, void, void> :
public ifsm_state
633 inline TContext& get_fsm_context()
const
635 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
647 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
648 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
649 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
650 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
651 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
652 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
653 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
654 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
655 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
656 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
657 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
658 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T12&
>(
message));
break;
659 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T13&
>(
message));
break;
660 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
671 typename T1,
typename T2,
typename T3,
typename T4,
672 typename T5,
typename T6,
typename T7,
typename T8,
673 typename T9,
typename T10,
typename T11,
typename T12>
674 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, void, void, void, void> :
public ifsm_state
694 inline TContext& get_fsm_context()
const
696 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
708 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
709 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
710 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
711 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
712 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
713 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
714 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
715 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
716 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
717 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
718 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
719 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T12&
>(
message));
break;
720 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
731 typename T1,
typename T2,
typename T3,
typename T4,
732 typename T5,
typename T6,
typename T7,
typename T8,
733 typename T9,
typename T10,
typename T11>
734 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, void, void, void, void, void> :
public ifsm_state
754 inline TContext& get_fsm_context()
const
756 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
768 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
769 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
770 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
771 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
772 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
773 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
774 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
775 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
776 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
777 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
778 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T11&
>(
message));
break;
779 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
790 typename T1,
typename T2,
typename T3,
typename T4,
791 typename T5,
typename T6,
typename T7,
typename T8,
792 typename T9,
typename T10>
793 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, void, void, void, void, void, void> :
public ifsm_state
813 inline TContext& get_fsm_context()
const
815 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
827 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
828 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
829 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
830 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
831 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
832 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
833 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
834 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
835 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
836 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T10&
>(
message));
break;
837 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
848 typename T1,
typename T2,
typename T3,
typename T4,
849 typename T5,
typename T6,
typename T7,
typename T8,
851 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, void, void, void, void, void, void, void> :
public ifsm_state
871 inline TContext& get_fsm_context()
const
873 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
885 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
886 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
887 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
888 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
889 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
890 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
891 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
892 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
893 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T9&
>(
message));
break;
894 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
905 typename T1,
typename T2,
typename T3,
typename T4,
906 typename T5,
typename T6,
typename T7,
typename T8>
907 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, void, void, void, void, void, void, void, void> :
public ifsm_state
927 inline TContext& get_fsm_context()
const
929 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
941 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
942 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
943 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
944 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
945 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
946 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
947 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
948 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T8&
>(
message));
break;
949 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
960 typename T1,
typename T2,
typename T3,
typename T4,
961 typename T5,
typename T6,
typename T7>
962 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, void, void, void, void, void, void, void, void, void> :
public ifsm_state
982 inline TContext& get_fsm_context()
const
984 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
996 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
997 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
998 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
999 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
1000 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
1001 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
1002 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T7&
>(
message));
break;
1003 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1006 return new_state_id;
1014 typename T1,
typename T2,
typename T3,
typename T4,
1015 typename T5,
typename T6>
1016 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1022 STATE_ID = STATE_ID_
1036 inline TContext& get_fsm_context()
const
1038 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1050 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1051 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
1052 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
1053 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
1054 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
1055 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T6&
>(
message));
break;
1056 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1059 return new_state_id;
1067 typename T1,
typename T2,
typename T3,
typename T4,
1069 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1075 STATE_ID = STATE_ID_
1089 inline TContext& get_fsm_context()
const
1091 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1103 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1104 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
1105 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
1106 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
1107 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T5&
>(
message));
break;
1108 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1111 return new_state_id;
1119 typename T1,
typename T2,
typename T3,
typename T4>
1120 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, void, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1126 STATE_ID = STATE_ID_
1140 inline TContext& get_fsm_context()
const
1142 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1154 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1155 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
1156 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
1157 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T4&
>(
message));
break;
1158 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1161 return new_state_id;
1169 typename T1,
typename T2,
typename T3>
1170 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, void, void, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1176 STATE_ID = STATE_ID_
1190 inline TContext& get_fsm_context()
const
1192 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1204 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1205 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
1206 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T3&
>(
message));
break;
1207 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1210 return new_state_id;
1218 typename T1,
typename T2>
1219 class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, void, void, void, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1225 STATE_ID = STATE_ID_
1239 inline TContext& get_fsm_context()
const
1241 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1253 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1254 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T2&
>(
message));
break;
1255 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1258 return new_state_id;
1267 class fsm_state<TContext, TDerived, STATE_ID_, T1, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1273 STATE_ID = STATE_ID_
1287 inline TContext& get_fsm_context()
const
1289 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1301 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(source,
static_cast<const T1&
>(
message));
break;
1302 default: new_state_id =
static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
break;
1305 return new_state_id;
1312 template <
typename TContext,
typename TDerived, const etl::fsm_state_
id_t STATE_ID_>
1313 class fsm_state<TContext, TDerived, STATE_ID_, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> :
public ifsm_state
1319 STATE_ID = STATE_ID_
1333 inline TContext& get_fsm_context()
const
1335 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1341 return static_cast<TDerived*
>(
this)->on_event_unknown(source,
message);
Base exception class for FSM.
Definition: fsm.h:89
Exception for null state pointer.
Definition: fsm.h:102
Exception for invalid state id.
Definition: fsm.h:115
Exception for incompatible state list.
Definition: fsm.h:128
Exception for incompatible order state list.
Definition: fsm.h:141
The FSM class.
Definition: fsm.h:220
etl::fsm_state_id_t get_state_id() const
Gets the current state id.
Definition: fsm.h:342
void receive(const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the FSM.
Definition: fsm.h:284
fsm(etl::message_router_id_t id)
Constructor.
Definition: fsm.h:226
bool accepts(etl::message_id_t) const ETL_OVERRIDE
Definition: fsm.h:334
void reset(bool call_on_exit_state=false)
Definition: fsm.h:378
ifsm_state & get_state()
Gets a reference to the current state interface.
Definition: fsm.h:351
void set_states(etl::ifsm_state **p_states, TSize size)
Set the states for the FSM.
Definition: fsm.h:236
const ifsm_state & get_state() const
Gets a const reference to the current state interface.
Definition: fsm.h:360
void receive(etl::imessage_router &source, const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the FSM.
Definition: fsm.h:304
void start(bool call_on_enter_state=true)
Definition: fsm.h:257
void receive(imessage_router &source, etl::message_router_id_t destination_router_id, const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the FSM.
Definition: fsm.h:293
bool is_started() const
Checks if the FSM has been started.
Definition: fsm.h:369
Interface class for FSM states.
Definition: fsm.h:154
~ifsm_state()
Destructor.
Definition: fsm.h:182
etl::fsm_state_id_t get_state_id() const
Gets the id for this state.
Definition: fsm.h:163
ifsm_state(etl::fsm_state_id_t state_id_)
Constructor.
Definition: fsm.h:173
This is the base of all message routers.
Definition: message_router_generator.h:114
This router can be used as a sink for messages or a 'null source' router.
Definition: message_router_generator.h:194
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
Definition: exception.h:47
Defines a type that is as larger or larger than the specified type. Will return the specified type is...
Definition: largest_generator.h:352
Definition: absolute.h:37
uint_least8_t message_id_t
Allow alternative type for message id.
Definition: message_types.h:40
uint_least8_t fsm_state_id_t
Allow alternative type for state id.
Definition: fsm.h:73