Chris@16
|
1 // Copyright 2008 Christophe Henry
|
Chris@16
|
2 // henry UNDERSCORE christophe AT hotmail DOT com
|
Chris@16
|
3 // This is an extended version of the state machine available in the boost::mpl library
|
Chris@16
|
4 // Distributed under the same license as the original.
|
Chris@16
|
5 // Copyright for the original version:
|
Chris@16
|
6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
|
Chris@16
|
7 // under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at
|
Chris@16
|
9 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_MSM_ROW2_HELPER_HPP
|
Chris@16
|
12 #define BOOST_MSM_ROW2_HELPER_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/mpl/bool.hpp>
|
Chris@16
|
15 #include <boost/fusion/include/at_key.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost { namespace msm { namespace front
|
Chris@16
|
18 {
|
Chris@16
|
19 namespace detail
|
Chris@16
|
20 {
|
Chris@16
|
21 template<
|
Chris@16
|
22 typename CalledForAction
|
Chris@16
|
23 , typename Event
|
Chris@16
|
24 , void (CalledForAction::*action)(Event const&)
|
Chris@16
|
25 >
|
Chris@16
|
26 struct row2_action_helper
|
Chris@16
|
27 {
|
Chris@16
|
28 template <class FSM,class Evt,class SourceState,class TargetState, class AllStates>
|
Chris@16
|
29 static void call_helper(FSM&,Evt const& evt,SourceState&,TargetState&,
|
Chris@16
|
30 AllStates& all_states,::boost::mpl::false_ const &)
|
Chris@16
|
31 {
|
Chris@16
|
32 // in this front-end, we don't need to know source and target states
|
Chris@16
|
33 ( ::boost::fusion::at_key<CalledForAction>(all_states).*action)(evt);
|
Chris@16
|
34 }
|
Chris@16
|
35 template <class FSM,class Evt,class SourceState,class TargetState, class AllStates>
|
Chris@16
|
36 static void call_helper(FSM& fsm,Evt const& evt,SourceState&,TargetState&,AllStates&,
|
Chris@16
|
37 ::boost::mpl::true_ const &)
|
Chris@16
|
38 {
|
Chris@16
|
39 // in this front-end, we don't need to know source and target states
|
Chris@16
|
40 (fsm.*action)(evt);
|
Chris@16
|
41 }
|
Chris@16
|
42 };
|
Chris@16
|
43
|
Chris@16
|
44 template<
|
Chris@16
|
45 typename CalledForGuard
|
Chris@16
|
46 , typename Event
|
Chris@16
|
47 , bool (CalledForGuard::*guard)(Event const&)
|
Chris@16
|
48 >
|
Chris@16
|
49 struct row2_guard_helper
|
Chris@16
|
50 {
|
Chris@16
|
51 template <class FSM,class Evt,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
52 static bool call_helper(FSM&,Evt const& evt,SourceState&,TargetState&,
|
Chris@16
|
53 AllStates& all_states, ::boost::mpl::false_ const &)
|
Chris@16
|
54 {
|
Chris@16
|
55 // in this front-end, we don't need to know source and target states
|
Chris@16
|
56 return ( ::boost::fusion::at_key<CalledForGuard>(all_states).*guard)(evt);
|
Chris@16
|
57 }
|
Chris@16
|
58 template <class FSM,class Evt,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
59 static bool call_helper(FSM& fsm,Evt const& evt,SourceState&,TargetState&,
|
Chris@16
|
60 AllStates&,::boost::mpl::true_ const &)
|
Chris@16
|
61 {
|
Chris@16
|
62 // in this front-end, we don't need to know source and target states
|
Chris@16
|
63 return (fsm.*guard)(evt);
|
Chris@16
|
64 }
|
Chris@16
|
65 };
|
Chris@16
|
66 }
|
Chris@16
|
67
|
Chris@16
|
68 }}}
|
Chris@16
|
69
|
Chris@16
|
70 #endif //BOOST_MSM_ROW2_HELPER_HPP
|
Chris@16
|
71
|