Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65844 - in branches/release/boost/msm: . back front/euml
From: christophe.j.henry_at_[hidden]
Date: 2010-10-08 17:05:27


Author: chenry
Date: 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
New Revision: 65844
URL: http://svn.boost.org/trac/boost/changeset/65844

Log:
merged revisions 63060-65696
Properties modified:
   branches/release/boost/msm/ (props changed)
Text files modified:
   branches/release/boost/msm/back/dispatch_table.hpp | 12 +++---
   branches/release/boost/msm/back/history_policies.hpp | 22 +++++++++-
   branches/release/boost/msm/back/metafunctions.hpp | 2
   branches/release/boost/msm/back/state_machine.hpp | 80 ++++++++++++++++++++++++++++++++++++---
   branches/release/boost/msm/front/euml/common.hpp | 52 +++++++++++++-------------
   branches/release/boost/msm/front/euml/guard_grammar.hpp | 32 ++++++++++------
   branches/release/boost/msm/front/euml/state_grammar.hpp | 18 +++++---
   7 files changed, 156 insertions(+), 62 deletions(-)

Modified: branches/release/boost/msm/back/dispatch_table.hpp
==============================================================================
--- branches/release/boost/msm/back/dispatch_table.hpp (original)
+++ branches/release/boost/msm/back/dispatch_table.hpp 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -68,16 +68,16 @@
                  HandledEnum res = first_row::execute(fsm,region_index,state,evt);
                  if (HANDLED_TRUE!=res)
                  {
- // if the first rejected, move on to the next one
+ // if the first rejected, move on to the next one
                     HandledEnum sub_res =
                          execute<typename ::boost::mpl::pop_front<Sequence>::type>(fsm,region_index,state,evt,
                             ::boost::mpl::bool_<
                                 ::boost::mpl::empty<typename ::boost::mpl::pop_front<Sequence>::type>::type::value>());
- // if at least one guards rejects, the event will not generate a call to no_transition
- HandledEnum handled = ((HANDLED_GUARD_REJECT==sub_res) ||
- (HANDLED_GUARD_REJECT==res))?
- HANDLED_GUARD_REJECT:sub_res;
- return handled;
+ // if at least one guards rejects, the event will not generate a call to no_transition
+ if ((HANDLED_FALSE==sub_res) && (HANDLED_GUARD_REJECT==res) )
+ return HANDLED_GUARD_REJECT;
+ else
+ return sub_res;
                  }
                  return res;
             }

Modified: branches/release/boost/msm/back/history_policies.hpp
==============================================================================
--- branches/release/boost/msm/back/history_policies.hpp (original)
+++ branches/release/boost/msm/back/history_policies.hpp 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -36,7 +36,7 @@
     }
     // returns the state where the state machine should be at start
     template <class Event>
- int* const history_entry(Event const& )
+ const int* history_entry(Event const& )
     {
         // always come back to the original state
         return m_initialStates;
@@ -49,6 +49,11 @@
          }
          return *this;
     }
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int)
+ {
+ ar & m_initialStates;
+ }
 private:
     int m_initialStates[NumberOfRegions];
 };
@@ -72,7 +77,7 @@
     }
     // returns the state where the state machine should be at start
     template <class Event>
- int* const history_entry(Event const& )
+ const int* history_entry(Event const& )
     {
         // always load back the last active state
         return m_initialStates;
@@ -85,6 +90,11 @@
          }
          return *this;
     }
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int)
+ {
+ ar & m_initialStates;
+ }
 private:
     int m_initialStates[NumberOfRegions];
 };
@@ -111,7 +121,7 @@
     }
     // returns the state where the state machine should be at start
     template <class Event>
- int* const history_entry(Event const&)
+ const int* history_entry(Event const&)
     {
         if ( ::boost::mpl::contains<Events,Event>::value)
         {
@@ -129,6 +139,12 @@
          }
          return *this;
     }
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int)
+ {
+ ar & m_initialStates;
+ ar & m_currentStates;
+ }
 private:
     int m_initialStates[NumberOfRegions];
     int m_currentStates[NumberOfRegions];

Modified: branches/release/boost/msm/back/metafunctions.hpp
==============================================================================
--- branches/release/boost/msm/back/metafunctions.hpp (original)
+++ branches/release/boost/msm/back/metafunctions.hpp 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -648,7 +648,7 @@
 inline
 typename ::boost::disable_if<typename ::boost::mpl::and_<typename is_composite_state<FSM>::type,
                                                          typename is_pseudo_exit<StateType>::type>,bool >::type
