Chris@16: // Copyright 2008 Christophe Henry Chris@16: // henry UNDERSCORE christophe AT hotmail DOT com Chris@16: // This is an extended version of the state machine available in the boost::mpl library Chris@16: // Distributed under the same license as the original. Chris@16: // Copyright for the original version: Chris@16: // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed Chris@16: // under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_MSM_FRONT_STATES_H Chris@16: #define BOOST_MSM_FRONT_STATES_H Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace msm { namespace front Chris@16: { Chris@16: Chris@16: struct no_sm_ptr Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::bool_ needs_sm; Chris@16: }; Chris@16: struct sm_ptr Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::bool_ needs_sm; Chris@16: }; Chris@16: // kept for backward compatibility Chris@16: struct NoSMPtr Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::bool_ needs_sm; Chris@16: }; Chris@16: struct SMPtr Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::bool_ needs_sm; Chris@16: }; Chris@16: Chris@16: // provides the typedefs and interface. Concrete states derive from it. Chris@16: // template argument: pointer-to-fsm policy Chris@16: template Chris@16: struct state : public boost::msm::front::detail::state_base, SMPtrPolicy Chris@16: { Chris@16: // tags Chris@16: // default: no flag Chris@16: typedef ::boost::mpl::vector0<> flag_list; Chris@16: typedef ::boost::mpl::vector0<> internal_flag_list; Chris@16: //default: no deferred events Chris@16: typedef ::boost::mpl::vector0<> deferred_events; Chris@16: }; Chris@16: Chris@16: // terminate state simply defines the TerminateFlag flag Chris@16: // template argument: pointer-to-fsm policy Chris@16: template Chris@16: struct terminate_state : public boost::msm::front::detail::state_base, SMPtrPolicy Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::vector0<> flag_list; Chris@16: typedef ::boost::mpl::vector< boost::msm::TerminateFlag> internal_flag_list; Chris@16: //default: no deferred events Chris@16: typedef ::boost::mpl::vector0<> deferred_events; Chris@16: }; Chris@16: Chris@16: // terminate state simply defines the InterruptedFlag and EndInterruptFlag flags Chris@16: // template argument: event which ends the interrupt Chris@16: // template argument: pointer-to-fsm policy Chris@16: template Chris@16: struct interrupt_state : public boost::msm::front::detail::state_base, SMPtrPolicy Chris@16: { Chris@16: // tags Chris@16: typedef ::boost::mpl::vector0<> flag_list; Chris@16: typedef typename boost::msm::back::build_interrupt_state_flag_list< Chris@16: typename boost::msm::back::get_interrupt_events::type Chris@16: >::type internal_flag_list; Chris@16: Chris@16: //default: no deferred events Chris@16: typedef ::boost::mpl::vector0<> deferred_events; Chris@16: }; Chris@16: Chris@16: // not a state but a bunch of extra typedefs to handle direct entry into a composite state. To be derived from Chris@16: // template argument: zone index of this state Chris@16: template Chris@16: struct explicit_entry Chris@16: { Chris@16: typedef int explicit_entry_state; Chris@16: enum {zone_index=ZoneIndex}; Chris@16: }; Chris@16: Chris@16: // to be derived from. Makes a type an entry (pseudo) state. Actually an almost full-fledged state Chris@16: // template argument: containing composite Chris@16: // template argument: zone index of this state Chris@16: // template argument: pointer-to-fsm policy Chris@16: template Chris@16: struct entry_pseudo_state Chris@16: : public boost::msm::front::detail::state_base,SMPtrPolicy Chris@16: { Chris@16: // tags Chris@16: typedef int pseudo_entry; Chris@16: enum {zone_index=ZoneIndex}; Chris@16: typedef int explicit_entry_state; Chris@16: // default: no flag Chris@16: typedef ::boost::mpl::vector0<> flag_list; Chris@16: typedef ::boost::mpl::vector0<> internal_flag_list; Chris@16: //default: no deferred events Chris@16: typedef ::boost::mpl::vector0<> deferred_events; Chris@16: }; Chris@16: Chris@16: // to be derived from. Makes a state an exit (pseudo) state. Actually an almost full-fledged state Chris@16: // template argument: event to forward Chris@16: // template argument: pointer-to-fsm policy Chris@16: template Chris@16: struct exit_pseudo_state : public boost::msm::front::detail::state_base , SMPtrPolicy Chris@16: { Chris@16: typedef Event event; Chris@16: typedef BASE Base; Chris@16: typedef SMPtrPolicy PtrPolicy; Chris@16: typedef int pseudo_exit; Chris@16: Chris@16: // default: no flag Chris@16: typedef ::boost::mpl::vector0<> flag_list; Chris@16: typedef ::boost::mpl::vector0<> internal_flag_list; Chris@16: //default: no deferred events Chris@16: typedef ::boost::mpl::vector0<> deferred_events; Chris@16: }; Chris@16: Chris@16: }}} Chris@16: Chris@16: #endif //BOOST_MSM_FRONT_STATES_H Chris@16: