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)
11 #ifndef BOOST_MSM_ROW2_HPP
12 #define BOOST_MSM_ROW2_HPP
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>
21 namespace boost { namespace msm { namespace front
30 typedef _row_tag row_type_tag;
40 , typename CalledForAction
41 , void (CalledForAction::*action)(Event const&)
45 typedef a_row_tag row_type_tag;
49 template <class FSM,class SourceState,class TargetState,class AllStates>
50 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
51 AllStates& all_states)
53 // in this front-end, we don't need to know source and target states
54 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::template call_helper
55 (fsm,evt,src,tgt,all_states,
56 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
57 return ::boost::msm::back::HANDLED_TRUE;
65 , typename CalledForAction
66 , void (CalledForAction::*action)(Event const&)
67 , typename CalledForGuard
68 , bool (CalledForGuard::*guard)(Event const&)
72 typedef row_tag row_type_tag;
76 template <class FSM,class SourceState,class TargetState, class AllStates>
77 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
78 AllStates& all_states)
80 // in this front-end, we don't need to know source and target states
81 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
82 (fsm,evt,src,tgt,all_states,
83 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
84 return ::boost::msm::back::HANDLED_TRUE;
86 template <class FSM,class SourceState,class TargetState,class AllStates>
87 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
88 AllStates& all_states)
90 // in this front-end, we don't need to know source and target states
91 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
92 (fsm,evt,src,tgt,all_states,
93 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
100 , typename CalledForGuard
101 , bool (CalledForGuard::*guard)(Event const&)
105 typedef g_row_tag row_type_tag;
109 template <class FSM,class SourceState,class TargetState,class AllStates>
110 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
111 AllStates& all_states)
113 // in this front-end, we don't need to know source and target states
114 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
115 (fsm,evt,src,tgt,all_states,
116 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
119 // internal transitions
123 , typename CalledForAction
124 , void (CalledForAction::*action)(Event const&)
128 typedef a_irow_tag row_type_tag;
132 template <class FSM,class SourceState,class TargetState,class AllStates>
133 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
134 AllStates& all_states)
136 // in this front-end, we don't need to know source and target states
137 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
138 (fsm,evt,src,tgt,all_states,
139 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
140 return ::boost::msm::back::HANDLED_TRUE;
147 , typename CalledForAction
148 , void (CalledForAction::*action)(Event const&)
149 , typename CalledForGuard
150 , bool (CalledForGuard::*guard)(Event const&)
154 typedef irow_tag row_type_tag;
158 template <class FSM,class SourceState,class TargetState,class AllStates>
159 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
160 AllStates& all_states)
162 // in this front-end, we don't need to know source and target states
163 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
164 (fsm,evt,src,tgt,all_states,
165 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
166 return ::boost::msm::back::HANDLED_TRUE;
168 template <class FSM,class SourceState,class TargetState,class AllStates>
169 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
170 AllStates& all_states)
172 // in this front-end, we don't need to know source and target states
173 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
174 (fsm,evt,src,tgt,all_states,
175 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
181 , typename CalledForGuard
182 , bool (CalledForGuard::*guard)(Event const&)
186 typedef g_irow_tag row_type_tag;
190 template <class FSM,class SourceState,class TargetState,class AllStates>
191 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
192 AllStates& all_states)
194 // in this front-end, we don't need to know source and target states
195 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
196 (fsm,evt,src,tgt,all_states,
197 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
203 #endif //BOOST_MSM_ROW2_HPP