Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72195 - in branches/release/boost/msm: . back front front/detail front/euml mpl_graph
From: christophe.j.henry_at_[hidden]
Date: 2011-05-26 17:04:48


Author: chenry
Date: 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
New Revision: 72195
URL: http://svn.boost.org/trac/boost/changeset/72195

Log:
merged revisions 72048-72191
Added:
   branches/release/boost/msm/active_state_switching_policies.hpp (props changed)
      - copied unchanged from r72191, /trunk/boost/msm/active_state_switching_policies.hpp
Properties modified:
   branches/release/boost/msm/ (props changed)
   branches/release/boost/msm/back/ (props changed)
   branches/release/boost/msm/back/any_event.hpp (props changed)
   branches/release/boost/msm/back/args.hpp (props changed)
   branches/release/boost/msm/back/bind_helpers.hpp (props changed)
   branches/release/boost/msm/back/common_types.hpp (props changed)
   branches/release/boost/msm/back/copy_policies.hpp (props changed)
   branches/release/boost/msm/back/default_compile_policy.hpp (props changed)
   branches/release/boost/msm/back/dispatch_table.hpp (props changed)
   branches/release/boost/msm/back/favor_compile_time.hpp (props changed)
   branches/release/boost/msm/back/fold_to_list.hpp (props changed)
   branches/release/boost/msm/back/history_policies.hpp (props changed)
   branches/release/boost/msm/back/metafunctions.hpp (contents, props changed)
   branches/release/boost/msm/back/mpl_graph_fsm_check.hpp (props changed)
   branches/release/boost/msm/back/no_fsm_check.hpp (props changed)
   branches/release/boost/msm/back/queue_container_circular.hpp (props changed)
   branches/release/boost/msm/back/queue_container_deque.hpp (props changed)
   branches/release/boost/msm/back/state_machine.hpp (contents, props changed)
   branches/release/boost/msm/back/tools.hpp (props changed)
   branches/release/boost/msm/common.hpp (props changed)
   branches/release/boost/msm/front/ (props changed)
   branches/release/boost/msm/front/common_states.hpp (props changed)
   branches/release/boost/msm/front/completion_event.hpp (props changed)
   branches/release/boost/msm/front/detail/ (props changed)
   branches/release/boost/msm/front/detail/common_states.hpp (props changed)
   branches/release/boost/msm/front/detail/row2_helper.hpp (props changed)
   branches/release/boost/msm/front/euml/ (props changed)
   branches/release/boost/msm/front/euml/algorithm.hpp (props changed)
   branches/release/boost/msm/front/euml/common.hpp (contents, props changed)
   branches/release/boost/msm/front/euml/container.hpp (props changed)
   branches/release/boost/msm/front/euml/euml.hpp (props changed)
   branches/release/boost/msm/front/euml/euml_typeof.hpp (props changed)
   branches/release/boost/msm/front/euml/guard_grammar.hpp (props changed)
   branches/release/boost/msm/front/euml/iteration.hpp (props changed)
   branches/release/boost/msm/front/euml/operator.hpp (props changed)
   branches/release/boost/msm/front/euml/phoenix_placeholders.hpp (contents, props changed)
   branches/release/boost/msm/front/euml/querying.hpp (props changed)
   branches/release/boost/msm/front/euml/state_grammar.hpp (contents, props changed)
   branches/release/boost/msm/front/euml/stl.hpp (props changed)
   branches/release/boost/msm/front/euml/stt_grammar.hpp (props changed)
   branches/release/boost/msm/front/euml/transformation.hpp (props changed)
   branches/release/boost/msm/front/functor_row.hpp (contents, props changed)
   branches/release/boost/msm/front/internal_row.hpp (props changed)
   branches/release/boost/msm/front/row2.hpp (props changed)
   branches/release/boost/msm/front/state_machine_def.hpp (contents, props changed)
   branches/release/boost/msm/front/states.hpp (props changed)
   branches/release/boost/msm/mpl_graph/mpl_graph.hpp (props changed)
   branches/release/boost/msm/msm_grammar.hpp (props changed)
   branches/release/boost/msm/proto_config.hpp (contents, props changed)
   branches/release/boost/msm/row_tags.hpp (props changed)
