Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71879 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2011-05-11 17:01:06


Author: chenry
Date: 2011-05-11 17:01:05 EDT (Wed, 11 May 2011)
New Revision: 71879
URL: http://svn.boost.org/trac/boost/changeset/71879

Log:
bugfix: wrong event in on_entry of direct entry state. See: [MSM] event type change while using a direct entry
Text files modified:
   trunk/boost/msm/back/state_machine.hpp | 19 ++++++++++++++++++-
   1 files changed, 18 insertions(+), 1 deletions(-)

Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp (original)
+++ trunk/boost/msm/back/state_machine.hpp 2011-05-11 17:01:05 EDT (Wed, 11 May 2011)
@@ -86,6 +86,7 @@
 {
     typedef int direct_entry;
     typedef StateType active_state;
+ typedef Event contained_event;
 
     direct_entry_event(Event const& evt):m_event(evt){}
     Event const& m_event;
@@ -2416,6 +2417,22 @@
     {
         // nothing to process
     }
+ // helper function. In cases where the event is wrapped (target is a direct entry states)
+ // we want to send only the real event to on_entry, not the wrapper.
+ template <class EventType>
+ static
+ typename boost::enable_if<typename has_direct_entry<EventType>::type,typename EventType::contained_event const& >::type
+ remove_direct_entry_event_wrapper(EventType const& evt)
+ {
+ return evt.m_event;
+ }
+ template <class EventType>
+ static typename boost::disable_if<typename has_direct_entry<EventType>::type,EventType const& >::type
+ remove_direct_entry_event_wrapper(EventType const& evt)
+ {
+ // identity. No wrapper
+ return evt;
+ }
     // calls the entry/exit or on_entry/on_exit depending on the state type
     // (avoids calling virtually)
     // variant for FSMs
@@ -2436,7 +2453,7 @@
     execute_entry(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<1> = 0)
     {
         // simple call to on_entry
- astate.on_entry(evt,fsm);
+ astate.on_entry(remove_direct_entry_event_wrapper(evt),fsm);
     }
     // variant for exit pseudo states
     template <class StateType,class EventType,class FsmType>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk