Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59061 - sandbox/msm/boost/msm/front
From: christophe.j.henry_at_[hidden]
Date: 2010-01-15 17:41:38


Author: chenry
Date: 2010-01-15 17:41:37 EST (Fri, 15 Jan 2010)
New Revision: 59061
URL: http://svn.boost.org/trac/boost/changeset/59061

Log:
- actualized action/guards to the new parameter (unused in functor and row types)
- added row2, which uses this new parameter to offer sc-like syntax
Added:
   sandbox/msm/boost/msm/front/row2.hpp (contents, props changed)
Text files modified:
   sandbox/msm/boost/msm/front/functor_row.hpp | 48 ++++++++++++++++++++--------------------
   sandbox/msm/boost/msm/front/state_machine_def.hpp | 32 +++++++++++++-------------
   2 files changed, 40 insertions(+), 40 deletions(-)

Modified: sandbox/msm/boost/msm/front/functor_row.hpp
==============================================================================
--- sandbox/msm/boost/msm/front/functor_row.hpp (original)
+++ sandbox/msm/boost/msm/front/functor_row.hpp 2010-01-15 17:41:37 EST (Fri, 15 Jan 2010)
@@ -34,14 +34,14 @@
         typedef GUARD Guard;
         // action plus guard
         typedef row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
         }
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt,AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);
@@ -69,8 +69,8 @@
         typedef none Guard;
         // no guard
         typedef a_row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
@@ -86,8 +86,8 @@
         typedef GUARD Guard;
         // no action
         typedef g_row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);
@@ -104,8 +104,8 @@
         typedef none Guard;
         // no guard
         typedef a_irow_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
@@ -121,8 +121,8 @@
         typedef GUARD Guard;
         // no action
         typedef g_irow_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);
@@ -138,14 +138,14 @@
         typedef GUARD Guard;
         // action + guard
         typedef irow_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
         }
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);
@@ -165,14 +165,14 @@
         typedef GUARD Guard;
         // action plus guard
         typedef sm_i_row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
         }
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);
@@ -187,8 +187,8 @@
         typedef none Guard;
         // no guard
         typedef sm_a_i_row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             Action()(evt,fsm,src,tgt);
@@ -202,8 +202,8 @@
         typedef GUARD Guard;
         // no action
         typedef sm_g_i_row_tag row_type_tag;