Text files modified:
   branches/release/boost/msm/back/metafunctions.hpp | 43 ++++++++++++++++++++++++++++++++++++++++
   branches/release/boost/msm/back/state_machine.hpp | 43 +++++++++++++++++++++++++++++----------
   branches/release/boost/msm/front/euml/common.hpp | 27 +++++++++++++++++++++---
   branches/release/boost/msm/front/euml/phoenix_placeholders.hpp | 2 +
   branches/release/boost/msm/front/euml/state_grammar.hpp | 10 ++++----
   branches/release/boost/msm/front/functor_row.hpp | 2 -
   branches/release/boost/msm/front/state_machine_def.hpp | 2 -
   branches/release/boost/msm/proto_config.hpp | 2 -
   8 files changed, 105 insertions(+), 26 deletions(-)

Modified: branches/release/boost/msm/back/metafunctions.hpp
==============================================================================
--- branches/release/boost/msm/back/metafunctions.hpp (original)
+++ branches/release/boost/msm/back/metafunctions.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -63,6 +63,7 @@
 BOOST_MPL_HAS_XXX_TRAIT_DEF(no_message_queue)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(activate_deferred_events)
 BOOST_MPL_HAS_XXX_TRAIT_DEF(wrapped_entry)
+BOOST_MPL_HAS_XXX_TRAIT_DEF(active_state_switch_policy)
 
 namespace boost { namespace msm { namespace back
 {
@@ -155,6 +156,35 @@
     typedef typename ::boost::mpl::first<all_state_ids>::type type;
 };
 
+template <class Fsm>
+struct get_active_state_switch_policy_helper
+{
+ typedef typename Fsm::active_state_switch_policy type;
+};
+template <class Iter>
+struct get_active_state_switch_policy_helper2
+{
+ typedef typename boost::mpl::deref<Iter>::type Fsm;
+ typedef typename Fsm::active_state_switch_policy type;
+};
+// returns the active state switching policy
+template <class Fsm>
+struct get_active_state_switch_policy
+{
+ typedef typename ::boost::mpl::find_if<
+ typename Fsm::configuration,
+ has_active_state_switch_policy< ::boost::mpl::placeholders::_1 > >::type iter;
+
+ typedef typename ::boost::mpl::eval_if<
+ typename ::boost::is_same<
+ iter,
+ typename ::boost::mpl::end<typename Fsm::configuration>::type
+ >::type,
+ get_active_state_switch_policy_helper<Fsm>,
+ get_active_state_switch_policy_helper2< iter >
+ >::type type;
+};
+
 // returns the id of a given state
 template <class stt,class State>
 struct get_state_id
@@ -642,6 +672,19 @@
 };
 
 template <class StateType>
+struct is_active_state_switch_policy
+{
+ typedef ::boost::mpl::bool_< ::boost::mpl::count_if<
+ typename StateType::configuration,
+ has_active_state_switch_policy< ::boost::mpl::placeholders::_1 > >::value != 0> found;
+
+ typedef typename ::boost::mpl::or_<
+ typename has_active_state_switch_policy<StateType>::type,
+ found
+ >::type type;
+};
+
+template <class StateType>
 struct get_initial_event
 {
     typedef typename StateType::initial_event type;

Modified: branches/release/boost/msm/back/state_machine.hpp
==============================================================================
--- branches/release/boost/msm/back/state_machine.hpp (original)
+++ branches/release/boost/msm/back/state_machine.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -49,6 +49,7 @@
 
 #include <boost/parameter.hpp>
 
+#include <boost/msm/active_state_switching_policies.hpp>
 #include <boost/msm/row_tags.hpp>
 #include <boost/msm/back/fold_to_list.hpp>
 #include <boost/msm/back/metafunctions.hpp>
@@ -174,6 +175,13 @@
     typedef typename QueueContainerPolicy::
         template In<transition_fct>::type events_queue_t;
 
+ typedef typename boost::mpl::eval_if<
+ typename is_active_state_switch_policy<Derived>::type,
+ get_active_state_switch_policy<Derived>,
+ // default
+ ::boost::mpl::identity<active_state_switch_after_entry>
+ >::type active_state_switching;
+
     typedef bool (*flag_handler)(library_sm const&);
 
     // all state machines are friend with each other to allow embedding any of them in another fsm
@@ -421,21 +429,24 @@
                 // guard rejected the event, we stay in the current one
                 return HANDLED_GUARD_REJECT;
             }
+ fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state);
 
             // the guard condition has already been checked
             execute_exit<current_state_type>
                 (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm);
+ fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state);
 
             // then call the action method
             HandledEnum res = ROW::action_call(fsm,evt,
                              ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),
                              ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),
                              fsm.m_substate_list);
+ fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state);
 
             // and finally the entry method of the new current state
             convert_event_and_execute_entry<next_state_type,T2>
                 (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm);
- fsm.m_states[region_index]=next_state;
+ fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state);
             return res;
         }
     };
@@ -497,15 +508,18 @@
                 // guard rejected the event, we stay in the current one
                 return HANDLED_GUARD_REJECT;
             }
+ fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state);
+
             // the guard condition has already been checked
             execute_exit<current_state_type>
                 (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm);
+ fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state);
+ fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state);
 
             // and finally the entry method of the new current state
             convert_event_and_execute_entry<next_state_type,T2>
                 (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm);
-
- fsm.m_states[region_index]=next_state;
+ fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state);
             return HANDLED_TRUE;
         }
     };
@@ -553,22 +567,25 @@
             {
                 return HANDLED_FALSE;
             }
+ fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state);
+
             // no need to check the guard condition
             // first call the exit method of the current state
             execute_exit<current_state_type>
                 (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm);
+ fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state);
 
             // then call the action method
             HandledEnum res = ROW::action_call(fsm,evt,
                             ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),
                             ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),
                             fsm.m_substate_list);
+ fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state);
 
             // and finally the entry method of the new current state
             convert_event_and_execute_entry<next_state_type,T2>
                 (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm);
-
- fsm.m_states[region_index]=next_state;
+ fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state);
             return res;
         }
     };
@@ -616,15 +633,19 @@
             {
                 return HANDLED_FALSE;
             }
+ fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state);
+
             // first call the exit method of the current state
             execute_exit<current_state_type>
                 (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm);
+ fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state);
+ fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state);
+
 
             // and finally the entry method of the new current state
             convert_event_and_execute_entry<next_state_type,T2>
                 (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm);
-
- fsm.m_states[region_index]=next_state;
+ fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state);
             return HANDLED_TRUE;
         }
     };
@@ -777,7 +798,7 @@
             return false;
         }
         // Take the transition action and return the next state.
- static HandledEnum execute(library_sm& fsm, int , int state, transition_event const& evt)
+ static HandledEnum execute(library_sm& fsm, int , int , transition_event const& evt)
         {
             if (!check_guard(fsm,evt))
             {
@@ -1099,7 +1120,7 @@
                 (evt,::boost::mpl::bool_<is_no_exception_thrown<library_sm>::type::value>());
             if (handled)
             {
- ret_handled = HANDLED_TRUE;
+ ret_handled = handled;
             }
 
             // process completion transitions BEFORE any other event in the pool (UML Standard 2.3 §15.3.14)
@@ -2422,13 +2443,13 @@
     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)
+ remove_direct_entry_event_wrapper(EventType const& evt,boost::msm::back::dummy<0> = 0)
     {
         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)
+ remove_direct_entry_event_wrapper(EventType const& evt,boost::msm::back::dummy<1> = 0)
     {
         // identity. No wrapper
         return evt;

Modified: branches/release/boost/msm/front/euml/common.hpp
==============================================================================
--- branches/release/boost/msm/front/euml/common.hpp (original)
+++ branches/release/boost/msm/front/euml/common.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -14,10 +14,6 @@
 #include <boost/config.hpp>
 #include <boost/msm/proto_config.hpp>
 
-#ifndef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
-#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
-#endif
-
 #include <iterator>
 #include <utility>
 
@@ -62,6 +58,7 @@
 #include <boost/preprocessor/cat.hpp>
 
 #include <boost/msm/msm_grammar.hpp>
+#include <boost/msm/active_state_switching_policies.hpp>
 #include <boost/msm/front/functor_row.hpp>
 
 namespace proto = boost::proto;
@@ -309,6 +306,28 @@
 No_Msg_Queue const no_msg_queue=No_Msg_Queue();
 Deferred_Events const deferred_events=Deferred_Events();
 
+struct ActiveStateSwitchBeforeTransition : euml_config<ActiveStateSwitchBeforeTransition>
+{
+ typedef boost::msm::active_state_switch_before_transition active_state_switch_policy;
+ ActiveStateSwitchBeforeTransition(){}
+};
+ActiveStateSwitchBeforeTransition const switch_active_before_transition = ActiveStateSwitchBeforeTransition();
+
+struct ActiveStateSwitchAfterExit : euml_config<ActiveStateSwitchAfterExit>
+{
+ typedef boost::msm::active_state_switch_after_exit active_state_switch_policy;
+ ActiveStateSwitchAfterExit(){}
+};
+ActiveStateSwitchAfterExit const switch_active_after_exit = ActiveStateSwitchAfterExit();
+
+struct ActiveStateSwitchAfterAction : euml_config<ActiveStateSwitchAfterAction>
+{
+ typedef boost::msm::active_state_switch_after_transition_action active_state_switch_policy;
+ ActiveStateSwitchAfterAction(){}
+};
+ActiveStateSwitchAfterAction const switch_active_after_action = ActiveStateSwitchAfterAction();
+
+
 struct invalid_type{};
 struct make_invalid_type
 {

Modified: branches/release/boost/msm/front/euml/phoenix_placeholders.hpp
==============================================================================
--- branches/release/boost/msm/front/euml/phoenix_placeholders.hpp (original)
+++ branches/release/boost/msm/front/euml/phoenix_placeholders.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -19,6 +19,8 @@
     boost::phoenix::expression::argument<2>::type const _fsm = {};
     boost::phoenix::expression::argument<3>::type const _source = {};
     boost::phoenix::expression::argument<4>::type const _target = {};
+ // this is for state actions
+ boost::phoenix::expression::argument<3>::type const _state = {};
 }}}}
 
 #endif //BOOST_MSM_FRONT_EUML_PHOENIX_PLACEHOLDERS_H

