Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73289 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2011-07-21 16:31:36


Author: chenry
Date: 2011-07-21 16:31:35 EDT (Thu, 21 Jul 2011)
New Revision: 73289
URL: http://svn.boost.org/trac/boost/changeset/73289

Log:
fixed missing recursion with internal tables and submachines
Text files modified:
   trunk/boost/msm/back/metafunctions.hpp | 26 +++++++++++++++++++++++++-
   trunk/boost/msm/back/state_machine.hpp | 7 ++++---
   2 files changed, 29 insertions(+), 4 deletions(-)

Modified: trunk/boost/msm/back/metafunctions.hpp
==============================================================================
--- trunk/boost/msm/back/metafunctions.hpp (original)
+++ trunk/boost/msm/back/metafunctions.hpp 2011-07-21 16:31:35 EDT (Thu, 21 Jul 2011)
@@ -455,6 +455,29 @@
 {
     typedef typename create_stt<Composite>::type type;
 };
+
+// recursively builds an internal table including those of substates, sub-substates etc.
+// variant for submachines
+template <class StateType,class IsComposite>
+struct recursive_get_internal_transition_table
+{
+ // get the composite's internal table
+ typedef typename StateType::internal_transition_table composite_table;
+ // and for every substate (state of submachine), recursively get the internal transition table
+ typedef typename generate_state_set<typename StateType::stt>::type composite_states;
+ typedef typename ::boost::mpl::fold<
+ composite_states, composite_table,
+ ::boost::mpl::insert_range< ::boost::mpl::placeholders::_1, ::boost::mpl::end<mpl::placeholders::_1>,
+ recursive_get_internal_transition_table< ::boost::mpl::placeholders::_2, is_composite_state< ::boost::mpl::placeholders::_2> >
+ >
+ >::type type;
+};
+// stop iterating on leafs (simple states)
+template <class StateType>
+struct recursive_get_internal_transition_table<StateType, ::boost::mpl::false_ >
+{
+ typedef typename StateType::internal_transition_table type;
+};
 // recursively get a transition table for a given composite state.
 // returns the transition table for this state + the tables of all composite sub states recursively
 template <class Composite>
@@ -463,7 +486,8 @@
     // get the transition table of the state if it's a state machine
     typedef typename ::boost::mpl::eval_if<typename is_composite_state<Composite>::type,
         get_transition_table<Composite>,
- ::boost::mpl::vector0<> >::type org_table;
+ ::boost::mpl::vector0<>
+ >::type org_table;
 
     typedef typename generate_state_set<org_table>::type states;
 

Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp (original)
+++ trunk/boost/msm/back/state_machine.hpp 2011-07-21 16:31:35 EDT (Thu, 21 Jul 2011)
@@ -1002,7 +1002,8 @@
         // add the internal events defined in the internal_transition_table
         // Note: these are added first because they must have a lesser prio
         // than the deeper transitions in the sub regions
- typedef typename StateType::internal_transition_table istt_simulated;
+ // we go recursively because our states can also have internal tables or substates etc.
+ typedef typename recursive_get_internal_transition_table<StateType, ::boost::mpl::true_>::type istt_simulated;
         typedef typename ::boost::mpl::fold<
             istt_simulated,::boost::mpl::vector0<>,
             ::boost::mpl::push_back< ::boost::mpl::placeholders::_1,
@@ -1196,12 +1197,12 @@
 
     deferred_events_queue_t& get_deferred_queue()
     {
- return m_deferred_events_queue;
+ return m_deferred_events_queue.m_deferred_events_queue;
     }
 
     const deferred_events_queue_t& get_deferred_queue() const
     {
- return m_deferred_events_queue;
+ return m_deferred_events_queue.m_deferred_events_queue;
     }
 
     // Getter that returns the current state of the FSM


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