From 7eb0077a4858da914e23ccca6810deb67eec7ea8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 8 Sep 2018 15:57:37 +0100 Subject: [PATCH] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/state_chart.h --- include/etl/state_chart.h | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/include/etl/state_chart.h b/include/etl/state_chart.h index 692c6322..1657e174 100644 --- a/include/etl/state_chart.h +++ b/include/etl/state_chart.h @@ -48,12 +48,29 @@ namespace etl typedef uint32_t state_id_t; typedef uint32_t event_id_t; - virtual state_id_t get_state_id() const = 0; virtual void process_event(const event_id_t event_id) = 0; + //************************************************************************* + /// Gets the current state id. + /// \return The current state id. + //************************************************************************* + state_id_t get_state_id() const + { + return current_state_id; + } + virtual ~istate_chart() { } + + protected: + + istate_chart(state_id_t current_state_id_) + : current_state_id(current_state_id_) + { + } + + state_id_t current_state_id; ///< The current state id. }; //*************************************************************************** @@ -75,7 +92,7 @@ namespace etl void (TObject::* const action_)() = nullptr, bool (TObject::* const guard_)() = nullptr) : event_id(event_id_), - current_state_id(current_state_id_), + current_state_id(current_state_id_), next_state_id(next_state_id_), action(action_), guard(guard_) @@ -119,8 +136,8 @@ namespace etl state_chart(TObject& object_, const etl::array& transition_table_, const state_id_t state_id_) - : object(object_), - current_state_id(state_id_), + : istate_chart(state_id_), + object(object_), transition_table(transition_table_.begin(), transition_table_.end()) { } @@ -154,15 +171,6 @@ namespace etl return object; } - //************************************************************************* - /// Gets the current state id. - /// \return The current state id. - //************************************************************************* - state_id_t get_state_id() const - { - return current_state_id; - } - //************************************************************************* /// Gets the current state id. /// \return The current state id. @@ -280,7 +288,6 @@ namespace etl state_chart& operator =(const state_chart&) ETL_DELETE; TObject& object; ///< The object that supplies guard and action member functions. - state_id_t current_state_id; ///< The current state id. const etl::array_view transition_table; ///< The table of transitions. etl::array_view state_table; ///< The table of states. };