30#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
51#ifndef ETL_FSM_INCLUDED
52#define ETL_FSM_INCLUDED
60#include "message_router.h"
74#if !defined(ETL_FSM_STATE_ID_TYPE)
83#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION)
88 typename,
typename,
typename,
typename,
89 typename,
typename,
typename,
typename,
90 typename,
typename,
typename,
typename,
91 typename,
typename,
typename,
typename>
102 fsm_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
116 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:null state", ETL_FSM_FILE_ID
"A"), file_name_, line_number_)
129 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state id", ETL_FSM_FILE_ID
"B"), file_name_, line_number_)
142 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state list", ETL_FSM_FILE_ID
"C"), file_name_, line_number_)
155 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:state list order", ETL_FSM_FILE_ID
"D"), file_name_, line_number_)
167 :
etl::fsm_exception(ETL_ERROR_TEXT(
"fsm:change in composite state forbidden", ETL_FSM_FILE_ID
"E"), file_name_, line_number_)
172 namespace private_fsm
174 template <
typename T =
void>
184 static ETL_CONSTANT
fsm_state_id_t Pass_To_Parent = No_State_Change - 1U;
187 template <
typename T>
190 template <
typename T>
208#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION)
213 typename,
typename,
typename,
typename,
214 typename,
typename,
typename,
typename,
215 typename,
typename,
typename,
typename,
216 typename,
typename,
typename,
typename>
235 state.p_parent =
this;
237 if (p_default_child == ETL_NULLPTR)
239 p_active_child = &state;
240 p_default_child = &state;
248 template <
typename TSize>
251 p_active_child = ETL_NULLPTR;
252 p_default_child = ETL_NULLPTR;
254 for (TSize i = 0; i < size; ++i)
267 : state_id(state_id_),
268 p_context(ETL_NULLPTR),
269 p_parent(ETL_NULLPTR),
270 p_active_child(ETL_NULLPTR),
271 p_default_child(ETL_NULLPTR)
292 virtual fsm_state_id_t on_enter_state() {
return No_State_Change; }
293 virtual void on_exit_state() {}
296 void set_fsm_context(
etl::fsm& context)
298 p_context = &context;
329 using imessage_router::receive;
334 fsm(etl::message_router_id_t
id)
336 , p_state(ETL_NULLPTR)
337 , state_list(ETL_NULLPTR)
338 , number_of_states(0U)
345 template <
typename TSize>
348 state_list = p_states;
358 state_list[i]->set_fsm_context(*
this);
368 virtual void start(
bool call_on_enter_state =
true)
371 if (p_state == ETL_NULLPTR)
373 p_state = state_list[0];
376 if (call_on_enter_state)
383 p_last_state = p_state;
384 next_state_id = p_state->on_enter_state();
385 if (next_state_id != ifsm_state::No_State_Change)
388 p_state = state_list[next_state_id];
390 }
while (p_last_state != p_state);
402 if (have_changed_state(next_state_id))
409 p_state->on_exit_state();
410 p_state = p_next_state;
412 next_state_id = p_state->on_enter_state();
414 if (have_changed_state(next_state_id))
417 p_next_state = state_list[next_state_id];
419 }
while (p_next_state != p_state);
423 using imessage_router::accepts;
466 return p_state != ETL_NULLPTR;
473 virtual void reset(
bool call_on_exit_state =
false)
475 if ((p_state != ETL_NULLPTR) && call_on_exit_state)
477 p_state->on_exit_state();
480 p_state = ETL_NULLPTR;
484 ETL_DEPRECATED
bool is_null_router() const ETL_OVERRIDE
490 bool is_producer() const ETL_OVERRIDE
496 bool is_consumer() const ETL_OVERRIDE
507 (next_state_id != ifsm_state::No_State_Change);
518#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION)
522 template <
typename TContext,
typename TDerived,
etl::fsm_state_id_t STATE_ID_,
typename... TMessageTypes>
523 class fsm_state :
public ifsm_state
540 TContext& get_fsm_context()
const
542 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
559 const bool was_handled = (process_event_type<TMessageTypes>(message, new_state_id) || ...);
561 if (!was_handled || (new_state_id == Pass_To_Parent))
563 new_state_id = (p_parent !=
nullptr) ? p_parent->process_event(message) :
static_cast<TDerived*
>(
this)->on_event_unknown(message);
570 template <
typename TMessage>
573 if (TMessage::ID == msg.get_message_id())
575 state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const TMessage&
>(msg));
586 template <
typename TContext,
typename TDerived,
etl::fsm_state_id_t STATE_ID_,
typename... TMessageTypes>
587 ETL_CONSTANT
etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, TMessageTypes...>::STATE_ID;
597 typename T1 = void,
typename T2 = void,
typename T3 = void,
typename T4 = void,
598 typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
599 typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
600 typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 =
void>
618 TContext& get_fsm_context()
const
620 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
632 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
633 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
634 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
635 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
636 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
637 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
638 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
639 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
640 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
641 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
642 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
643 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T12&
>(
message));
break;
644 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T13&
>(
message));
break;
645 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T14&
>(
message));
break;
646 case T15::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T15&
>(
message));
break;
647 case T16::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T16&
>(
message));
break;
648 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
651 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
659 typename T1,
typename T2,
typename T3,
typename T4,
660 typename T5,
typename T6,
typename T7,
typename T8,
661 typename T9,
typename T10,
typename T11,
typename T12,
662 typename T13,
typename T14,
typename T15>
663 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
680 TContext& get_fsm_context()
const
682 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
694 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
695 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
696 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
697 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
698 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
699 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
700 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
701 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
702 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
703 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
704 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
705 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T12&
>(
message));
break;
706 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T13&
>(
message));
break;
707 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T14&
>(
message));
break;
708 case T15::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T15&
>(
message));
break;
709 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
712 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
720 typename T1,
typename T2,
typename T3,
typename T4,
721 typename T5,
typename T6,
typename T7,
typename T8,
722 typename T9,
typename T10,
typename T11,
typename T12,
723 typename T13,
typename T14>
724 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
741 TContext& get_fsm_context()
const
743 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
755 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
756 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
757 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
758 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
759 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
760 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
761 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
762 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
763 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
764 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
765 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
766 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T12&
>(
message));
break;
767 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T13&
>(
message));
break;
768 case T14::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T14&
>(
message));
break;
769 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
772 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
780 typename T1,
typename T2,
typename T3,
typename T4,
781 typename T5,
typename T6,
typename T7,
typename T8,
782 typename T9,
typename T10,
typename T11,
typename T12,
784 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
801 TContext& get_fsm_context()
const
803 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
815 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
816 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
817 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
818 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
819 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
820 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
821 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
822 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
823 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
824 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
825 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
826 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T12&
>(
message));
break;
827 case T13::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T13&
>(
message));
break;
828 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
831 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
839 typename T1,
typename T2,
typename T3,
typename T4,
840 typename T5,
typename T6,
typename T7,
typename T8,
841 typename T9,
typename T10,
typename T11,
typename T12>
842 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
859 TContext& get_fsm_context()
const
861 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
873 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
874 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
875 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
876 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
877 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
878 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
879 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
880 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
881 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
882 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
883 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
884 case T12::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T12&
>(
message));
break;
885 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
888 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
896 typename T1,
typename T2,
typename T3,
typename T4,
897 typename T5,
typename T6,
typename T7,
typename T8,
898 typename T9,
typename T10,
typename T11>
899 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
916 TContext& get_fsm_context()
const
918 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
930 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
931 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
932 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
933 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
934 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
935 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
936 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
937 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
938 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
939 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
940 case T11::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T11&
>(
message));
break;
941 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
944 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
952 typename T1,
typename T2,
typename T3,
typename T4,
953 typename T5,
typename T6,
typename T7,
typename T8,
954 typename T9,
typename T10>
955 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
972 TContext& get_fsm_context()
const
974 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
986 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
987 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
988 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
989 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
990 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
991 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
992 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
993 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
994 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
995 case T10::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T10&
>(
message));
break;
996 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
999 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1007 typename T1,
typename T2,
typename T3,
typename T4,
1008 typename T5,
typename T6,
typename T7,
typename T8,
1010 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
1027 TContext& get_fsm_context()
const
1029 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1041 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1042 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1043 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1044 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1045 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
1046 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
1047 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
1048 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
1049 case T9::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T9&
>(
message));
break;
1050 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1053 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1061 typename T1,
typename T2,
typename T3,
typename T4,
1062 typename T5,
typename T6,
typename T7,
typename T8>
1063 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
1080 TContext& get_fsm_context()
const
1082 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1094 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1095 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1096 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1097 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1098 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
1099 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
1100 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
1101 case T8::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T8&
>(
message));
break;
1102 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1105 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1113 typename T1,
typename T2,
typename T3,
typename T4,
1114 typename T5,
typename T6,
typename T7>
1115 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
1132 TContext& get_fsm_context()
const
1134 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1146 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1147 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1148 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1149 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1150 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
1151 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
1152 case T7::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T7&
>(
message));
break;
1153 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1156 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1164 typename T1,
typename T2,
typename T3,
typename T4,
1165 typename T5,
typename T6>
1166 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
1183 TContext& get_fsm_context()
const
1185 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1197 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1198 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1199 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1200 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1201 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
1202 case T6::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T6&
>(
message));
break;
1203 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1206 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1214 typename T1,
typename T2,
typename T3,
typename T4,
1216 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
1233 TContext& get_fsm_context()
const
1235 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1247 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1248 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1249 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1250 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1251 case T5::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T5&
>(
message));
break;
1252 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1255 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1263 typename T1,
typename T2,
typename T3,
typename T4>
1264 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
1281 TContext& get_fsm_context()
const
1283 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1295 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1296 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1297 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1298 case T4::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T4&
>(
message));
break;
1299 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1302 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1310 typename T1,
typename T2,
typename T3>
1311 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
1328 TContext& get_fsm_context()
const
1330 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1342 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1343 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1344 case T3::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T3&
>(
message));
break;
1345 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1348 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1356 typename T1,
typename T2>
1357 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
1374 TContext& get_fsm_context()
const
1376 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1388 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1389 case T2::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T2&
>(
message));
break;
1390 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1393 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1402 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
1419 TContext& get_fsm_context()
const
1421 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1433 case T1::ID: new_state_id =
static_cast<TDerived*
>(
this)->on_event(
static_cast<const T1&
>(
message));
break;
1434 default: new_state_id = p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
break;
1437 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(
message) : No_State_Change);
1444 template <
typename TContext,
typename TDerived, etl::fsm_state_
id_t STATE_ID_>
1445 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
1462 TContext& get_fsm_context()
const
1464 return static_cast<TContext&
>(ifsm_state::get_fsm_context());
1470 return p_parent ? p_parent->process_event(
message) :
static_cast<TDerived*
>(
this)->on_event_unknown(
message);
1475 typename T1,
typename T2,
typename T3,
typename T4,
1476 typename T5,
typename T6,
typename T7,
typename T8,
1477 typename T9,
typename T10,
typename T11,
typename T12,
1478 typename T13,
typename T14,
typename T15,
typename T16>
1479 ETL_CONSTANT
etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::STATE_ID;
Base exception class for FSM.
Definition: fsm.h:99
Exception for null state pointer.
Definition: fsm.h:112
Exception for forbidden state chages.
Definition: fsm.h:164
Exception for invalid state id.
Definition: fsm.h:125
Exception for incompatible state list.
Definition: fsm.h:138
Exception for incompatible order state list.
Definition: fsm.h:151
The FSM class.
Definition: fsm.h:325
etl::fsm_state_id_t get_state_id() const
Gets the current state id.
Definition: fsm.h:437
void receive(const etl::imessage &message) ETL_OVERRIDE
Top level message handler for the FSM.
Definition: fsm.h:398
virtual void start(bool call_on_enter_state=true)
Definition: fsm.h:368
fsm(etl::message_router_id_t id)
Constructor.
Definition: fsm.h:334
virtual void reset(bool call_on_exit_state=false)
Definition: fsm.h:473
bool accepts(etl::message_id_t) const ETL_OVERRIDE
Definition: fsm.h:429
void set_states(etl::ifsm_state **p_states, TSize size)
Set the states for the FSM.
Definition: fsm.h:346
const ifsm_state & get_state() const
Gets a const reference to the current state interface.
Definition: fsm.h:455
ifsm_state & get_state()
Gets a reference to the current state interface.
Definition: fsm.h:446
bool is_started() const
Checks if the FSM has been started.
Definition: fsm.h:464
Interface class for FSM states.
Definition: fsm.h:198
void add_child_state(etl::ifsm_state &state)
Definition: fsm.h:232
void set_child_states(etl::ifsm_state **state_list, TSize size)
Definition: fsm.h:249
etl::fsm_state_id_t get_state_id() const
Gets the id for this state.
Definition: fsm.h:223
ifsm_state(etl::fsm_state_id_t state_id_)
Constructor.
Definition: fsm.h:266
virtual ~ifsm_state()
Destructor.
Definition: fsm.h:278
This is the base of all message routers.
Definition: message_router_generator.h:121
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
Definition: exception.h:47
Definition: integral_limits.h:468
Defines a type that is as larger or larger than the specified type. Will return the specified type is...
Definition: largest_generator.h:352
bitset_ext
Definition: absolute.h:38
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:75