-is_exit_state_active(FSM& fsm)
+is_exit_state_active(FSM&)
 {
     return false;
 }

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 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -31,6 +31,7 @@
 #include <boost/fusion/include/at_key.hpp>
 #include <boost/fusion/algorithm/iteration/for_each.hpp>
 #include <boost/fusion/include/for_each.hpp>
+#include <boost/fusion/include/for_each.hpp>
 
 #include <boost/assert.hpp>
 #include <boost/ref.hpp>
@@ -44,6 +45,9 @@
 #ifndef BOOST_NO_RTTI
 #include <boost/any.hpp>
 #endif
+
+#include <boost/serialization/base_object.hpp>
+
 #include <boost/msm/row_tags.hpp>
 #include <boost/msm/back/metafunctions.hpp>
 #include <boost/msm/back/history_policies.hpp>
@@ -58,6 +62,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(do_serialize)
 
 #ifndef BOOST_MSM_CONSTRUCTOR_ARG_SIZE
 #define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 5 // default max number of arguments for constructors
@@ -991,6 +996,11 @@
             {
                 ret_handled = HANDLED_TRUE;
             }
+
+ // process completion transitions BEFORE any other event in the pool (UML Standard 2.3 §15.3.14)
+ handle_eventless_transitions_helper<library_sm> eventless_helper(this,(handled == HANDLED_TRUE));
+ eventless_helper.process_completion_event();
+
             // after handling, take care of the deferred events
             defer_helper.do_post_handle_deferred(handled);
 
@@ -998,11 +1008,6 @@
             // because of another processing, and if yes, start handling them
             do_post_msg_queue_helper(::boost::mpl::bool_<is_no_message_queue<library_sm>::type::value>());
 
- // event can be handled, processing
- // handle with lowest priority event-less transitions
- handle_eventless_transitions_helper<library_sm> eventless_helper(this,(handled!=HANDLED_FALSE));
- eventless_helper.process_completion_event();
-
             return ret_handled;
         }
     }
@@ -1013,6 +1018,53 @@
         return this->m_states;
     }
 
+ template <class Archive>
+ struct serialize_state
+ {
+ serialize_state(Archive& ar):ar_(ar){}
+
+ template<typename T>
+ typename ::boost::enable_if<
+ typename ::boost::mpl::or_<
+ typename has_do_serialize<T>::type,
+ typename is_composite_state<T>::type
+ >::type
+ ,void
+ >::type
+ operator()(T& t) const
+ {
+ ar_ & t;
+ }
+ template<typename T>
+ typename ::boost::disable_if<
+ typename ::boost::mpl::or_<
+ typename has_do_serialize<T>::type,
+ typename is_composite_state<T>::type
+ >::type
+ ,void
+ >::type
+ operator()(T& t) const
+ {
+ // no state to serialize
+ }
+ Archive& ar_;
+ };
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int)
+ {
+ // invoke serialization of the base class
+ (serialize_state<Archive>(ar))(boost::serialization::base_object<Derived>(*this));
+ // now our attributes
+ ar & m_states;
+ // queues cannot be serialized => skip
+ ar & m_history;
+ ar & m_event_processing;
+ ar & m_is_included;
+ // visitors cannot be serialized => skip
+ ::boost::fusion::for_each(m_substate_list, serialize_state<Archive>(ar));
+ }
+
     // linearly search for the state with the given id
     struct get_state_id_helper
     {
@@ -1650,12 +1702,21 @@
 #undef MSM_VISITOR_ARGS_EXECUTE
 #undef MSM_VISITOR_ARGS_SUB
 
+// the IBM compiler seems to have problems with nested classes
+// the same seems to apply to the Apple version of gcc 4.0.1 (just in case we do for < 4.1)
+// and also to MS VC < 8
+#if defined (__IBMCPP__) || (defined (__APPLE_CC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 1)) || (defined(_MSC_VER) && (_MSC_VER < 1400))
+ public:
+#endif
     template<class ContainingSM>
     void set_containing_sm(ContainingSM* sm)
     {
         m_is_included=true;
         ::boost::fusion::for_each(m_substate_list,add_state<ContainingSM>(this,sm));
     }
+#if defined (__IBMCPP__) || (defined (__APPLE_CC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 1)) || (defined(_MSC_VER) && (_MSC_VER < 1400))
+ private:
+#endif
     // A function object for use with mpl::for_each that stuffs
     // states into the state list.
     template<class ContainingSM>
@@ -2012,6 +2073,10 @@
         m_history.history_exit(this->m_states);
      }
 
