Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60822 - in sandbox/msm/boost/msm: back front front/detail
From: christophe.j.henry_at_[hidden]
Date: 2010-03-25 06:53:40


Author: chenry
Date: 2010-03-25 06:53:39 EDT (Thu, 25 Mar 2010)
New Revision: 60822
URL: http://svn.boost.org/trac/boost/changeset/60822

Log:
- added possibility to define your own init event
- added missing headers
Text files modified:
   sandbox/msm/boost/msm/back/metafunctions.hpp | 5 +++++
   sandbox/msm/boost/msm/back/state_machine.hpp | 15 +++++++++++++--
   sandbox/msm/boost/msm/front/detail/common_states.hpp | 5 ++---
   sandbox/msm/boost/msm/front/state_machine_def.hpp | 1 +
   4 files changed, 21 insertions(+), 5 deletions(-)

Modified: sandbox/msm/boost/msm/back/metafunctions.hpp
==============================================================================
--- sandbox/msm/boost/msm/back/metafunctions.hpp (original)
+++ sandbox/msm/boost/msm/back/metafunctions.hpp 2010-03-25 06:53:39 EDT (Thu, 25 Mar 2010)
@@ -607,6 +607,11 @@
>::type type;
 };
 
+template <class StateType>
+struct get_initial_event
+{
+ typedef typename StateType::initial_event type;
+};
 // helper to find out if a SM has an active exit state and is therefore waiting for exiting
 template <class StateType,class OwnerFct,class FSM>
 inline

Modified: sandbox/msm/boost/msm/back/state_machine.hpp
==============================================================================
--- sandbox/msm/boost/msm/back/state_machine.hpp (original)
+++ sandbox/msm/boost/msm/back/state_machine.hpp 2010-03-25 06:53:39 EDT (Thu, 25 Mar 2010)
@@ -11,6 +11,7 @@
 #ifndef BOOST_MSM_BACK_STATEMACHINE_H
 #define BOOST_MSM_BACK_STATEMACHINE_H
 
+#include <exception>
 #include <vector>
 #include <queue>
 #include <functional>
@@ -56,6 +57,7 @@
 BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create)
 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)
 
 #ifndef BOOST_MSM_CONSTRUCTOR_ARG_SIZE
 #define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 5 // default max number of arguments for constructors
@@ -192,6 +194,14 @@
     typedef typename Derived::BaseAllStates BaseState;
     typedef Derived ConcreteSM;
 
+ // if the front-end fsm provides an initial_event typedef, replace InitEvent by this one
+ typedef typename ::boost::mpl::eval_if<
+ typename has_initial_event<Derived>::type,
+ get_initial_event<Derived>,
+ ::boost::mpl::identity<InitEvent>
+ >::type fsm_initial_event;
+
+
     template <class ExitPoint>
     struct exit_pt : public ExitPoint
     {
@@ -204,6 +214,7 @@
             ExitPoint::event Event;
         typedef ::boost::function<execute_return (Event const&)>
                                     forwarding_function;
+
         // forward event to the higher-level FSM
         template <class ForwardEvent>
         void forward_event(ForwardEvent const& incomingEvent)
@@ -929,9 +940,9 @@
     void start()
     {
         // call on_entry on this SM
- (static_cast<Derived*>(this))->on_entry(InitEvent(),*this);
+ (static_cast<Derived*>(this))->on_entry(fsm_initial_event(),*this);
         ::boost::mpl::for_each<initial_states, boost::msm::wrap<mpl::placeholders::_1> >
- (call_init<InitEvent>(InitEvent(),this));
+ (call_init<fsm_initial_event>(fsm_initial_event(),this));
         // give a chance to handle an anonymous (eventless) transition
         handle_eventless_transitions_helper<library_sm> eventless_helper(this,true);
         eventless_helper.process_completion_event();

Modified: sandbox/msm/boost/msm/front/detail/common_states.hpp
==============================================================================
--- sandbox/msm/boost/msm/front/detail/common_states.hpp (original)
+++ sandbox/msm/boost/msm/front/detail/common_states.hpp 2010-03-25 06:53:39 EDT (Thu, 25 Mar 2010)
@@ -15,8 +15,7 @@
 
 #include <boost/mpl/vector.hpp>
 #include <boost/fusion/container/map.hpp>
-#include <boost/fusion/include/at_c.hpp>
-
+#include <boost/fusion/include/at_key.hpp>
 #include <boost/type_traits/add_const.hpp>
 
 namespace boost { namespace msm { namespace front {namespace detail
@@ -55,7 +54,7 @@
 };
 
 // the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it.
-template<class USERBASE,class Attributes= ::boost::fusion::vector<> >
+template<class USERBASE,class Attributes= ::boost::fusion::map<> >
 struct state_base : public inherit_attributes<Attributes>, USERBASE
 {
     typedef USERBASE user_state_base;

Modified: sandbox/msm/boost/msm/front/state_machine_def.hpp
==============================================================================
--- sandbox/msm/boost/msm/front/state_machine_def.hpp (original)
+++ sandbox/msm/boost/msm/front/state_machine_def.hpp 2010-03-25 06:53:39 EDT (Thu, 25 Mar 2010)
@@ -11,6 +11,7 @@
 #ifndef BOOST_MSM_FRONT_STATEMACHINE_DEF_H
 #define BOOST_MSM_FRONT_STATEMACHINE_DEF_H
 
+#include <boost/assert.hpp>
 #include <boost/mpl/vector.hpp>
 
 #include <boost/msm/row_tags.hpp>


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