From ba7e0d9e1e305ca93cd783d942baccaa859eaa64 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Fri, 23 Aug 2024 06:59:51 +0200 Subject: [PATCH] Eliminate "unhandled" special state --- include/cpp_event_framework/Statemachine.hxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/include/cpp_event_framework/Statemachine.hxx b/include/cpp_event_framework/Statemachine.hxx index 2dbbce6..810261d 100644 --- a/include/cpp_event_framework/Statemachine.hxx +++ b/include/cpp_event_framework/Statemachine.hxx @@ -191,6 +191,12 @@ public: } } + /** + * @brief Construct a new Statemachine Transition object + * Use Statemachine::UnhandledEvent() instead + * + */ + constexpr Transition() noexcept = default; /** * @brief Construct a new Statemachine Transition object * Use Statemachine::TransitionTo() instead @@ -508,9 +514,9 @@ public: } s = s->parent_; - } while ((transition.target_ == &kUnhandled) && (s != nullptr)); + } while ((transition.target_ == nullptr) && (s != nullptr)); - if ((transition.target_ != &kUnhandled)) + if ((transition.target_ != nullptr)) { if (transition.target_ != &kNone) { @@ -592,7 +598,7 @@ public: */ static inline Transition UnhandledEvent() { - return Transition(kUnhandled); + return Transition(); } /** @@ -674,10 +680,6 @@ public: * @brief No transition */ static const State kNone; - /** - * @brief Unhandled transition - */ - static const State kUnhandled; /** * @brief Event deferral request */ @@ -832,9 +834,6 @@ template const typename Statemachine::State Statemachine::kNone = typename Statemachine::State("None", nullptr); template -const typename Statemachine::State Statemachine::kUnhandled = - typename Statemachine::State("Unhandled", nullptr); -template const typename Statemachine::State Statemachine::kInTransition = typename Statemachine::State("InTransition", nullptr); template