// 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_FUNCTOR_ROW_H #define BOOST_MSM_FRONT_FUNCTOR_ROW_H #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS #include #include #include #include #include #include #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() namespace boost { namespace msm { namespace front { template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef TARGET Target; typedef ACTION Action; typedef GUARD Guard; // action plus guard typedef row_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt,AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef TARGET Target; typedef none Action; typedef none Guard; // no action, no guard typedef _row_tag row_type_tag; }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef TARGET Target; typedef ACTION Action; typedef none Guard; // no guard typedef a_row_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef TARGET Target; typedef none Action; typedef GUARD Guard; // no action typedef g_row_tag row_type_tag; template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; // internal transitions template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef Source Target; typedef ACTION Action; typedef none Guard; // no guard typedef a_irow_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef Source Target; typedef none Action; typedef GUARD Guard; // no action typedef g_irow_tag row_type_tag; template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef Source Target; typedef ACTION Action; typedef GUARD Guard; // action + guard typedef irow_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; template struct Row { typedef SOURCE Source; typedef EVENT Evt; typedef Source Target; typedef none Action; typedef none Guard; // no action, no guard typedef _irow_tag row_type_tag; }; template struct get_row_target { typedef typename TGT::Target type; }; template struct Internal { typedef EVENT Evt; typedef ACTION Action; typedef GUARD Guard; // action plus guard typedef sm_i_row_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; template struct Internal { typedef EVENT Evt; typedef ACTION Action; typedef none Guard; // no guard typedef sm_a_i_row_tag row_type_tag; template static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it Action()(evt,fsm,src,tgt); } }; template struct Internal { typedef EVENT Evt; typedef none Action; typedef GUARD Guard; // no action typedef sm_g_i_row_tag row_type_tag; template static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) { // create functor, call it return Guard()(evt,fsm,src,tgt); } }; template struct Internal { typedef EVENT Evt; typedef none Action; typedef none Guard; // no action, no guard typedef sm__i_row_tag row_type_tag; }; struct state_tag{}; struct event_tag{}; struct action_tag{}; struct state_action_tag{}; struct flag_tag{}; struct config_tag{}; struct not_euml_tag{}; template struct ActionSequence_ { typedef Sequence sequence; template struct state_action_result { typedef void type; }; template struct Call { Call(EVT const& evt,FSM& fsm,STATE& state): evt_(evt),fsm_(fsm),state_(state){} template void operator()(::boost::msm::wrap const& ) { FCT()(evt_,fsm_,state_); } private: EVT const& evt_; FSM& fsm_; STATE& state_; }; template struct transition_action_result { typedef void type; }; template struct Call2 { Call2(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt): evt_(evt),fsm_(fsm),src_(src),tgt_(tgt){} template void operator()(::boost::msm::wrap const& ) { FCT()(evt_,fsm_,src_,tgt_); } private: EVT const & evt_; FSM& fsm_; SourceState& src_; TargetState& tgt_; }; typedef ::boost::mpl::set tag_type; template void operator()(EVT const& evt,FSM& fsm,STATE& state) { mpl::for_each > (Call(evt,fsm,state)); } template void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt) { mpl::for_each > (Call2(evt,fsm,src,tgt)); } }; // functor pre-defined for basic functionality struct Defer { template void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& ) const { fsm.defer_event(evt); } }; }}} #endif //BOOST_MSM_FRONT_FUNCTOR_ROW_H