Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:48:14

0001 // Copyright 2008 Christophe Henry
0002 // henry UNDERSCORE christophe AT hotmail DOT com
0003 // This is an extended version of the state machine available in the boost::mpl library
0004 // Distributed under the same license as the original.
0005 // Copyright for the original version:
0006 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
0007 // under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_MSM_FRONT_STATES_H
0012 #define BOOST_MSM_FRONT_STATES_H
0013 
0014 #include <boost/mpl/bool.hpp>
0015 #include <boost/mpl/vector.hpp>
0016 #include <boost/msm/front/common_states.hpp>
0017 #include <boost/msm/row_tags.hpp>
0018 #include <boost/msm/back/metafunctions.hpp>
0019 
0020 namespace boost { namespace msm { namespace front
0021 {
0022 
0023 struct no_sm_ptr 
0024 {
0025     // tags
0026     typedef ::boost::mpl::bool_<false>   needs_sm;
0027 };
0028 struct sm_ptr 
0029 {
0030     // tags
0031     typedef ::boost::mpl::bool_<true>    needs_sm;
0032 };
0033 // kept for backward compatibility
0034 struct NoSMPtr 
0035 {
0036     // tags
0037     typedef ::boost::mpl::bool_<false>   needs_sm;
0038 };
0039 struct SMPtr 
0040 {
0041     // tags
0042     typedef ::boost::mpl::bool_<true>    needs_sm;
0043 };
0044 
0045 // provides the typedefs and interface. Concrete states derive from it.
0046 // template argument: pointer-to-fsm policy
0047 template<class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr>
0048 struct state :  public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy
0049 {
0050     // tags
0051     // default: no flag
0052     typedef ::boost::mpl::vector0<>       flag_list;
0053     typedef ::boost::mpl::vector0<>       internal_flag_list;
0054     //default: no deferred events
0055     typedef ::boost::mpl::vector0<>       deferred_events;
0056 };
0057 
0058 // terminate state simply defines the TerminateFlag flag
0059 // template argument: pointer-to-fsm policy
0060 template<class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr>
0061 struct terminate_state : public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy
0062 {
0063     // tags
0064     typedef ::boost::mpl::vector0<>                               flag_list;
0065     typedef ::boost::mpl::vector< boost::msm::TerminateFlag>      internal_flag_list;
0066     //default: no deferred events
0067     typedef ::boost::mpl::vector0<>                               deferred_events;
0068 };
0069 
0070 // terminate state simply defines the InterruptedFlag and EndInterruptFlag<EndInterruptEvent> flags
0071 // template argument: event which ends the interrupt
0072 // template argument: pointer-to-fsm policy
0073 template <class EndInterruptEvent,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr>
0074 struct interrupt_state : public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy
0075 {
0076     // tags
0077     typedef ::boost::mpl::vector0<>                           flag_list;
0078     typedef typename boost::msm::back::build_interrupt_state_flag_list<
0079         typename boost::msm::back::get_interrupt_events<EndInterruptEvent>::type
0080     >::type internal_flag_list; 
0081 
0082     //default: no deferred events
0083     typedef ::boost::mpl::vector0<>                           deferred_events;
0084 };
0085 
0086 // not a state but a bunch of extra typedefs to handle direct entry into a composite state. To be derived from
0087 // template argument: zone index of this state
0088 template <int ZoneIndex=-1>
0089 struct explicit_entry 
0090 {
0091     typedef int explicit_entry_state;
0092     enum {zone_index=ZoneIndex};
0093 };
0094 
0095 // to be derived from. Makes a type an entry (pseudo) state. Actually an almost full-fledged state
0096 // template argument: containing composite
0097 // template argument: zone index of this state
0098 // template argument: pointer-to-fsm policy
0099 template<int ZoneIndex=-1,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr>
0100 struct entry_pseudo_state
0101     :  public boost::msm::front::detail::state_base<BASE>,SMPtrPolicy
0102 {
0103     // tags
0104     typedef int                          pseudo_entry;
0105     enum {zone_index=ZoneIndex};
0106     typedef int explicit_entry_state;
0107     // default: no flag
0108     typedef ::boost::mpl::vector0<>       flag_list;
0109     typedef ::boost::mpl::vector0<>       internal_flag_list;
0110     //default: no deferred events
0111     typedef ::boost::mpl::vector0<>       deferred_events;
0112 };
0113 
0114 // to be derived from. Makes a state an exit (pseudo) state. Actually an almost full-fledged state
0115 // template argument: event to forward
0116 // template argument: pointer-to-fsm policy
0117 template<class Event,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr>
0118 struct exit_pseudo_state : public boost::msm::front::detail::state_base<BASE> , SMPtrPolicy
0119 {
0120     typedef Event       event;
0121     typedef BASE        Base;
0122     typedef SMPtrPolicy PtrPolicy;
0123     typedef int         pseudo_exit;
0124 
0125     // default: no flag
0126     typedef ::boost::mpl::vector0<>  flag_list;
0127     typedef ::boost::mpl::vector0<>  internal_flag_list;
0128     //default: no deferred events
0129     typedef ::boost::mpl::vector0<>  deferred_events;
0130 };
0131 
0132 }}}
0133 
0134 #endif //BOOST_MSM_FRONT_STATES_H
0135