Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67138 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2010-12-09 17:56:35


Author: chenry
Date: 2010-12-09 17:56:31 EST (Thu, 09 Dec 2010)
New Revision: 67138
URL: http://svn.boost.org/trac/boost/changeset/67138

Log:
added checking of unreachable states
Text files modified:
   trunk/boost/msm/back/metafunctions.hpp | 18 ++++++++++++++++++
   trunk/boost/msm/back/mpl_graph_fsm_check.hpp | 10 ++++++++++
   trunk/boost/msm/back/no_fsm_check.hpp | 4 ++++
   trunk/boost/msm/back/state_machine.hpp | 2 ++
   4 files changed, 34 insertions(+), 0 deletions(-)

Modified: trunk/boost/msm/back/metafunctions.hpp
==============================================================================
--- trunk/boost/msm/back/metafunctions.hpp (original)
+++ trunk/boost/msm/back/metafunctions.hpp 2010-12-09 17:56:31 EST (Thu, 09 Dec 2010)
@@ -809,6 +809,24 @@
     enum {cumulated_states_in_regions_raw = ::boost::mpl::size<one_big_states_set>::value};
 };
 
+template <class Fsm>
+struct check_no_unreachable_state
+{
+ typedef typename check_regions_orthogonality<Fsm>::one_big_states_set states_in_regions;
+
+ typedef typename set_insert_range<
+ states_in_regions,
+ typename ::boost::mpl::eval_if<
+ typename has_explicit_creation<Fsm>::type,
+ get_explicit_creation<Fsm>,
+ ::boost::mpl::vector0<>
+ >::type
+ >::type with_explicit_creation;
+
+ enum {states_in_fsm = ::boost::mpl::size< typename Fsm::substate_list >::value};
+ enum {cumulated_states_in_regions = ::boost::mpl::size< with_explicit_creation >::value};
+};
+
 // 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: trunk/boost/msm/back/mpl_graph_fsm_check.hpp
==============================================================================
--- trunk/boost/msm/back/mpl_graph_fsm_check.hpp (original)
+++ trunk/boost/msm/back/mpl_graph_fsm_check.hpp 2010-12-09 17:56:31 EST (Thu, 09 Dec 2010)
@@ -30,6 +30,16 @@
                                        ::boost::msm::back::check_regions_orthogonality<Fsm>::cumulated_states_in_regions_raw );
 
         }
+ // checks that all states are reachable or created using the explicit_creation typedef
+ // using the mpl_graph library (part of metagraph)
+ template <class Fsm>
+ static void check_unreachable_states()
+ {
+ BOOST_MPL_ASSERT_RELATION( ::boost::msm::back::check_no_unreachable_state<Fsm>::states_in_fsm,
+ ==,
+ ::boost::msm::back::check_no_unreachable_state<Fsm>::cumulated_states_in_regions );
+
+ }
     };
 
 } } }//boost::msm::back

Modified: trunk/boost/msm/back/no_fsm_check.hpp
==============================================================================
--- trunk/boost/msm/back/no_fsm_check.hpp (original)
+++ trunk/boost/msm/back/no_fsm_check.hpp 2010-12-09 17:56:31 EST (Thu, 09 Dec 2010)
@@ -25,6 +25,10 @@
         static void check_orthogonality()
         {
         }
+ template <class Fsm>
+ static void check_unreachable_states()
+ {
+ }
     };
 
 } } }//boost::msm::back

Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp (original)
+++ trunk/boost/msm/back/state_machine.hpp 2010-12-09 17:56:31 EST (Thu, 09 Dec 2010)
@@ -2403,6 +2403,8 @@
     {
         // checks that regions are truly orthogonal
         FsmCheckPolicy::template check_orthogonality<library_sm>();
+ // checks that all states are reachable
+ FsmCheckPolicy::template check_unreachable_states<library_sm>();
 
         BOOST_STATIC_CONSTANT(int, max_state = (mpl::size<state_list>::value));
         // allocate the place without reallocation


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