Modified: branches/release/boost/msm/front/euml/state_grammar.hpp
==============================================================================
--- branches/release/boost/msm/front/euml/state_grammar.hpp (original)
+++ branches/release/boost/msm/front/euml/state_grammar.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -602,8 +602,8 @@
    typedef ::boost::fusion::pair<int,int> attribute_type;
 };
 
- attribute<> const attributes_ = {{}};
- attribute<> const no_attributes_ = {{}};
+attribute<> const attributes_ = {{{}}};
+ attribute<> const no_attributes_ = {{{}}};
 
  struct BuildAttributesHelper
    : proto::make<
@@ -672,8 +672,8 @@
    )
 };
 
- configure<> const configure_ = {{}};
- configure<> const no_configure_ = {{}};
+ configure<> const configure_ = {{{}}};
+ configure<> const no_configure_ = {{{}}};
 
 struct BuildConfigure
  : proto::make<
@@ -704,7 +704,7 @@
    )
 };
 
-define_init<> const init_ = {{}};
+define_init<> const init_ = {{{}}};
 struct BuildInit
    : proto::make<
        ::boost::mpl::pop_front<

Modified: branches/release/boost/msm/front/functor_row.hpp
==============================================================================
--- branches/release/boost/msm/front/functor_row.hpp (original)
+++ branches/release/boost/msm/front/functor_row.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -11,8 +11,6 @@
 #ifndef BOOST_MSM_FRONT_FUNCTOR_ROW_H
 #define BOOST_MSM_FRONT_FUNCTOR_ROW_H
 
-#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
-
 #include <boost/mpl/set.hpp>
 #include <boost/mpl/for_each.hpp>
 #include <boost/mpl/has_xxx.hpp>

Modified: branches/release/boost/msm/front/state_machine_def.hpp
==============================================================================
--- branches/release/boost/msm/front/state_machine_def.hpp (original)
+++ branches/release/boost/msm/front/state_machine_def.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -14,8 +14,6 @@
 #include <exception>
 #include <boost/assert.hpp>
 
-#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
-
 #include <boost/mpl/vector.hpp>
 
 #include <boost/msm/row_tags.hpp>

Modified: branches/release/boost/msm/proto_config.hpp
==============================================================================
--- branches/release/boost/msm/proto_config.hpp (original)
+++ branches/release/boost/msm/proto_config.hpp 2011-05-26 17:04:46 EDT (Thu, 26 May 2011)
@@ -11,8 +11,6 @@
 #ifndef BOOST_MSM_PROTO_CONFIG_H
 #define BOOST_MSM_PROTO_CONFIG_H
 
-#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
-
 #include <boost/proto/proto_fwd.hpp>
 
 #endif //BOOST_MSM_PROTO_CONFIG_H


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