$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70956 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2011-04-03 14:53:26
Author: chenry
Date: 2011-04-03 14:53:26 EDT (Sun, 03 Apr 2011)
New Revision: 70956
URL: http://svn.boost.org/trac/boost/changeset/70956
Log:
added stop() in state_machine
Text files modified: 
   trunk/boost/msm/back/metafunctions.hpp |     6 ++++++                                  
   trunk/boost/msm/back/state_machine.hpp |    13 +++++++++++++                           
   2 files changed, 19 insertions(+), 0 deletions(-)
Modified: trunk/boost/msm/back/metafunctions.hpp
==============================================================================
--- trunk/boost/msm/back/metafunctions.hpp	(original)
+++ trunk/boost/msm/back/metafunctions.hpp	2011-04-03 14:53:26 EDT (Sun, 03 Apr 2011)
@@ -647,6 +647,12 @@
     typedef typename StateType::initial_event type;
 };
 
+template <class StateType>
+struct get_final_event 
+{
+    typedef typename StateType::final_event type;
+};
+
 template <class TransitionTable, class InitState>
 struct build_one_orthogonal_region 
 {
Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp	(original)
+++ trunk/boost/msm/back/state_machine.hpp	2011-04-03 14:53:26 EDT (Sun, 03 Apr 2011)
@@ -67,6 +67,7 @@
 BOOST_MPL_HAS_XXX_TRAIT_DEF(non_forwarding_flag)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(direct_entry)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(initial_event)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(final_event)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(do_serialize)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(history_policy)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(fsm_check)
@@ -257,6 +258,7 @@
     typedef HistoryPolicy               history_policy;
 
     struct InitEvent { };
+    struct ExitEvent { };
     // flag handling
     struct Flag_AND
     {
@@ -276,6 +278,12 @@
         ::boost::mpl::identity<InitEvent>
     >::type fsm_initial_event;
 
+    // if the front-end fsm provides an exit_event typedef, replace ExitEvent by this one
+    typedef typename ::boost::mpl::eval_if< 
+        typename has_final_event<Derived>::type,
+        get_final_event<Derived>,
+        ::boost::mpl::identity<ExitEvent>
+    >::type fsm_final_event;
 
     template <class ExitPoint>
     struct exit_pt : public ExitPoint
@@ -1034,7 +1042,12 @@
         // give a chance to handle an anonymous (eventless) transition
         handle_eventless_transitions_helper<library_sm> eventless_helper(this,true);
         eventless_helper.process_completion_event();
+    }
 
+    // stop the state machine (calls exit of the current state)
+    void stop()
+    {
+        do_exit(fsm_final_event(),*this);
     }
 
     // Main function used by clients of the derived FSM to make