From 8fd774b8c1afcbbd8ce0828a065e8912426fb6ec Mon Sep 17 00:00:00 2001 From: Christian Granzin Date: Tue, 16 Jun 2026 22:35:09 +0200 Subject: [PATCH] feat(backmp11)!: dedicated process_result enum --- .../ROOT/attachments/backmp11/BackAdapter.cpp | 3 +- .../ROOT/attachments/backmp11/Logger.cpp | 11 ++--- doc/modules/ROOT/pages/backmp11-back-end.adoc | 2 +- doc/modules/ROOT/pages/version-history.adoc | 6 +-- include/boost/msm/backmp11/common_types.hpp | 49 +++++++++++++++++-- include/boost/msm/backmp11/detail/common.hpp | 49 +++---------------- .../backmp11/detail/event_pool_processor.hpp | 4 +- .../backmp11/detail/favor_runtime_speed.hpp | 14 +++--- .../msm/backmp11/detail/metafunctions.hpp | 4 ++ .../msm/backmp11/detail/transition_table.hpp | 43 ++++++++++------ .../boost/msm/backmp11/favor_compile_time.hpp | 18 +++---- include/boost/msm/backmp11/state_machine.hpp | 19 +++---- include/boost/msm/common.hpp | 6 --- test/Backmp11Observer.cpp | 20 ++++---- test/Backmp11Transitions.cpp | 4 +- 15 files changed, 137 insertions(+), 115 deletions(-) diff --git a/doc/modules/ROOT/attachments/backmp11/BackAdapter.cpp b/doc/modules/ROOT/attachments/backmp11/BackAdapter.cpp index e9dcc5ec..d006d63a 100644 --- a/doc/modules/ROOT/attachments/backmp11/BackAdapter.cpp +++ b/doc/modules/ROOT/attachments/backmp11/BackAdapter.cpp @@ -181,7 +181,8 @@ class back_adapter : public boost::msm::backmp11::state_machine< { try { - return Base::process_event(event); + return static_cast( + Base::process_event(event)); } catch (std::exception& e) { diff --git a/doc/modules/ROOT/attachments/backmp11/Logger.cpp b/doc/modules/ROOT/attachments/backmp11/Logger.cpp index a8683361..8c642214 100644 --- a/doc/modules/ROOT/attachments/backmp11/Logger.cpp +++ b/doc/modules/ROOT/attachments/backmp11/Logger.cpp @@ -128,16 +128,15 @@ class Logger : public back::default_observer static std::string to_string(process_result result) { - using Enum = boost::msm::back::HandledEnum; switch (result) { - case Enum::HANDLED_FALSE: + case process_result::discarded: return "discarded"; - case Enum::HANDLED_TRUE: - return "handled"; - case Enum::HANDLED_GUARD_REJECT: + case process_result::consumed: + return "consumed"; + case process_result::rejected: return "rejected"; - case Enum::HANDLED_DEFERRED: + case process_result::deferred: return "deferred"; default: return {}; diff --git a/doc/modules/ROOT/pages/backmp11-back-end.adoc b/doc/modules/ROOT/pages/backmp11-back-end.adoc index b2c0f7ab..018bf005 100644 --- a/doc/modules/ROOT/pages/backmp11-back-end.adoc +++ b/doc/modules/ROOT/pages/backmp11-back-end.adoc @@ -307,7 +307,7 @@ Calling `start(...)` on an active or `stop(...)` on an inactive state machine ha == Handling events -Use xref:reference:boost/msm/backmp11/state_machine/process_event.adoc[`process_result state_machine::process_event(const Event&)`] to start processing an event while the state machine is idle. +Use xref:reference:boost/msm/backmp11/state_machine/process_event.adoc[`process_result state_machine::process_event(const Event&)`] to trigger processing an event while the state machine is idle. The xref:reference:boost/msm/backmp11/process_result.adoc[`process_result`] enum returns the result of the processing attempt. You can enqueue an event to the event pool for subsequent processing in an action with xref:reference:boost/msm/backmp11/state_machine/enqueue_event.adoc[`void state_machine::enqueue_event(const Event&)`]. The enqueued event will be processed immediately after the current event has finished processing. If an event is enqueued while the state machine is idle, you can explicitly request the state machine to process events from its event pool with xref:reference:boost/msm/backmp11/state_machine/process_event_pool.adoc[`size_t process_event_pool(size_t max_events = SIZE_MAX)`]. diff --git a/doc/modules/ROOT/pages/version-history.adoc b/doc/modules/ROOT/pages/version-history.adoc index edaad19b..eb2a703d 100644 --- a/doc/modules/ROOT/pages/version-history.adoc +++ b/doc/modules/ROOT/pages/version-history.adoc @@ -10,15 +10,15 @@ ** Ensure basic exception guarantee and propagate exceptions to the caller (https://github.com/boostorg/msm/issues/221[#221]) ** Provide a reflection API and serialization support for Boost.Serialization, Boost.JSON and nlohmann/json (https://github.com/boostorg/msm/issues/197[#197]) ** Configurable event pool and inline storage (https://github.com/boostorg/msm/issues/239[#239]) +** API reference and examples are now available * Bug fixes (`backmp11`): ** State machine processes events although it is not running (https://github.com/boostorg/msm/issues/198[#198]) * **Breaking changes (`backmp11`)**: ** Events in `process_event(...)` are not enqueued automatically anymore to reduce memory footprint, use `enqueue_event(...)` in actions (https://github.com/boostorg/msm/issues/178[#178]) ** The back-end does not forward constructor arguments to the front-end anymore, it must be default-constructible. To use custom constructors, define them in the back-end (https://github.com/boostorg/msm/issues/232[#232]) ** The deprecated APIs `process_queued_events()` and `process_single_queued_event()` are removed, use `process_event_pool(...)` instead -** The default active state switch policy is set to "after source exit" in compliance to the UML specification. The other options are not UML-compliant and will be removed in version 1.93 (https://github.com/boostorg/msm/issues/222[#222]) -* Documentation: -** API reference is now generated from source with MrDocs +** The default active state switch policy is set to "after source exit" in compliance to the UML specification. The other options are not UML-compliant and will be removed (https://github.com/boostorg/msm/issues/222[#222]) +** The back-end uses its own `process_result` type with new enum values instead of aliasing the enum of the `back` namespace. The old enum values are deprecated (https://github.com/boostorg/msm/issues/242[#242]) and will be removed == Boost 1.91 diff --git a/include/boost/msm/backmp11/common_types.hpp b/include/boost/msm/backmp11/common_types.hpp index 704e26cb..06350f56 100644 --- a/include/boost/msm/backmp11/common_types.hpp +++ b/include/boost/msm/backmp11/common_types.hpp @@ -15,8 +15,6 @@ #include #include -#include - namespace boost::msm::backmp11 { @@ -32,7 +30,52 @@ enum class machine_state : uint8_t }; /// Return type of @ref state_machine::process_event calls. -using process_result = back::HandledEnum; +enum class process_result : uint8_t +{ + /// No matching transition found, or the state machine was not ready. + /// + /// The state machine is not ready when stopped or + /// already processing another event. + discarded = 0, + /// The event triggered at least one transition. + consumed = 1, + /// All matching guards evaluated to false, no transition fired. + rejected = 2, + /// The event will be re-evaluated after the next transition. + deferred = 4, + + /// Deprecated enum values. + HANDLED_FALSE [[deprecated("Use discarded")]] = 0, + HANDLED_TRUE [[deprecated("Use accepted")]] = 1, + HANDLED_GUARD_REJECT [[deprecated("Use rejected")]] = 2, + HANDLED_DEFERRED [[deprecated("Use deferred")]] = 4 +}; + +constexpr process_result operator|(process_result lhs, process_result rhs) +{ + return static_cast( + static_cast>(lhs) | + static_cast>(rhs)); +} + +constexpr process_result& operator|=(process_result& lhs, process_result rhs) +{ + lhs = lhs | rhs; + return lhs; +} + +constexpr process_result operator&(process_result lhs, process_result rhs) +{ + return static_cast( + static_cast>(lhs) & + static_cast>(rhs)); +} + +constexpr process_result& operator&=(process_result& lhs, process_result rhs) +{ + lhs = lhs & rhs; + return lhs; +} /// Default event when starting a state machine (see @ref state_machine::start). struct starting {}; diff --git a/include/boost/msm/backmp11/detail/common.hpp b/include/boost/msm/backmp11/detail/common.hpp index 53e4cc96..ae802122 100644 --- a/include/boost/msm/backmp11/detail/common.hpp +++ b/include/boost/msm/backmp11/detail/common.hpp @@ -12,46 +12,8 @@ #ifndef BOOST_MSM_BACKMP11_DETAIL_COMMON_HPP #define BOOST_MSM_BACKMP11_DETAIL_COMMON_HPP -#include - #include -namespace boost::msm::back -{ - -// Bitwise operations for process_result. -// Defined in this header instead of back because type_traits are C++11. -// Defined in the back namespace because the operations have to be in the -// same namespace as HandledEnum. - -constexpr HandledEnum operator|(HandledEnum lhs, HandledEnum rhs) -{ - return static_cast( - static_cast>(lhs) | - static_cast>(rhs)); -} - -constexpr HandledEnum& operator|=(HandledEnum& lhs, HandledEnum rhs) -{ - lhs = lhs | rhs; - return lhs; -} - -constexpr HandledEnum operator&(HandledEnum lhs, HandledEnum rhs) -{ - return static_cast( - static_cast>(lhs) & - static_cast>(rhs)); -} - -constexpr HandledEnum& operator&=(HandledEnum& lhs, HandledEnum rhs) -{ - lhs = lhs & rhs; - return lhs; -} - -} // namespace boost::msm::back - namespace boost::msm::backmp11::detail { @@ -81,11 +43,14 @@ enum class process_info event_pool }; -using process_result = back::HandledEnum; - // Bitmask for process result checks. -static constexpr process_result handled_true_or_deferred = - process_result::HANDLED_TRUE | process_result::HANDLED_DEFERRED; +constexpr process_result consumed_or_deferred = + process_result::consumed | process_result::deferred; + +constexpr bool any(process_result result) +{ + return result != process_result::discarded; +} template struct compile_policy_impl; diff --git a/include/boost/msm/backmp11/detail/event_pool_processor.hpp b/include/boost/msm/backmp11/detail/event_pool_processor.hpp index fc5f63e1..820fbfda 100644 --- a/include/boost/msm/backmp11/detail/event_pool_processor.hpp +++ b/include/boost/msm/backmp11/detail/event_pool_processor.hpp @@ -158,7 +158,7 @@ class event_pool_processor } // Consider anything except "only deferred" to be a processed event. - if (*result != process_result::HANDLED_DEFERRED) + if (*result != process_result::deferred) { processed_events++; if (processed_events == max_events) @@ -175,7 +175,7 @@ class event_pool_processor // (required to prevent infinitely processing the same event, // if it was handled and at the same time action-deferred // in orthogonal regions). - if (!(*result & process_result::HANDLED_DEFERRED)) + if (!(any(*result & process_result::deferred))) { m_event_pool.cur_seq_cnt += 1; } diff --git a/include/boost/msm/backmp11/detail/favor_runtime_speed.hpp b/include/boost/msm/backmp11/detail/favor_runtime_speed.hpp index 8d9171e8..a931db2f 100644 --- a/include/boost/msm/backmp11/detail/favor_runtime_speed.hpp +++ b/include/boost/msm/backmp11/detail/favor_runtime_speed.hpp @@ -136,7 +136,7 @@ struct compile_policy_impl< using table = dispatch_impl; return table::dispatch(sm, region_id, event); } - return process_result::HANDLED_FALSE; + return process_result::discarded; } // Dispatch an event to the SM's internal table. @@ -147,7 +147,7 @@ struct compile_policy_impl< { return internal_dispatch_impl::transition::process(sm, event); } - return process_result::HANDLED_FALSE; + return process_result::discarded; } private: @@ -330,7 +330,7 @@ struct compile_policy_impl< const Event& event) { const auto state_id = sm.m_active_state_ids[region_id]; - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; mp11::mp_for_each( [&sm, region_id, &event, state_id, &result](auto transition) { @@ -367,7 +367,7 @@ struct compile_policy_impl< { return cell(sm, region_id, event); } - return process_result::HANDLED_FALSE; + return process_result::discarded; } private: @@ -410,17 +410,17 @@ struct compile_policy_impl< static process_result process(StateMachine& sm, Event const& evt) { - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; mp_for_each_until( [&result, &sm, &evt](auto transition) { using Transition = decltype(transition); result |= Transition::process(sm, evt); - if (result & handled_true_or_deferred) + if (any(result & consumed_or_deferred)) { // If a guard rejected previously, // ensure this bit is not present. - result &= handled_true_or_deferred; + result &= consumed_or_deferred; return true; } return false; diff --git a/include/boost/msm/backmp11/detail/metafunctions.hpp b/include/boost/msm/backmp11/detail/metafunctions.hpp index 2a823d0d..1ed86486 100644 --- a/include/boost/msm/backmp11/detail/metafunctions.hpp +++ b/include/boost/msm/backmp11/detail/metafunctions.hpp @@ -316,6 +316,10 @@ struct is_state_blocking_impl template using is_state_blocking = typename is_state_blocking_impl::type; +// Helper to print types within metafunctions for debugging. +template +struct [[deprecated]] print_types {}; + } // boost::msm::backmp11::detail #endif // BOOST_MSM_BACKMP11_DETAIL_METAFUNCTIONS_HPP diff --git a/include/boost/msm/backmp11/detail/transition_table.hpp b/include/boost/msm/backmp11/detail/transition_table.hpp index c426416f..e513ad04 100644 --- a/include/boost/msm/backmp11/detail/transition_table.hpp +++ b/include/boost/msm/backmp11/detail/transition_table.hpp @@ -15,19 +15,34 @@ #include #include +#include +#include + #include #include #include -#include namespace boost::msm::front { - struct Defer; + +struct Defer; + } namespace boost::msm::backmp11::detail { +// Adapter for the basic front-end. +constexpr process_result to_process_result(back::HandledEnum value) +{ + return static_cast(value); +} + +constexpr process_result to_process_result(process_result result) +{ + return result; +} + // Chain of priority tags for SFINAE handling: // priority_tag_0 // ↓ (SFINAE fails?) @@ -114,7 +129,7 @@ struct invoke_action_functor { invoke_functor(priority_tag_0{}, Functor{}, event, fsm, source, target); - return process_result::HANDLED_TRUE; + return process_result::consumed; } }; template <> @@ -123,7 +138,7 @@ struct invoke_action_functor template static process_result execute(const Event&, Fsm&, Source&, Target&) { - return process_result::HANDLED_TRUE; + return process_result::consumed; } }; template <> @@ -134,7 +149,7 @@ struct invoke_action_functor Target&) { fsm.defer_event(event); - return process_result::HANDLED_DEFERRED; + return process_result::deferred; } }; @@ -185,12 +200,12 @@ struct transition_table_impl } else if constexpr (HasAction) { - return Row::action_call( - sm.get_fsm_argument(), event, source, target, sm.m_states); + return to_process_result(Row::action_call( + sm.get_fsm_argument(), event, source, target, sm.m_states)); } else { - return process_result::HANDLED_TRUE; + return process_result::consumed; } } @@ -288,7 +303,7 @@ struct transition_table_impl if (!call_guard_or_true(sm, event, source, target)) { // guard rejected the event, we stay in the current one - return process_result::HANDLED_GUARD_REJECT; + return process_result::rejected; } if constexpr (std::is_same_v) @@ -379,7 +394,7 @@ struct transition_table_impl if (!call_guard_or_true(sm, event, source, target)) { - return process_result::HANDLED_GUARD_REJECT; + return process_result::rejected; } return call_action_or_true(sm, event, source, target); } @@ -427,7 +442,7 @@ struct transition_table_impl if (!call_guard_or_true(sm, event, source, target)) { - return process_result::HANDLED_GUARD_REJECT; + return process_result::rejected; } return call_action_or_true(sm, event, source, target); } @@ -588,16 +603,16 @@ struct transition_chain uint8_t region_id, const Event& evt) { - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; mp_for_each_until( [&result, &sm, region_id, &evt](auto transition) { using Transition = decltype(transition); result |= Transition::process(sm, region_id, evt); - if (result & handled_true_or_deferred) + if (any(result & consumed_or_deferred)) { // If a guard rejected previously, ensure this bit is not present. - result &= handled_true_or_deferred; + result &= consumed_or_deferred; return true; } return false; diff --git a/include/boost/msm/backmp11/favor_compile_time.hpp b/include/boost/msm/backmp11/favor_compile_time.hpp index 7c67415a..bfb635c6 100644 --- a/include/boost/msm/backmp11/favor_compile_time.hpp +++ b/include/boost/msm/backmp11/favor_compile_time.hpp @@ -221,10 +221,10 @@ struct compile_policy_impl for (const generic_cell cell : m_transition_cells) { result |= reinterpret_cast(cell)(sm, region_id, event); - if (result & handled_true_or_deferred) + if (any(result & consumed_or_deferred)) { // If a guard rejected previously, ensure this bit is not present. - return result & handled_true_or_deferred; + return result & consumed_or_deferred; } } // At this point result can be HANDLED_FALSE or HANDLED_GUARD_REJECT. @@ -253,14 +253,14 @@ struct compile_policy_impl process_result process(StateMachine& sm, any_event const& event) const { using cell_t = process_result (*)(StateMachine&, any_event const&); - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; for (const generic_cell cell : m_transition_cells) { result |= reinterpret_cast(cell)(sm, event); - if (result & handled_true_or_deferred) + if (any(result & consumed_or_deferred)) { // If a guard rejected previously, ensure this bit is not present. - return result & handled_true_or_deferred; + return result & consumed_or_deferred; } } // At this point result can be HANDLED_FALSE or HANDLED_GUARD_REJECT. @@ -305,7 +305,7 @@ struct compile_policy_impl const dispatch_table& self = instance(); return self.m_internal_dispatch_table.dispatch(sm, event); } - return process_result::HANDLED_FALSE; + return process_result::discarded; } private: @@ -373,11 +373,11 @@ struct compile_policy_impl // Dispatch an event. process_result dispatch(StateMachine& sm, uint8_t region_id, const any_event& event) const { - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; if (m_call_process_event) { result = m_call_process_event(sm, event); - if (result & handled_true_or_deferred) + if (any(result & consumed_or_deferred)) { return result; } @@ -451,7 +451,7 @@ struct compile_policy_impl // Dispatch an event. process_result dispatch(StateMachine& sm, const any_event& event) const { - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; auto it = m_transition_chains.find(event.type()); if (it != m_transition_chains.end()) { diff --git a/include/boost/msm/backmp11/state_machine.hpp b/include/boost/msm/backmp11/state_machine.hpp index cfa5e7c5..bb3ba763 100644 --- a/include/boost/msm/backmp11/state_machine.hpp +++ b/include/boost/msm/backmp11/state_machine.hpp @@ -547,7 +547,7 @@ class state_machine { if (this->m_machine_state != machine_state::idle) { - return process_result::HANDLED_FALSE; + return process_result::discarded; } // If the state machine has terminate or interrupt flags, check them. @@ -556,7 +556,7 @@ class state_machine // If the state machine is terminated, discard the event. if (is_flag_active()) { - return process_result::HANDLED_TRUE; + return process_result::consumed; } // If the state machine is interrupted, discard the event @@ -564,7 +564,7 @@ class state_machine if (is_flag_active() && !is_end_interrupt_event(event)) { - return process_result::HANDLED_TRUE; + return process_result::consumed; } } @@ -579,7 +579,7 @@ class state_machine if (info != detail::process_info::submachine_call && compile_policy_impl::try_defer_event(self(), event)) { - return process_result::HANDLED_DEFERRED; + return process_result::deferred; } // Ensure we consider an event @@ -615,7 +615,7 @@ class state_machine using dispatch_table = typename compile_policy_impl::template dispatch_table; - process_result result = process_result::HANDLED_FALSE; + process_result result = process_result::discarded; // Dispatch the event to every region. for (uint8_t region_id = 0; region_id < nr_regions; region_id++) @@ -624,7 +624,7 @@ class state_machine } // Dispatch the event to the SM-internal table if it hasn't been // consumed yet. - if (!(result & detail::handled_true_or_deferred)) + if (!detail::any(result & detail::consumed_or_deferred)) { result |= dispatch_table::internal_dispatch(self(), event); } @@ -633,7 +633,8 @@ class state_machine // then generate an error on every active state. For events coming // from upper machines, do not handle but let the upper sm handle // the error. - if (!result && !(info == detail::process_info::submachine_call)) + if (result == process_result::discarded && + !(info == detail::process_info::submachine_call)) { for (const auto state_id : m_active_state_ids) { @@ -707,7 +708,7 @@ class state_machine if (is_flag_active() || is_flag_active()) { - return process_result::HANDLED_TRUE; + return process_result::consumed; } } @@ -755,7 +756,7 @@ class state_machine m_self.get_observer() .template post_process_transition( - m_self, m_region_id, process_result::HANDLED_TRUE); + m_self, m_region_id, process_result::consumed); } } diff --git a/include/boost/msm/common.hpp b/include/boost/msm/common.hpp index bbd7e1d8..6a80b822 100644 --- a/include/boost/msm/common.hpp +++ b/include/boost/msm/common.hpp @@ -20,12 +20,6 @@ struct wrap{}; // tag to use in grammars where states are seen (init_<<, states_<<...) struct state_tag{}; -// helper to print types within metafunctions -// TODO: -// Remove again -template -struct [[deprecated]] print_types {}; - } } // boost::msm #endif //BOOST_MSM_COMMON_H diff --git a/test/Backmp11Observer.cpp b/test/Backmp11Observer.cpp index 4e252c41..d6a4fda5 100644 --- a/test/Backmp11Observer.cpp +++ b/test/Backmp11Observer.cpp @@ -128,14 +128,14 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer, StateMachine, TestMachines) Observer& observer = test_machine.get_observer(); test_machine.start(); - observer.assert_and_pop_msg("MyStateMachine processed transition \"none + starting -> MyState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"none + starting -> MyState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); test_machine.process_event(TransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event TransitionEvent"); observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ NotMyGuard ] / MyAction -> MyOtherState\" (rejected)"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ MyGuard ] / MyAction -> MyOtherState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ MyGuard ] / MyAction -> MyOtherState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 2); ASSERT_AND_RESET(observer.post_process_transition_counter, 2); @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer, StateMachine, TestMachines) test_machine.process_event(TransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event TransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyOtherState + TransitionEvent -> MyState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyOtherState + TransitionEvent -> MyState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); @@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer, StateMachine, TestMachines) test_machine.process_event(InternalTransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event InternalTransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + InternalTransitionEvent / MyAction\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + InternalTransitionEvent / MyAction\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); @@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer, StateMachine, TestMachines) test_machine.process_event(SmInternalTransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event SmInternalTransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyStateMachine + SmInternalTransitionEvent / MyAction\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyStateMachine + SmInternalTransitionEvent / MyAction\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); @@ -197,14 +197,14 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer_ref, StateMachine, TestMachines) StateMachine test_machine{observer}; test_machine.start(); - observer.assert_and_pop_msg("MyStateMachine processed transition \"none + starting -> MyState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"none + starting -> MyState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); test_machine.process_event(TransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event TransitionEvent"); observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ NotMyGuard ] / MyAction -> MyOtherState\" (rejected)"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ MyGuard ] / MyAction -> MyOtherState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + TransitionEvent [ MyGuard ] / MyAction -> MyOtherState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 2); ASSERT_AND_RESET(observer.post_process_transition_counter, 2); @@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer_ref, StateMachine, TestMachines) test_machine.process_event(TransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event TransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyOtherState + TransitionEvent -> MyState\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyOtherState + TransitionEvent -> MyState\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer_ref, StateMachine, TestMachines) test_machine.process_event(InternalTransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event InternalTransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + InternalTransitionEvent / MyAction\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyState + InternalTransitionEvent / MyAction\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(observer_ref, StateMachine, TestMachines) test_machine.process_event(SmInternalTransitionEvent{}); observer.assert_and_pop_msg("MyStateMachine processing event SmInternalTransitionEvent"); - observer.assert_and_pop_msg("MyStateMachine processed transition \"MyStateMachine + SmInternalTransitionEvent / MyAction\" (handled)"); + observer.assert_and_pop_msg("MyStateMachine processed transition \"MyStateMachine + SmInternalTransitionEvent / MyAction\" (consumed)"); ASSERT_AND_RESET(observer.pre_process_event_counter, 1); ASSERT_AND_RESET(observer.pre_process_transition_counter, 1); ASSERT_AND_RESET(observer.post_process_transition_counter, 1); diff --git a/test/Backmp11Transitions.cpp b/test/Backmp11Transitions.cpp index 56b6deba..dd4ba588 100644 --- a/test/Backmp11Transitions.cpp +++ b/test/Backmp11Transitions.cpp @@ -60,7 +60,7 @@ struct MyAction // Attempting to process events while the state machine is processing // shall discard the event. BOOST_REQUIRE(fsm.process_event(TriggerNoTransition{}) == - process_result::HANDLED_FALSE); + process_result::discarded); } }; @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(transitions, StateMachine, TestMachines) TestMachine test_machine; BOOST_REQUIRE(test_machine.process_event(TriggerInternalTransition{}) == - process_result::HANDLED_FALSE); + process_result::discarded); ASSERT_AND_RESET(test_machine.template get_state().action_counter, 0); test_machine.start();