// 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_FRONT_EUML_COMMON_H #define BOOST_MSM_FRONT_EUML_COMMON_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if BOOST_VERSION >= 104000 #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace proto = boost::proto; BOOST_MPL_HAS_XXX_TRAIT_DEF(tag_type) BOOST_MPL_HAS_XXX_TRAIT_DEF(action_name) BOOST_MPL_HAS_XXX_TRAIT_DEF(not_intern_euml_state) namespace boost { namespace msm { namespace front { namespace euml { template struct get_iterator { typedef typename T::iterator type; }; template struct get_reverse_iterator { typedef typename T::reverse_iterator type; }; template struct get_reference { typedef typename T::reference type; }; template struct get_size_type { typedef typename T::size_type type; }; template struct get_value_type { typedef typename T::value_type type; }; template struct get_first_type { typedef typename T::first_type type; }; template struct get_second_type { typedef typename T::second_type type; }; template struct get_action_tag_type { typedef typename ::boost::mpl::has_key< typename T::tag_type,action_tag>::type type; }; template struct get_state_action_tag_type { typedef typename ::boost::mpl::has_key< typename T::tag_type,state_action_tag>::type type; }; template struct get_result_type { typedef typename T::template transition_action_result::type type; }; template struct get_result_type2 { typedef typename T::template state_action_result::type type; }; template struct get_sequence { typedef typename SEQ::sequence type; }; template struct get_attributes_type { typedef typename T::attributes_type type; }; template struct get_euml_tag_type { typedef typename T::euml_tag_type type; }; template struct get_fct { typedef typename T::template In::type type; }; // used to differentiate between different types of euml_state's template struct get_state_name { typedef T type; }; template struct get_state_name >::type> { typedef typename T::In::type type; }; template struct get_action_name { typedef typename T::action_name type; }; template struct get_event_name { typedef typename T::event_name type; }; template struct euml_event: proto::extends::type, EVT, boost::msm::sm_domain> { typedef event_tag euml_tag_type; typedef EVT event_name; using proto::extends::type, EVT, boost::msm::sm_domain>::operator=; template struct In { typedef EVT type; }; }; template struct euml_state_intern: proto::extends::type, STATE, boost::msm::state_domain> { typedef state_tag euml_tag_type; using proto::extends::type, STATE, boost::msm::state_domain>::operator=; template struct In { typedef STATE type; }; }; template struct euml_state: proto::extends::type, STATE, boost::msm::state_domain> { typedef state_tag euml_tag_type; typedef int not_intern_euml_state; using proto::extends::type, STATE, boost::msm::state_domain>::operator=; struct In { typedef STATE type; }; }; template struct euml_action: proto::extends::type, ACTION, boost::msm::sm_domain> { typedef action_tag euml_tag_type; typedef ACTION action_name; using proto::extends::type, ACTION, boost::msm::sm_domain>::operator=; template struct In { typedef ACTION type; }; }; template struct euml_flag: proto::extends::type, FLAG, boost::msm::sm_domain> { typedef flag_tag euml_tag_type; using proto::extends::type, FLAG, boost::msm::sm_domain>::operator=; template struct In { typedef FLAG type; }; }; template struct euml_config: proto::extends::type, CONFIG, boost::msm::sm_domain> { typedef config_tag euml_tag_type; using proto::extends::type, CONFIG, boost::msm::sm_domain>::operator=; template struct In { typedef CONFIG type; }; }; struct No_Exception : euml_config { typedef int no_exception_thrown; No_Exception(){} }; struct No_Msg_Queue : euml_config { typedef int no_message_queue; No_Msg_Queue(){} }; struct Deferred_Events : euml_config { typedef int activate_deferred_events; Deferred_Events(){} }; No_Exception const no_exception=No_Exception(); No_Msg_Queue const no_msg_queue=No_Msg_Queue(); Deferred_Events const deferred_events=Deferred_Events(); struct ActiveStateSwitchBeforeTransition : euml_config { typedef boost::msm::active_state_switch_before_transition active_state_switch_policy; ActiveStateSwitchBeforeTransition(){} }; ActiveStateSwitchBeforeTransition const switch_active_before_transition = ActiveStateSwitchBeforeTransition(); struct ActiveStateSwitchAfterExit : euml_config { typedef boost::msm::active_state_switch_after_exit active_state_switch_policy; ActiveStateSwitchAfterExit(){} }; ActiveStateSwitchAfterExit const switch_active_after_exit = ActiveStateSwitchAfterExit(); struct ActiveStateSwitchAfterAction : euml_config { typedef boost::msm::active_state_switch_after_transition_action active_state_switch_policy; ActiveStateSwitchAfterAction(){} }; ActiveStateSwitchAfterAction const switch_active_after_action = ActiveStateSwitchAfterAction(); struct invalid_type{}; struct make_invalid_type { typedef invalid_type type; }; template struct make_vector_one_row { typedef boost::mpl::vector type; }; template T make_T(T t) {return t;} struct make_vector_no_row { typedef boost::mpl::vector0<> type; }; struct NoAction : euml_action { NoAction(){} // return value if used inside a state action (entry/exit) template struct state_action_result { typedef bool type; }; // return value if used inside a transition (action/guard) template struct transition_action_result { typedef bool type; }; // this functor can be used in both modes, state action and transition action typedef ::boost::mpl::set tag_type; template bool operator()(Event const&,FSM&,STATE& ) { // does nothing return true; } template bool operator()(EVT const& ,FSM& ,SourceState& ,TargetState&)const { // does nothing return true; } }; NoAction const no_action = NoAction(); struct fsm_artefact_tag {}; template struct GetSource_ : euml_action > { template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& ,FSM& ,SourceState& src,TargetState&)const { return src.get_attribute(Index()); } }; template<> struct GetSource_ : euml_action > { template struct transition_action_result { typedef SourceState& type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& , FSM&,SourceState& src,TargetState& )const { return src; } }; struct GetSource_Helper: proto::extends< proto::terminal::type, GetSource_Helper, boost::msm::sm_domain> { GetSource_Helper(){} template struct In { typedef GetSource_ type; }; }; GetSource_Helper const source_ = GetSource_Helper(); template struct GetTarget_ : euml_action > { template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const { return tgt.get_attribute(Index()); } }; template<> struct GetTarget_ : euml_action > { template struct transition_action_result { typedef TargetState& type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& , FSM&,SourceState& ,TargetState& tgt)const { return tgt; } }; struct GetTarget_Helper: proto::extends< proto::terminal::type, GetTarget_Helper, boost::msm::sm_domain> { GetTarget_Helper(){} template struct In { typedef GetTarget_ type; }; }; GetTarget_Helper const target_ = GetTarget_Helper(); template struct GetState_ : euml_action > { template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& ,STATE& state ) { return state.get_attribute(Index()); } }; template<> struct GetState_ : euml_action > { using euml_action::operator=; template struct state_action_result { typedef STATE& type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& ,STATE& state ) { return state; } }; struct GetState_Helper: proto::extends< proto::terminal::type, GetState_Helper, boost::msm::sm_domain> { GetState_Helper(){} template struct In { typedef GetState_ type; }; }; GetState_Helper const state_ = GetState_Helper(); template struct GetEvent_ : euml_action > { template struct state_action_result { typedef typename ::boost::add_const< typename ::boost::fusion::result_of::at_key::type>::type type; }; template struct transition_action_result { typedef typename ::boost::add_const< typename ::boost::fusion::result_of::at_key::type>::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const& evt,FSM& ,STATE& ) { return evt.get_attribute(Index()); } template typename transition_action_result::type operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const { return evt.get_attribute(Index()); } }; template <> struct GetEvent_ : euml_action > { template struct state_action_result { typedef Event const& type; }; template struct transition_action_result { typedef EVT const& type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const& evt,FSM& ,STATE& ) { return evt; } template typename transition_action_result::type operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const { return evt; } }; struct GetEvent_Helper: proto::extends< proto::terminal::type, GetEvent_Helper, boost::msm::sm_domain> { GetEvent_Helper(){} template struct In { typedef GetEvent_ type; }; }; GetEvent_Helper const event_ = GetEvent_Helper(); template struct GetFsm_ : euml_action > { template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& fsm,STATE& ) { return fsm.get_attribute(Index()); } template typename transition_action_result::type operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const { return fsm.get_attribute(Index()); } }; template<> struct GetFsm_ : euml_action > { using euml_action::operator=; template struct state_action_result { typedef FSM& type; }; template struct transition_action_result { typedef FSM& type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& fsm,STATE& ) { return fsm; } template typename transition_action_result::type operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const { return fsm; } }; struct GetFsm_Helper: proto::extends< proto::terminal::type, GetFsm_Helper, boost::msm::sm_domain> { GetFsm_Helper(){} template struct In { typedef GetFsm_ type; }; }; GetFsm_Helper const fsm_ = GetFsm_Helper(); template struct SubState_ : euml_action > { template struct state_action_result { typedef StateName& type; }; template struct transition_action_result { typedef StateName& type; }; typedef ::boost::mpl::set tag_type; template StateName& operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { return (Param1()(evt,fsm,src,tgt)).template get_state(); } template StateName& operator()(Event const& evt,FSM& fsm,STATE& state)const { return (Param1()(evt,fsm,state)).template get_state(); } }; template struct SubState_ : euml_action > { template struct state_action_result { typedef StateName& type; }; template struct transition_action_result { typedef StateName& type; }; typedef ::boost::mpl::set tag_type; template StateName& operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const { return fsm.template get_state(); } template StateName& operator()(Event const& ,FSM& fsm,STATE& )const { return fsm.template get_state(); } }; struct SubState_Helper: proto::extends< proto::terminal::type, SubState_Helper, boost::msm::sm_domain> { SubState_Helper(){} using proto::extends< proto::terminal::type, SubState_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef SubState_ type; }; }; SubState_Helper const substate_ = SubState_Helper(); template struct GetAttribute_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key< typename get_attributes_type< typename ::boost::remove_reference< typename get_result_type2::type>::type>::type, Index >::type type; }; template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key< typename get_attributes_type< typename ::boost::remove_reference< typename get_result_type::type>::type>::type, Index >::type type; }; typedef ::boost::mpl::set tag_type; template typename ::boost::enable_if< typename ::boost::mpl::has_key< typename Target::tag_type,action_tag>::type, typename transition_action_result::type >::type operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { return (Target()(evt,fsm,src,tgt)).get_attribute(Index()); } template typename ::boost::enable_if< typename ::boost::mpl::has_key< typename Target::tag_type,state_action_tag>::type, typename state_action_result::type >::type operator()(Event const& evt,FSM& fsm,STATE& state )const { return (Target()(evt,fsm,state)).get_attribute(Index()); } }; struct GetAttribute_Helper: proto::extends< proto::terminal::type, GetAttribute_Helper, boost::msm::sm_domain> { GetAttribute_Helper(){} template struct In { typedef GetAttribute_ type; }; }; GetAttribute_Helper const attribute_ = GetAttribute_Helper(); template struct Source_ : euml_action > { using euml_action >::operator=; template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& , FSM&,SourceState& src,TargetState& )const { return src.get_attribute(Index()); } }; template struct Target_ : euml_action > { using euml_action >::operator=; template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename transition_action_result::type operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const { return tgt.get_attribute(Index()); } }; template struct State_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& ,STATE& state ) { return state.get_attribute(Index()); } }; template struct Event_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef typename ::boost::add_const< typename ::boost::fusion::result_of::at_key::type>::type type; }; template struct transition_action_result { typedef typename ::boost::add_const< typename ::boost::fusion::result_of::at_key::type>::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const& evt,FSM& ,STATE& ) { return evt.get_attribute(Index()); } template typename transition_action_result::type operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const { return evt.get_attribute(Index()); } }; template struct State_Attribute_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& fsm,STATE& ) { return fsm.template get_state().get_attribute(Index()); } }; template struct Fsm_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; template struct transition_action_result { typedef typename ::boost::fusion::result_of::at_key::type type; }; typedef ::boost::mpl::set tag_type; template typename state_action_result::type operator()(Event const&,FSM& fsm,STATE& ) { return fsm.get_attribute(Index()); } template typename transition_action_result::type operator()(EVT const& evt ,FSM& fsm,SourceState& ,TargetState&)const { return fsm.get_attribute(Index()); } }; struct True_ : euml::euml_action { using euml_action::operator=; True_(){} template struct state_action_result { typedef bool type; }; template struct transition_action_result { typedef bool type; }; typedef ::boost::mpl::set tag_type; template bool operator()(EVT const&,FSM&,SourceState& ,TargetState& ) { return true; } template bool operator()(Event const&,FSM&,STATE& ) { return true; } }; True_ const true_ = True_(); struct False_ : euml::euml_action { using euml_action::operator=; False_(){} template struct state_action_result { typedef bool type; }; template struct transition_action_result { typedef bool type; }; typedef ::boost::mpl::set tag_type; template bool operator()(EVT const&,FSM&,SourceState& ,TargetState& ) { return false; } template bool operator()(Event const&,FSM&,STATE& ) { return false; } }; False_ const false_ = False_(); template struct Int_ : euml_action > { using euml_action >::operator=; typedef ::boost::mpl::int_ value_type; enum {value = Val}; template struct state_action_result { typedef int type; }; template struct transition_action_result { typedef int type; }; typedef ::boost::mpl::set tag_type; template int operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) { return Val; } template int operator()(Event const& ,FSM& ,STATE& ) { return Val; } }; template struct Char_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef char type; }; template struct transition_action_result { typedef char type; }; typedef ::boost::mpl::set tag_type; template char operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) { return Val; } template char operator()(Event const& ,FSM& ,STATE& ) { return Val; } }; template struct Size_t_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef size_t type; }; template struct transition_action_result { typedef size_t type; }; typedef ::boost::mpl::set tag_type; template size_t operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) { return Val; } template size_t operator()(Event const& ,FSM& ,STATE& ) { return Val; } }; #if BOOST_VERSION >= 104000 template struct String_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef char const* type; }; template struct transition_action_result { typedef char const* type; }; typedef ::boost::mpl::set tag_type; template char const* operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) { return ::boost::mpl::c_str::value; } template char const* operator()(Event const& ,FSM& ,STATE& ) { return ::boost::mpl::c_str::value; } }; #endif template struct Predicate_ : euml_action > { using euml_action >::operator=; template struct state_action_result { typedef T type; }; template struct transition_action_result { typedef T type; }; typedef ::boost::mpl::set tag_type; template T operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) { return T(); } template T operator()(Event const& ,FSM& ,STATE& ) { return T(); } }; template struct Process_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param4()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); (Param3()(evt,fsm,state)).process_event(ToProcessEvt()); (Param4()(evt,fsm,state)).process_event(ToProcessEvt()); } }; template struct Process_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const { fsm.process_event(ToProcessEvt()); } template void operator()(Event const& ,FSM& fsm,STATE& )const { fsm.process_event(ToProcessEvt()); } }; template struct Process_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); } }; template struct Process_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); } }; template struct Process_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); (Param3()(evt,fsm,state)).process_event(ToProcessEvt()); } }; //version for process_(event_) template <> struct Process_ ,void,void,void,void> : euml_action, void, void, void, void > > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& )const { fsm.process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& )const { fsm.process_event(evt); } }; struct process_tag {}; struct Process_Helper: proto::extends< proto::terminal::type, Process_Helper, boost::msm::sm_domain> { Process_Helper(){} using proto::extends< proto::terminal::type, Process_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef Process_ type; }; }; Process_Helper const process_ = Process_Helper(); template struct Reprocess_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(evt); (Param2()(evt,fsm,src,tgt)).process_event(evt); (Param3()(evt,fsm,src,tgt)).process_event(evt); (Param4()(evt,fsm,src,tgt)).process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(evt); (Param2()(evt,fsm,state)).process_event(evt); (Param3()(evt,fsm,state)).process_event(evt); (Param4()(evt,fsm,state)).process_event(evt); } }; template <> struct Reprocess_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& )const { fsm.process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& )const { fsm.process_event(evt); } }; template struct Reprocess_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(evt); } }; template struct Reprocess_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(evt); (Param2()(evt,fsm,src,tgt)).process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(evt); (Param2()(evt,fsm,state)).process_event(evt); } }; template struct Reprocess_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(evt); (Param2()(evt,fsm,src,tgt)).process_event(evt); (Param3()(evt,fsm,src,tgt)).process_event(evt); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(evt); (Param2()(evt,fsm,state)).process_event(evt); (Param3()(evt,fsm,state)).process_event(evt); } }; struct reprocess_tag {}; struct Reprocess_Helper: proto::extends< proto::terminal::type, Reprocess_Helper, boost::msm::sm_domain> { Reprocess_Helper(){} using proto::extends< proto::terminal::type, Reprocess_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef Reprocess_ type; }; }; Reprocess_Helper const reprocess_ = Reprocess_Helper(); template struct Process2_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); (Param2()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); (Param3()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); } }; template struct Process2_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { fsm.process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { fsm.process_event(ToProcessEvt(Value()(evt,fsm,state))); } }; template struct Process2_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); } }; template struct Process2_ : euml_action > { template struct state_action_result { typedef void type; }; template struct transition_action_result { typedef void type; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); } template void operator()(Event const& evt,FSM& fsm,STATE& state)const { (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); (Param2()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); } }; struct process2_tag {}; struct Process2_Helper : proto::extends< proto::terminal::type, Process2_Helper, boost::msm::sm_domain> { Process2_Helper(){} using proto::extends< proto::terminal::type, Process2_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef Process2_ type; }; }; Process2_Helper const process2_ = Process2_Helper(); template struct Get_Flag_ : euml_action > {}; template struct Get_Flag_ ::type >::type> : euml_action > { template struct state_action_result { typedef bool type; }; template struct transition_action_result { typedef bool type; }; typedef ::boost::mpl::set tag_type; template bool operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const { return fsm.template is_flag_active(); } template bool operator()(Event const& ,FSM& fsm,STATE& )const { return fsm.template is_flag_active(); } }; template struct Get_Flag_ ::type >::type> : euml_action > { template struct state_action_result { typedef bool type; }; template struct transition_action_result { typedef bool type; }; typedef ::boost::mpl::set tag_type; template bool operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const { return (Param1()(evt,fsm,src,tgt)).template is_flag_active(); } template bool operator()(Event const& evt,FSM& fsm,STATE& state)const { return (Param1()(evt,fsm,state)).template is_flag_active(); } }; struct Get_Flag_Helper: proto::extends< proto::terminal::type, Get_Flag_Helper, boost::msm::sm_domain> { Get_Flag_Helper(){} template struct In { typedef Get_Flag_ type; }; }; Get_Flag_Helper const is_flag_ = Get_Flag_Helper(); // deferring an event struct DeferEvent_ : euml_action< DeferEvent_ > { typedef ::boost::mpl::set tag_type; // mark as deferring to avoid stack overflows in certain conditions typedef int deferring_action; template void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& ) const { fsm.defer_event(evt); } }; struct Defer_Helper : proto::extends< proto::terminal::type, Defer_Helper, boost::msm::sm_domain> { Defer_Helper(){} using proto::extends< proto::terminal::type, Defer_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef DeferEvent_ type; }; }; Defer_Helper const defer_ = Defer_Helper(); struct explicit_tag {}; struct Explicit_Helper : proto::extends< proto::terminal::type, Explicit_Helper, boost::msm::sm_domain> { Explicit_Helper(){} using proto::extends< proto::terminal::type, Explicit_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef typename Arg1::template direct type; }; }; Explicit_Helper const explicit_ = Explicit_Helper(); struct entry_pt_tag {}; struct Entry_Pt_Helper : proto::extends< proto::terminal::type, Entry_Pt_Helper, boost::msm::sm_domain> { Entry_Pt_Helper(){} using proto::extends< proto::terminal::type, Entry_Pt_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef typename Arg1::template entry_pt type; }; }; Entry_Pt_Helper const entry_pt_ = Entry_Pt_Helper(); struct exit_pt_tag {}; struct Exit_Pt_Helper : proto::extends< proto::terminal::type, Exit_Pt_Helper, boost::msm::sm_domain> { Exit_Pt_Helper(){} using proto::extends< proto::terminal::type, Exit_Pt_Helper, boost::msm::sm_domain>::operator=; template struct In { typedef typename Arg1::template exit_pt type; }; }; Exit_Pt_Helper const exit_pt_ = Exit_Pt_Helper(); #ifdef BOOST_MSVC #define BOOST_MSM_EUML_FUNCTION(functor,function,function_name,result_trans,result_state) \ template \ struct functor : euml_action > {}; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename transition_action_result::type \ operator()(EVT const& , FSM& ,SourceState& ,TargetState& )const { \ return function ();} \ template \ typename state_action_result::type \ operator()(Event const& ,FSM& ,STATE& )const { \ return function ();} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt),Param6()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state),Param6()(evt,fsm,state));} }; \ struct function_name ## tag{}; \ struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ template \ struct In {typedef functor type;}; }; \ functor ## Helper const function_name = functor ## Helper (); #define BOOST_MSM_EUML_METHOD(functor,function,function_name,result_trans,result_state) \ template \ struct functor : euml_action > {}; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function();} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function();} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt),Param6()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state),Param6()(evt,fsm,state));} }; \ struct function_name ## tag{}; \ struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ template \ struct In {typedef functor type;}; }; \ functor ## Helper const function_name = functor ## Helper (); #else #define BOOST_MSM_EUML_FUNCTION(functor,function,function_name,result_trans,result_state) \ template \ struct functor : euml_action > {}; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state));} }; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ struct function_name ## tag{}; \ struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ template \ struct In {typedef functor type;}; }; \ functor ## Helper const function_name = functor ## Helper (); #define BOOST_MSM_EUML_METHOD(functor,function,function_name,result_trans,result_state) \ template \ struct functor : euml_action > {}; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function();} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function();} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ template \ struct functor::type,typename ::boost::mpl::not_< \ typename ::boost::is_same::type>::type>::type >::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state));} }; \ template \ struct functor::type>::type> \ : euml_action > { \ template struct state_action_result { \ typedef result_state type;} ; \ template \ struct transition_action_result { typedef result_trans type;}; \ typedef ::boost::mpl::set tag_type; \ template \ typename ::boost::enable_if::type, \ typename transition_action_result::type >::type \ operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ template \ typename ::boost::enable_if::type, \ typename state_action_result::type >::type \ operator()(Event const& evt,FSM& fsm,STATE& state )const { \ return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ struct function_name ## tag{}; \ struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ template \ struct In {typedef functor type;}; }; \ functor ## Helper const function_name = functor ## Helper (); #endif #define RESULT_TYPE2_PARAM1 typename get_result_type2::type #define RESULT_TYPE_PARAM1 typename get_result_type::type #define RESULT_TYPE2_PARAM2 typename get_result_type2::type #define RESULT_TYPE_PARAM2 typename get_result_type::type #define RESULT_TYPE2_PARAM3 typename get_result_type2::type #define RESULT_TYPE_PARAM3 typename get_result_type::type #define RESULT_TYPE2_PARAM4 typename get_result_type2::type #define RESULT_TYPE_PARAM4 typename get_result_type::type #define RESULT_TYPE2_PARAM5 typename get_result_type2::type #define RESULT_TYPE_PARAM5 typename get_result_type::type #define RESULT_TYPE2_PARAM6 typename get_result_type2::type #define RESULT_TYPE_PARAM6 typename get_result_type::type #define RESULT_TYPE2_DIFF_TYPE_ITER_TRAITS_PARAM1 typename std::iterator_traits::type>::difference_type #define RESULT_TYPE_DIFF_TYPE_ITER_TRAITS_PARAM1 typename std::iterator_traits::type>::difference_type #define RESULT_TYPE2_REMOVE_REF_PARAM1 typename ::boost::remove_reference::type>::type #define RESULT_TYPE_REMOVE_REF_PARAM1 typename ::boost::remove_reference::type>::type #define RESULT_TYPE2_PAIR_REMOVE_REF_PARAM1 std::pair #define RESULT_TYPE_PAIR_REMOVE_REF_PARAM1 std::pair #define RESULT_TYPE2_GET_REF_REMOVE_REF_PARAM1 typename get_reference::type>::type>::type #define RESULT_TYPE_GET_REF_REMOVE_REF_PARAM1 typename get_reference::type>::type>::type #define RESULT_TYPE2_GET_ITERATOR_REMOVE_REF_PARAM1 typename get_iterator::type>::type>::type #define RESULT_TYPE_GET_ITERATOR_REMOVE_REF_PARAM1 typename get_iterator::type>::type>::type #define RESULT_TYPE2_GET_REV_ITERATOR_REMOVE_REF_PARAM1 typename get_reverse_iterator::type>::type>::type #define RESULT_TYPE_GET_REV_ITERATOR_REMOVE_REF_PARAM1 typename get_reverse_iterator::type>::type>::type #define RESULT_TYPE2_GET_SIZE_TYPE_REMOVE_REF_PARAM1 typename get_size_type::type>::type>::type #define RESULT_TYPE_GET_SIZE_TYPE_REMOVE_REF_PARAM1 typename get_size_type::type>::type>::type #define BOOST_MSM_EUML_ACTION(instance_name) \ struct instance_name ## _impl; \ struct instance_name ## _helper : msm::front::euml::euml_action \ { \ instance_name ## _helper(){} \ typedef instance_name ## _impl action_name; \ }; \ static instance_name ## _helper instance_name; \ struct instance_name ## _impl : instance_name ## _helper #define BOOST_MSM_EUML_DECLARE_ACTION(instance_name) \ struct instance_name ; \ struct instance_name ## _helper : msm::front::euml::euml_action \ { \ instance_name ## _helper(){} \ typedef instance_name action_name; \ }; \ struct instance_name : instance_name ## _helper #define BOOST_MSM_EUML_EVENT(instance_name) \ struct instance_name ## _helper : msm::front::euml::euml_event{ \ instance_name ## _helper(){} \ instance_name ## _helper const& operator()() const {return *this;} }; \ static instance_name ## _helper instance_name; // an event matching any event struct kleene_ : msm::front::euml::euml_event, public boost::any { kleene_() : boost::any(){} template kleene_(const ValueType & v) : boost::any(v){} }; static kleene_ kleene; #define BOOST_MSM_EUML_DECLARE_EVENT(instance_name) \ struct instance_name : msm::front::euml::euml_event{ \ instance_name(){} \ instance_name const& operator()() const {return *this;} }; #define MSM_EUML_CONCAT(param1,param2) param1 #define MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1(z, n, unused) ARG ## n arg ## n #define MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2(z, n, unused) arg ## n #define MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP_ENTRY(z, n, unused) \ typename boost::fusion::result_of::first< \ typename ::boost::remove_reference< \ typename boost::fusion::result_of::at_c::type>::type>::type \ #define MSM_EUML_EVENT_HELPER_GET_ATTRIBUTE(z, n, unused) \ get_attribute( \ typename boost::fusion::result_of::first< \ typename ::boost::remove_reference< \ typename boost::fusion::result_of::at_c::type>::type>::type())=arg ## n; #define MSM_EUML_EVENT_HELPER_CONSTRUCTORS(z, n, mytuple) \ template \ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, mytuple) , _helper)(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ )): \ BOOST_PP_TUPLE_ELEM(2, 1, mytuple)(){ \ init(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2, ~ ),attribute_vec());} #define MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP(z, n, unused) \ template \ void init(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ ), \ T,typename ::boost::enable_if< typename boost::mpl::eval_if< typename ::boost::fusion::traits::is_sequence::type,size_helper,::boost::mpl::false_>::type,void >::type* =0) \ { \ BOOST_PP_REPEAT_FROM_TO(0,n , \ MSM_EUML_EVENT_HELPER_GET_ATTRIBUTE, ~) \ } #define MSM_EUML_EVENT_INSTANCE_HELPER_OPERATOR_IMPL(z, n, instance) \ template \ BOOST_PP_CAT(instance,_helper) operator() \ (BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ ))const{ \ return BOOST_PP_CAT(instance,_helper) (BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2, ~ ));} #define BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(instance_name, attributes_name) \ struct instance_name ## _helper : \ msm::front::euml::euml_event , public attributes_name \ { \ template struct size_helper \ { \ typedef typename ::boost::mpl::less_equal< \ typename ::boost::fusion::result_of::size::type, \ ::boost::mpl::int_ >::type type; \ }; \ BOOST_PP_CAT(instance_name,_helper()) : attributes_name(){} \ typedef attributes_name::attributes_type attribute_map; \ typedef ::boost::fusion::result_of::as_vector::type attribute_vec; \ BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ MSM_EUML_EVENT_HELPER_CONSTRUCTORS, (instance_name,attributes_name)) \ BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP, ~) \ BOOST_PP_CAT(instance_name,_helper) operator()(){ \ return BOOST_PP_CAT(instance_name,_helper)();} \ BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ MSM_EUML_EVENT_INSTANCE_HELPER_OPERATOR_IMPL, instance_name) \ }; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_EVENT_NAME(instance_name) instance_name ## _helper #define BOOST_MSM_EUML_FLAG_NAME(instance_name) instance_name ## _helper #define BOOST_MSM_EUML_FLAG(instance_name) \ struct instance_name ## _helper : msm::front::euml::euml_flag{}; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_DECLARE_FLAG(instance_name) \ struct instance_name : msm::front::euml::euml_flag{}; #define BOOST_MSM_EUML_STATE_NAME(instance_name) instance_name ## _helper #define BOOST_MSM_EUML_BUILD_STT_HELPER build_stt( #define BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER build_internal_stt( #define BOOST_MSM_EUML_BUILD_STT_HELPER2(expr) expr) #define BOOST_MSM_EUML_ENTRY_STATE_HELPER(expr) ,expr #define BOOST_MSM_EUML_ATTRIBUTES(expr,instance_name) \ typedef BOOST_TYPEOF(build_attributes expr) instance_name; // following macros declare a state type but do not create an instance #define BOOST_MSM_EUML_DECLARE_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_INTERRUPT_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_interrupt_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_TERMINATE_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_terminate_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_EXPLICIT_ENTRY_STATE(region,expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_explicit_entry_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_ENTRY_STATE(region,expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_entry_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_EXIT_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_exit_state expr) instance_name; #define BOOST_MSM_EUML_DECLARE_STATE_MACHINE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_sm expr) instance_name; #define BOOST_MSM_EUML_DECLARE_TRANSITION_TABLE(expr,instance_name) \ typedef int using_declared_table; \ typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name; #define BOOST_MSM_EUML_DECLARE_INTERNAL_TRANSITION_TABLE(expr) \ typedef BOOST_TYPEOF( \ BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) internal_transition_table; // following macros declare a state type and create an instance #define BOOST_MSM_EUML_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_INTERRUPT_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_interrupt_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_TERMINATE_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_terminate_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_EXPLICIT_ENTRY_STATE(region,expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_explicit_entry_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_ENTRY_STATE(region,expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_entry_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_EXIT_STATE(expr,instance_name) \ struct instance_name ## tag{}; \ typedef BOOST_TYPEOF(build_exit_state expr) instance_name ## _helper; \ static instance_name ## _helper instance_name; #ifndef BOOST_MSVC #define BOOST_MSM_EUML_TRANSITION_TABLE(expr,instance_name) \ typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name ## _def; \ struct instance_name ## _helper : public instance_name ## _def{instance_name ## _helper(){}}; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_INTERNAL_TRANSITION_TABLE(expr,instance_name) \ typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name ## _def; \ struct instance_name ## _helper : public instance_name ## _def{instance_name ## _helper(){}}; \ static instance_name ## _helper instance_name; #else #define BOOST_MSM_EUML_TRANSITION_TABLE(expr,instance_name) \ struct instance_name ## _helper : \ public BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) \ {instance_name ## _helper(){}} ; \ static instance_name ## _helper instance_name; #define BOOST_MSM_EUML_INTERNAL_TRANSITION_TABLE(expr,instance_name) \ struct instance_name ## _helper : \ public BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) \ {instance_name ## _helper(){}} ; \ static instance_name ## _helper instance_name; #endif }}}} // boost::msm::front::euml namespace boost { namespace msm{ template<> struct is_kleene_event< boost::msm::front::euml::kleene_ > { typedef ::boost::mpl::true_ type; }; }} #endif // BOOST_MSM_FRONT_EUML_COMMON_H