- template <class EVT,class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt)
+ template <class EVT,class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&)
         {
             // create functor, call it
             return Guard()(evt,fsm,src,tgt);

Added: sandbox/msm/boost/msm/front/row2.hpp
==============================================================================
--- (empty file)
+++ sandbox/msm/boost/msm/front/row2.hpp 2010-01-15 17:41:37 EST (Fri, 15 Jan 2010)
@@ -0,0 +1,234 @@
+// Copyright 2008 Christophe Henry
+// henry UNDERSCORE christophe AT hotmail DOT com
+// This is an extended version of the state machine available in the boost::mpl library
+// Distributed under the same license as the original.
+// Copyright for the original version:
+// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
+// under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_MSM_ROW2_HPP
+#define BOOST_MSM_ROW2_HPP
+
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/fusion/include/at_key.hpp>
+#include <boost/msm/row_tags.hpp>
+
+namespace boost { namespace msm { namespace front
+{
+ namespace detail
+ {
+ template<
+ typename CalledForAction
+ , typename Event
+ , void (CalledForAction::*action)(Event const&)
+ >
+ struct row2_action_helper
+ {
+ template <class FSM,class Event,class SourceState,class TargetState, class AllStates>
+ static void call_helper(FSM&,Event const& evt,SourceState&,TargetState&,
+ AllStates& all_states,::boost::mpl::false_ const &)
+ {
+ // in this front-end, we don't need to know source and target states
+ ( ::boost::fusion::at_key<CalledForAction>(all_states).*action)(evt);
+ }
+ template <class FSM,class Event,class SourceState,class TargetState, class AllStates>
+ static void call_helper(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&,
+ ::boost::mpl::true_ const &)
+ {
+ // in this front-end, we don't need to know source and target states
+ (fsm.*action)(evt);
+ }
+ };
+
+ template<
+ typename CalledForGuard
+ , typename Event
+ , bool (CalledForGuard::*guard)(Event const&)
+ >
+ struct row2_guard_helper
+ {
+ template <class FSM,class Event,class SourceState,class TargetState,class AllStates>
+ static bool call_helper(FSM&,Event const& evt,SourceState&,TargetState&,
+ AllStates& all_states, ::boost::mpl::false_ const &)
+ {
+ // in this front-end, we don't need to know source and target states
+ return ( ::boost::fusion::at_key<CalledForGuard>(all_states).*guard)(evt);
+ }
+ template <class FSM,class Event,class SourceState,class TargetState,class AllStates>
+ static bool call_helper(FSM& fsm,Event const& evt,SourceState&,TargetState&,
+ AllStates&,::boost::mpl::true_ const &)
+ {
+ // in this front-end, we don't need to know source and target states
+ return (fsm.*guard)(evt);
+ }
+ };
+ }
+
+ template<
+ typename T1
+ , class Event
+ , typename T2
+ , typename CalledForAction
+ , void (CalledForAction::*action)(Event const&)
+ >
+ struct a_row2
+ {
+ typedef a_row_tag row_type_tag;
+ typedef T1 Source;
+ typedef T2 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ detail::row2_action_helper<CalledForAction,Event,action>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
+ }
+ };
+
+ template<
+ typename T1
+ , class Event
+ , typename T2
+ , typename CalledForAction
+ , void (CalledForAction::*action)(Event const&)
+ , typename CalledForGuard
+ , bool (CalledForGuard::*guard)(Event const&)
+ >
+ struct row2
+ {
+ typedef row_tag row_type_tag;
+ typedef T1 Source;
+ typedef T2 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState, class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ detail::row2_action_helper<CalledForAction,Event,action>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
+ }
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ return detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
+ }
+ };
+ template<
+ typename T1
+ , class Event
+ , typename T2
+ , typename CalledForGuard
+ , bool (CalledForGuard::*guard)(Event const&)
+ >
+ struct g_row2
+ {
+ typedef g_row_tag row_type_tag;
+ typedef T1 Source;
+ typedef T2 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ return detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
+ }
+ };
+ // internal transitions
+ template<
+ typename T1
+ , class Event
+ , typename CalledForAction
+ , void (CalledForAction::*action)(Event const&)
+ >
+ struct a_irow2
+ {
+ typedef a_irow_tag row_type_tag;
+ typedef T1 Source;
+ typedef T1 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ detail::row2_action_helper<CalledForAction,Event,action>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
+ }
+ };
+
+ template<
+ typename T1
+ , class Event
+ , typename CalledForAction
+ , void (CalledForAction::*action)(Event const&)
+ , typename CalledForGuard
+ , bool (CalledForGuard::*guard)(Event const&)
+ >
+ struct irow2
+ {
+ typedef irow_tag row_type_tag;
+ typedef T1 Source;
+ typedef T1 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ detail::row2_action_helper<CalledForAction,Event,action>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
+ }
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ return detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
+ }
+ };
+ template<
+ typename T1
+ , class Event
+ , typename CalledForGuard
+ , bool (CalledForGuard::*guard)(Event const&)
+ >
+ struct g_irow2
+ {
+ typedef g_irow_tag row_type_tag;
+ typedef T1 Source;
+ typedef T1 Target;
+ typedef Event Evt;
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
+ AllStates& all_states)
+ {
+ // in this front-end, we don't need to know source and target states
+ return detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
+ (fsm,evt,src,tgt,all_states,
+ ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
+ }
+ };
+
+}}}
+
+#endif //BOOST_MSM_ROW2_HPP
+

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-01-15 17:41:37 EST (Fri, 15 Jan 2010)
@@ -45,8 +45,8 @@
                 typedef T1 Source;
                 typedef T2 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&, AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             (fsm.*action)(evt);
@@ -79,14 +79,14 @@
                 typedef T1 Source;
                 typedef T2 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState, class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             (fsm.*action)(evt);
         }
- template <class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             return (fsm.*guard)(evt);
@@ -104,8 +104,8 @@
                 typedef T1 Source;
                 typedef T2 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             return (fsm.*guard)(evt);
@@ -123,8 +123,8 @@
                 typedef T1 Source;
                 typedef T1 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             (fsm.*action)(evt);
@@ -143,14 +143,14 @@
                 typedef T1 Source;
                 typedef T1 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static void action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             (fsm.*action)(evt);
         }
- template <class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             return (fsm.*guard)(evt);
@@ -167,8 +167,8 @@
                 typedef T1 Source;
                 typedef T1 Target;
                 typedef Event Evt;
- template <class FSM,class SourceState,class TargetState>
- static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&)
+ template <class FSM,class SourceState,class TargetState,class AllStates>
+ static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&)
         {
             // in this front-end, we don't need to know source and target states
             return (fsm.*guard)(evt);


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