Skip to content

Commit

Permalink
Eliminate "unhandled" special state
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Aug 23, 2024
1 parent 423a780 commit ba7e0d9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions include/cpp_event_framework/Statemachine.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -592,7 +598,7 @@ public:
*/
static inline Transition UnhandledEvent()
{
return Transition(kUnhandled);
return Transition();
}

/**
Expand Down Expand Up @@ -674,10 +680,6 @@ public:
* @brief No transition
*/
static const State kNone;
/**
* @brief Unhandled transition
*/
static const State kUnhandled;
/**
* @brief Event deferral request
*/
Expand Down Expand Up @@ -832,9 +834,6 @@ template <typename Impl, typename Event, PolymorphicAllocatorProvider Allocator>
const typename Statemachine<Impl, Event, Allocator>::State Statemachine<Impl, Event, Allocator>::kNone =
typename Statemachine<Impl, Event, Allocator>::State("None", nullptr);
template <typename Impl, typename Event, PolymorphicAllocatorProvider Allocator>
const typename Statemachine<Impl, Event, Allocator>::State Statemachine<Impl, Event, Allocator>::kUnhandled =
typename Statemachine<Impl, Event, Allocator>::State("Unhandled", nullptr);
template <typename Impl, typename Event, PolymorphicAllocatorProvider Allocator>
const typename Statemachine<Impl, Event, Allocator>::State Statemachine<Impl, Event, Allocator>::kInTransition =
typename Statemachine<Impl, Event, Allocator>::State("InTransition", nullptr);
template <typename Impl, typename Event, PolymorphicAllocatorProvider Allocator>
Expand Down

0 comments on commit ba7e0d9

Please sign in to comment.