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_INTERNAL_ROW_HPP
12 #define BOOST_MSM_INTERNAL_ROW_HPP
13 
14 #include <boost/type_traits/is_base_of.hpp>
15 #include <boost/mpl/bool.hpp>
16 #include <boost/fusion/include/at_key.hpp>
17 #include <boost/msm/back/common_types.hpp>
18 #include <boost/msm/row_tags.hpp>
19 #include <boost/msm/front/detail/row2_helper.hpp>
20 
21 namespace boost { namespace msm { namespace front
22 {
23     template<
24         class Event
25         , typename CalledForAction
26         , void (CalledForAction::*action)(Event const&)
27     >
28     struct a_internal
29     {
30         typedef sm_a_i_row_tag row_type_tag;
31         typedef Event Evt;
32         template <class FSM,class SourceState,class TargetState,class AllStates>
action_callboost::msm::front::a_internal33         static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
34                                 AllStates& all_states)
35         {
36             // in this front-end, we don't need to know source and target states
37             ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
38                 (fsm,evt,src,tgt,all_states,
39                 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
40             return ::boost::msm::back::HANDLED_TRUE;
41         }
42     };
43 
44     template<
45         class Event
46         , typename CalledForAction
47         , void (CalledForAction::*action)(Event const&)
48         , typename CalledForGuard
49         , bool (CalledForGuard::*guard)(Event const&)
50     >
51     struct internal
52     {
53         typedef sm_i_row_tag row_type_tag;
54         typedef Event Evt;
55         template <class FSM,class SourceState,class TargetState,class AllStates>
action_callboost::msm::front::internal56         static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
57                                 AllStates& all_states)
58         {
59             // in this front-end, we don't need to know source and target states
60             ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
61                 (fsm,evt,src,tgt,all_states,
62                 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
63             return ::boost::msm::back::HANDLED_TRUE;
64         }
65         template <class FSM,class SourceState,class TargetState,class AllStates>
guard_callboost::msm::front::internal66         static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
67                                AllStates& all_states)
68         {
69             // in this front-end, we don't need to know source and target states
70             return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
71                 (fsm,evt,src,tgt,all_states,
72                 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
73         }
74     };
75     template<
76         class Event
77         , typename CalledForGuard
78         , bool (CalledForGuard::*guard)(Event const&)
79     >
80     struct g_internal
81     {
82         typedef sm_g_i_row_tag row_type_tag;
83         typedef Event Evt;
84         template <class FSM,class SourceState,class TargetState,class AllStates>
guard_callboost::msm::front::g_internal85         static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
86                                AllStates& all_states)
87         {
88             // in this front-end, we don't need to know source and target states
89             return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
90                 (fsm,evt,src,tgt,all_states,
91                 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
92         }
93     };
94     template<
95         class Event
96     >
97     struct _internal
98     {
99         typedef sm__i_row_tag row_type_tag;
100         typedef Event Evt;
101     };
102 }}}
103 
104 #endif //BOOST_MSM_INTERNAL_ROW_HPP
105 
106