// Copyright 2025 Christian Granzin // Copyright 2008 Christophe Henry // henry UNDERSCORE christophe AT hotmail DOT com // This is an extended version of the state machine available in the boost::mpl library // Distributed under the same license as the original. // Copyright for the original version: // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed // under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_MSM_BACKMP11_DETAIL_HISTORY_IMPL_HPP #define BOOST_MSM_BACKMP11_DETAIL_HISTORY_IMPL_HPP #include #include #include namespace boost::msm::backmp11::detail { template class history_impl; template class history_impl { public: template static void on_entry(StateMachine& sm, const Event&) { sm.m_active_state_ids = value_array; if constexpr (StateMachine::has_event_pool) { sm.get_event_pool().events.clear(); } } template static void on_entry(StateMachine& sm, Visitor&& visitor) { mp11::mp_for_each( [&sm, &visitor](auto state_id) { auto& state = std::get(sm.m_states); visitor(state); }); } }; template class history_impl { public: template static void on_entry(StateMachine&, const Event&) { } template static void on_entry(StateMachine& sm, Visitor&& visitor) { sm.template visit(visitor); } }; template class history_impl, InitialStateIds> : public history_impl { using events = mp11::mp_list; public: template static void on_entry(StateMachine& sm, const Event&) { if constexpr (!mp11::mp_contains::value) { sm.m_active_state_ids = value_array; if constexpr (StateMachine::has_event_pool) { sm.get_event_pool().events.clear(); } } } template static void on_entry(StateMachine& sm, Visitor&& visitor) { sm.template visit(visitor); } }; } // boost::msm::backmp11 #endif // BOOST_MSM_BACKMP11_DETAIL_HISTORY_IMPL_HPP