+ // the IBM and VC<8 compilers seem to have problems with the friend declaration of dispatch_table
+#if defined (__IBMCPP__) || (defined(_MSC_VER) && (_MSC_VER < 1400))
+ public:
+#endif
     // no transition for event.
     template <class Event>
     static HandledEnum call_no_transition(library_sm& , int , int , Event const& )
@@ -2025,7 +2090,6 @@
         fsm.defer_event(e);
         return HANDLED_DEFERRED;
     }
-
     // called for completion events. Default address set in the dispatch_table at init
     // prevents no-transition detection for completion events
     template <class Event>
@@ -2033,7 +2097,9 @@
     {
         return HANDLED_FALSE;
     }
-
+#if defined (__IBMCPP__) || (defined(_MSC_VER) && (_MSC_VER < 1400))
+ private:
+#endif
     // puts a deferred event in the queue
     void post_deferred_event(deferred_fct& deferred)
     {

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 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -197,6 +197,18 @@
     : proto::domain< proto::generator<euml_terminal>, terminal_grammar >
 {};
 
+struct state_grammar :
+ proto::and_<
+ proto::not_<proto::address_of<proto::_> >,
+ proto::not_<proto::shift_right<proto::_,proto::_> >,
+ proto::not_<proto::shift_left<proto::_,proto::_> >,
+ proto::not_<proto::bitwise_and<proto::_,proto::_> >
+ >
+{};
+struct state_domain
+ : proto::domain< proto::generator<euml_terminal>, state_grammar,sm_domain >
+{};
+
 template<typename Expr>
 struct euml_terminal
     : proto::extends<Expr, euml_terminal<Expr>, sm_domain>
@@ -229,10 +241,10 @@
     };
 };
 template <class STATE>
-struct euml_state: proto::extends<typename proto::terminal<state_tag>::type, STATE, sm_domain>
+struct euml_state: proto::extends<typename proto::terminal<state_tag>::type, STATE, state_domain>
 {
     typedef state_tag euml_tag_type;
- using proto::extends<typename proto::terminal<state_tag>::type, STATE, sm_domain>::operator=;
+ using proto::extends<typename proto::terminal<state_tag>::type, STATE, state_domain>::operator=;
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
 #ifdef BOOST_MSVC
  ,class Arg6
@@ -362,6 +374,7 @@
 };
 NoAction const no_action;
 
+struct fsm_artefact_tag {};
 template <class Index=void>
 struct GetSource_ : euml_action<GetSource_<Index> >
 {
@@ -397,8 +410,7 @@
         return src;
     }
 };
-struct get_source_tag {};
-struct GetSource_Helper: proto::extends< proto::terminal<get_source_tag>::type, GetSource_Helper, sm_domain>
+struct GetSource_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetSource_Helper, sm_domain>
 {
     GetSource_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -448,8 +460,7 @@
         return tgt;
     }
 };
-struct get_target_tag {};
-struct GetTarget_Helper: proto::extends< proto::terminal<get_target_tag>::type, GetTarget_Helper, sm_domain>
+struct GetTarget_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetTarget_Helper, sm_domain>
 {
     GetTarget_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -501,8 +512,7 @@
         return state;
     }
 };
-struct get_state_tag {};
-struct GetState_Helper: proto::extends< proto::terminal<get_state_tag>::type, GetState_Helper, sm_domain>
+struct GetState_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetState_Helper, sm_domain>
 {
     GetState_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -577,8 +587,7 @@
         return evt;
     }
 };
-struct get_event_tag {};
-struct GetEvent_Helper: proto::extends< proto::terminal<get_event_tag>::type, GetEvent_Helper, sm_domain>
+struct GetEvent_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetEvent_Helper, sm_domain>
 {
     GetEvent_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -653,8 +662,7 @@
         return fsm;
     }
 };
