Changeset 62155


Ignore:
Timestamp:
May 22, 2010, 7:47:15 PM (9 years ago)
Author:
Christophe Henry
Message:

corrected bug: the fsm parameter of a submachine now is the containing state machine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/boost/msm/back/state_machine.hpp

    r62128 r62155  
    18531853         direct_event_start_helper(library_sm* self_):self(self_){}
    18541854         // this variant is for the standard case, entry due to activation of the containing FSM
    1855          template <class EventType>
     1855         template <class EventType,class FsmType>
    18561856         typename ::boost::disable_if<typename has_direct_entry<EventType>::type,void>::type
    1857              operator()(EventType const& evt, ::boost::msm::back::dummy<0> = 0)
     1857             operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<0> = 0)
    18581858         {
    1859              (static_cast<Derived*>(self))->on_entry(evt,*self);
     1859             (static_cast<Derived*>(self))->on_entry(evt,fsm);
    18601860             self->start(evt);
    18611861         }
    18621862
    18631863         // this variant is for the direct entry case (just one entry, not a sequence of entries)
    1864          template <class EventType>
     1864         template <class EventType,class FsmType>
    18651865         typename ::boost::enable_if<
    18661866             typename ::boost::mpl::and_<
     
    18721872                                                    >::type>::type,void
    18731873                                  >::type
    1874          operator()(EventType const& evt, ::boost::msm::back::dummy<1> = 0)
     1874         operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<1> = 0)
    18751875         {
    1876              (static_cast<Derived*>(self))->on_entry(evt,*self);
     1876             (static_cast<Derived*>(self))->on_entry(evt,fsm);
    18771877             int state_id = get_state_id<stt,typename EventType::active_state>::value;
    18781878             BOOST_STATIC_ASSERT(EventType::active_state::zone_index >= 0);
     
    18841884
    18851885         // this variant is for the fork entry case (a sequence on entries)
    1886          template <class EventType>
     1886         template <class EventType,class FsmType>
    18871887         typename ::boost::enable_if<
    18881888             typename ::boost::mpl::and_<
     
    18941894                                                >::type>::type,void
    18951895                                >::type
    1896          operator()(EventType const& evt, ::boost::msm::back::dummy<2> = 0)
     1896         operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<2> = 0)
    18971897         {
    1898              (static_cast<Derived*>(self))->on_entry(evt,*self);
     1898             (static_cast<Derived*>(self))->on_entry(evt,fsm);
    18991899             ::boost::mpl::for_each<typename EventType::active_state,
    19001900                                    ::boost::msm::wrap< ::boost::mpl::placeholders::_1> >
     
    19051905
    19061906         // this variant is for the pseudo state entry case
    1907          template <class EventType>
     1907         template <class EventType,class FsmType>
    19081908         typename ::boost::enable_if<
    19091909             typename is_pseudo_entry<typename EventType::active_state >::type,void
    19101910                                    >::type
    1911          operator()(EventType const& evt, ::boost::msm::back::dummy<3> = 0)
     1911         operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<3> = 0)
    19121912         {
    19131913             // entry on the FSM
    1914              (static_cast<Derived*>(self))->on_entry(evt,*self);
     1914             (static_cast<Derived*>(self))->on_entry(evt,fsm);
    19151915             int state_id = get_state_id<stt,typename EventType::active_state>::value;
    19161916             // given region starts with the entry pseudo state as active state
     
    19741974     };
    19751975     // entry/exit for states machines which are themselves embedded in other state machines (composites)
    1976          template <class Event>
    1977      void do_entry(Event const& incomingEvent)
     1976         template <class Event,class FsmType>
     1977     void do_entry(Event const& incomingEvent,FsmType& fsm)
    19781978     {
    19791979        // by default we activate the history/init states, can be overwritten by direct_event_start_helper
     
    19821982        m_event_processing = true;
    19831983        // if the event is generating a direct entry/fork, set the current state(s) to the direct state(s)
    1984         direct_event_start_helper(this)(incomingEvent);
     1984        direct_event_start_helper(this)(incomingEvent,fsm);
    19851985        // handle messages which were generated and blocked in the init calls
    19861986        m_event_processing = false;
    19871987        process_message_queue(this);
    19881988     }
    1989          template <class Event>
    1990      void do_exit(Event const& incomingEvent)
     1989         template <class Event,class FsmType>
     1990     void do_exit(Event const& incomingEvent,FsmType& fsm)
    19911991     {
    19921992        // first recursively exit the sub machines
     
    19941994        region_entry_exit_helper< ::boost::mpl::int_<0> >::template do_exit(this,incomingEvent);
    19951995        // then call our own exit
    1996         (static_cast<Derived*>(this))->on_exit(incomingEvent,*this);
     1996        (static_cast<Derived*>(this))->on_exit(incomingEvent,fsm);
    19971997        // give the history a chance to handle this (or not).
    19981998        m_history.history_exit(this->m_states);
     
    20532053    {
    20542054        // calls on_entry on the fsm then handles direct entries, fork, entry pseudo state
    2055         astate.do_entry(evt);
     2055        astate.do_entry(evt,fsm);
    20562056    }
    20572057    // variant for states
     
    20802080    static
    20812081        typename ::boost::enable_if<typename is_composite_state<StateType>::type,void >::type
    2082     execute_exit(StateType& astate,EventType const& evt,FsmType& , ::boost::msm::back::dummy<0> = 0)
    2083     {
    2084         astate.do_exit(evt);
     2082    execute_exit(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<0> = 0)
     2083    {
     2084        astate.do_exit(evt,fsm);
    20852085    }
    20862086    template <class StateType,class EventType,class FsmType>
Note: See TracChangeset for help on using the changeset viewer.