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