-struct get_fsm_tag {};
-struct GetFsm_Helper: proto::extends< proto::terminal<get_fsm_tag>::type, GetFsm_Helper, sm_domain>
+struct GetFsm_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetFsm_Helper, sm_domain>
 {
     GetFsm_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -725,11 +733,10 @@
     }
 };
 
-struct substate_tag {};
-struct SubState_Helper: proto::extends< proto::terminal<substate_tag>::type, SubState_Helper, sm_domain>
+struct SubState_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, SubState_Helper, sm_domain>
 {
     SubState_Helper(){}
- using proto::extends< proto::terminal<substate_tag>::type, SubState_Helper, sm_domain>::operator=;
+ using proto::extends< proto::terminal<fsm_artefact_tag>::type, SubState_Helper, sm_domain>::operator=;
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
 #ifdef BOOST_MSVC
  ,class Arg6
@@ -789,10 +796,7 @@
     }
 };
 
-struct get_attribute_tag
-{
-};
-struct GetAttribute_Helper: proto::extends< proto::terminal<get_attribute_tag>::type, GetAttribute_Helper, sm_domain>
+struct GetAttribute_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetAttribute_Helper, sm_domain>
 {
     GetAttribute_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -1544,10 +1548,7 @@
     }
 };
 
-struct get_flag_tag
-{
-};
-struct Get_Flag_Helper: proto::extends< proto::terminal<get_flag_tag>::type, Get_Flag_Helper, sm_domain>
+struct Get_Flag_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, Get_Flag_Helper, sm_domain>
 {
     Get_Flag_Helper(){}
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
@@ -1572,11 +1573,10 @@
         fsm.defer_event(evt);
     }
 };
-struct defer_event_tag {};
-struct Defer_Helper : proto::extends< proto::terminal<defer_event_tag>::type, Defer_Helper, sm_domain>
+struct Defer_Helper : proto::extends< proto::terminal<fsm_artefact_tag>::type, Defer_Helper, sm_domain>
 {
     Defer_Helper(){}
- using proto::extends< proto::terminal<defer_event_tag>::type, Defer_Helper, sm_domain>::operator=;
+ using proto::extends< proto::terminal<fsm_artefact_tag>::type, Defer_Helper, sm_domain>::operator=;
     template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
 #ifdef BOOST_MSVC
  ,class Arg6

Modified: branches/release/boost/msm/front/euml/guard_grammar.hpp
==============================================================================
--- branches/release/boost/msm/front/euml/guard_grammar.hpp (original)
+++ branches/release/boost/msm/front/euml/guard_grammar.hpp 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -321,21 +321,29 @@
 struct BuildGuardsCases::case_<proto::tag::terminal>
     : proto::or_<
         proto::when <
- proto::terminal<action_tag>,
- get_action_name<proto::_ >()
- >,
+ proto::terminal<action_tag>,
+ get_action_name<proto::_ >()
+ >,
         proto::when<
- proto::terminal<state_tag>,
- proto::_
- >,
+ proto::terminal<state_tag>,
+ proto::_
+ >,
         proto::when<
- proto::terminal<flag_tag>,
- proto::_
- >,
+ proto::terminal<flag_tag>,
+ proto::_
+ >,
         proto::when<
- proto::terminal<event_tag>,
- proto::_
- >
+ proto::terminal<event_tag>,
+ proto::_
+ >,
+ proto::when<
+ proto::terminal<fsm_artefact_tag>,
+ get_fct<proto::_ >()
+ >,
+ proto::when<
+ proto::terminal<proto::_>,
+ proto::_child
+ >
>
 {};
 

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 2010-10-08 17:05:24 EDT (Fri, 08 Oct 2010)
@@ -484,23 +484,27 @@
         proto::when<
             proto::terminal<action_tag>,
             get_action_name<proto::_ >()
- >,
+ >,
         proto::when<
             proto::terminal<state_tag>,
             proto::_
- >,
+ >,
         proto::when<
             proto::terminal<flag_tag>,
             proto::_
- >,
+ >,
         proto::when<
             proto::terminal<event_tag>,
             proto::_
- >,
+ >,
         proto::when<
- proto::terminal<proto::_>,
- get_fct<proto::_ >()
- >
+ proto::terminal<fsm_artefact_tag>,
+ get_fct<proto::_ >()
+ >,
+ proto::when<
+ proto::terminal<proto::_>,
+ proto::_child
+ >
>
 {};
 struct BuildActions


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