diff --git a/library.properties b/library.properties index 8096d610..f9d0fce8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=10.8.1 +version=10.8.2 author= John Wellbelove maintainer=John Wellbelove sentence=A C++ template library tailored for embedded systems. diff --git a/src/fsm.h b/src/fsm.h index 4ccf9904..665f7666 100644 --- a/src/fsm.h +++ b/src/fsm.h @@ -144,7 +144,7 @@ namespace etl public: /// Allows ifsm_state functions to be private. - friend class fsm_helper; + friend class etl::fsm; //******************************************* /// Gets the id for this state. @@ -195,46 +195,10 @@ namespace etl ifsm_state& operator =(const ifsm_state&); }; - //*************************************************************************** - /// Helper class for FSM. - /// Allows ifsm_state functions to be private. - //*************************************************************************** - class fsm_helper - { - public: - - //******************************************* - inline void set_fsm_context(etl::ifsm_state& state, - etl::fsm& context) - { - state.set_fsm_context(context); - } - - //******************************************* - inline fsm_state_id_t process_event(etl::ifsm_state& state, - etl::imessage_router& source, - const etl::imessage& message) - { - return state.process_event(source, message); - } - - //******************************************* - inline fsm_state_id_t on_enter_state(etl::ifsm_state& state) - { - return state.on_enter_state(); - } - - //******************************************* - inline void on_exit_state(etl::ifsm_state& state) - { - state.on_exit_state(); - } - }; - //*************************************************************************** /// The FSM class. //*************************************************************************** - class fsm : public etl::imessage_router, protected etl::fsm_helper + class fsm : public etl::imessage_router { public: @@ -261,7 +225,7 @@ namespace etl for (etl::fsm_state_id_t i = 0; i < size; ++i) { ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception)); - fsm_helper::set_fsm_context(*state_list[i], *this); + state_list[i]->set_fsm_context(*this); } } @@ -278,7 +242,7 @@ namespace etl p_state = state_list[0]; ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - fsm_helper::on_enter_state(*p_state); + p_state->on_enter_state(); } } @@ -296,7 +260,7 @@ namespace etl //******************************************* void receive(etl::imessage_router& source, const etl::imessage& message) { - etl::fsm_state_id_t next_state_id = fsm_helper::process_event(*p_state, source, message); + etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); etl::ifsm_state* p_next_state = state_list[next_state_id]; @@ -306,10 +270,10 @@ namespace etl { do { - fsm_helper::on_exit_state(*p_state); + p_state->on_exit_state(); p_state = p_next_state; - next_state_id = fsm_helper::on_enter_state(*p_state); + next_state_id = p_state->on_enter_state(); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); p_next_state = state_list[next_state_id]; @@ -379,7 +343,6 @@ namespace etl etl::fsm_state_id_t number_of_states; ///< The number of states. }; - //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** diff --git a/src/fsm_generator.h b/src/fsm_generator.h index 50c67cad..20c06789 100644 --- a/src/fsm_generator.h +++ b/src/fsm_generator.h @@ -156,7 +156,7 @@ namespace etl public: /// Allows ifsm_state functions to be private. - friend class fsm_helper; + friend class etl::fsm; //******************************************* /// Gets the id for this state. @@ -207,46 +207,10 @@ namespace etl ifsm_state& operator =(const ifsm_state&); }; - //*************************************************************************** - /// Helper class for FSM. - /// Allows ifsm_state functions to be private. - //*************************************************************************** - class fsm_helper - { - public: - - //******************************************* - inline void set_fsm_context(etl::ifsm_state& state, - etl::fsm& context) - { - state.set_fsm_context(context); - } - - //******************************************* - inline fsm_state_id_t process_event(etl::ifsm_state& state, - etl::imessage_router& source, - const etl::imessage& message) - { - return state.process_event(source, message); - } - - //******************************************* - inline fsm_state_id_t on_enter_state(etl::ifsm_state& state) - { - return state.on_enter_state(); - } - - //******************************************* - inline void on_exit_state(etl::ifsm_state& state) - { - state.on_exit_state(); - } - }; - //*************************************************************************** /// The FSM class. //*************************************************************************** - class fsm : public etl::imessage_router, protected etl::fsm_helper + class fsm : public etl::imessage_router { public: @@ -273,7 +237,7 @@ namespace etl for (etl::fsm_state_id_t i = 0; i < size; ++i) { ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception)); - fsm_helper::set_fsm_context(*state_list[i], *this); + state_list[i]->set_fsm_context(*this); } } @@ -290,7 +254,7 @@ namespace etl p_state = state_list[0]; ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); - fsm_helper::on_enter_state(*p_state); + p_state->on_enter_state(); } } @@ -308,7 +272,7 @@ namespace etl //******************************************* void receive(etl::imessage_router& source, const etl::imessage& message) { - etl::fsm_state_id_t next_state_id = fsm_helper::process_event(*p_state, source, message); + etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); etl::ifsm_state* p_next_state = state_list[next_state_id]; @@ -318,10 +282,10 @@ namespace etl { do { - fsm_helper::on_exit_state(*p_state); + p_state->on_exit_state(); p_state = p_next_state; - next_state_id = fsm_helper::on_enter_state(*p_state); + next_state_id = p_state->on_enter_state(); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); p_next_state = state_list[next_state_id]; @@ -393,7 +357,6 @@ namespace etl /*[[[cog import cog - cog.outl("") ################################################ # The first definition for all of the events. ################################################ diff --git a/src/pool.h b/src/pool.h index ae7cc334..a945767a 100644 --- a/src/pool.h +++ b/src/pool.h @@ -399,7 +399,6 @@ namespace etl //************************************************************************* /// Allocate an object from the pool. - /// Uses the default constructor. /// If asserts or exceptions are enabled and there are no more free items an /// etl::pool_no_allocation if thrown, otherwise a nullptr is returned. /// Static asserts if the specified type is too large for the pool. diff --git a/support/Release notes.txt b/support/Release notes.txt index 8a1feeec..9113d975 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,7 +1,15 @@ +10.8.2 + +Finite State Machine + Tidied code. Removed unecessary class. + +=============================================================================== 10.8.1 + Pool Changed alignof to etl::alignment_of +=============================================================================== 10.8.0 Added etl::variant_pool as a replacement for etl::factory. diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 604e2e12..7eb27ba0 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -19,7 +19,7 @@ Win32Proj unittest etl - 10.0.15063.0 + 10.0.16299.0 @@ -77,6 +77,7 @@ ../../unittest-cpp/UnitTest++/;../../src;../../src/c;../../test + false Console