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_HPP
|
Chris@16
|
12 #define BOOST_MSM_ROW2_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/type_traits/is_base_of.hpp>
|
Chris@16
|
15 #include <boost/mpl/bool.hpp>
|
Chris@16
|
16 #include <boost/fusion/include/at_key.hpp>
|
Chris@16
|
17 #include <boost/msm/back/common_types.hpp>
|
Chris@16
|
18 #include <boost/msm/row_tags.hpp>
|
Chris@16
|
19 #include <boost/msm/front/detail/row2_helper.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace msm { namespace front
|
Chris@16
|
22 {
|
Chris@16
|
23 template<
|
Chris@16
|
24 typename T1
|
Chris@16
|
25 , class Event
|
Chris@16
|
26 , typename T2
|
Chris@16
|
27 >
|
Chris@16
|
28 struct _row2
|
Chris@16
|
29 {
|
Chris@16
|
30 typedef _row_tag row_type_tag;
|
Chris@16
|
31 typedef T1 Source;
|
Chris@16
|
32 typedef T2 Target;
|
Chris@16
|
33 typedef Event Evt;
|
Chris@16
|
34 };
|
Chris@16
|
35
|
Chris@16
|
36 template<
|
Chris@16
|
37 typename T1
|
Chris@16
|
38 , class Event
|
Chris@16
|
39 , typename T2
|
Chris@16
|
40 , typename CalledForAction
|
Chris@16
|
41 , void (CalledForAction::*action)(Event const&)
|
Chris@16
|
42 >
|
Chris@16
|
43 struct a_row2
|
Chris@16
|
44 {
|
Chris@16
|
45 typedef a_row_tag row_type_tag;
|
Chris@16
|
46 typedef T1 Source;
|
Chris@16
|
47 typedef T2 Target;
|
Chris@16
|
48 typedef Event Evt;
|
Chris@16
|
49 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
50 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
51 AllStates& all_states)
|
Chris@16
|
52 {
|
Chris@16
|
53 // in this front-end, we don't need to know source and target states
|
Chris@16
|
54 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::template call_helper
|
Chris@16
|
55 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
56 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
|
Chris@16
|
57 return ::boost::msm::back::HANDLED_TRUE;
|
Chris@16
|
58 }
|
Chris@16
|
59 };
|
Chris@16
|
60
|
Chris@16
|
61 template<
|
Chris@16
|
62 typename T1
|
Chris@16
|
63 , class Event
|
Chris@16
|
64 , typename T2
|
Chris@16
|
65 , typename CalledForAction
|
Chris@16
|
66 , void (CalledForAction::*action)(Event const&)
|
Chris@16
|
67 , typename CalledForGuard
|
Chris@16
|
68 , bool (CalledForGuard::*guard)(Event const&)
|
Chris@16
|
69 >
|
Chris@16
|
70 struct row2
|
Chris@16
|
71 {
|
Chris@16
|
72 typedef row_tag row_type_tag;
|
Chris@16
|
73 typedef T1 Source;
|
Chris@16
|
74 typedef T2 Target;
|
Chris@16
|
75 typedef Event Evt;
|
Chris@16
|
76 template <class FSM,class SourceState,class TargetState, class AllStates>
|
Chris@16
|
77 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
78 AllStates& all_states)
|
Chris@16
|
79 {
|
Chris@16
|
80 // in this front-end, we don't need to know source and target states
|
Chris@16
|
81 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
|
Chris@16
|
82 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
83 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
|
Chris@16
|
84 return ::boost::msm::back::HANDLED_TRUE;
|
Chris@16
|
85 }
|
Chris@16
|
86 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
87 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
88 AllStates& all_states)
|
Chris@16
|
89 {
|
Chris@16
|
90 // in this front-end, we don't need to know source and target states
|
Chris@16
|
91 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
|
Chris@16
|
92 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
93 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
|
Chris@16
|
94 }
|
Chris@16
|
95 };
|
Chris@16
|
96 template<
|
Chris@16
|
97 typename T1
|
Chris@16
|
98 , class Event
|
Chris@16
|
99 , typename T2
|
Chris@16
|
100 , typename CalledForGuard
|
Chris@16
|
101 , bool (CalledForGuard::*guard)(Event const&)
|
Chris@16
|
102 >
|
Chris@16
|
103 struct g_row2
|
Chris@16
|
104 {
|
Chris@16
|
105 typedef g_row_tag row_type_tag;
|
Chris@16
|
106 typedef T1 Source;
|
Chris@16
|
107 typedef T2 Target;
|
Chris@16
|
108 typedef Event Evt;
|
Chris@16
|
109 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
110 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
111 AllStates& all_states)
|
Chris@16
|
112 {
|
Chris@16
|
113 // in this front-end, we don't need to know source and target states
|
Chris@16
|
114 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
|
Chris@16
|
115 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
116 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
|
Chris@16
|
117 }
|
Chris@16
|
118 };
|
Chris@16
|
119 // internal transitions
|
Chris@16
|
120 template<
|
Chris@16
|
121 typename T1
|
Chris@16
|
122 , class Event
|
Chris@16
|
123 , typename CalledForAction
|
Chris@16
|
124 , void (CalledForAction::*action)(Event const&)
|
Chris@16
|
125 >
|
Chris@16
|
126 struct a_irow2
|
Chris@16
|
127 {
|
Chris@16
|
128 typedef a_irow_tag row_type_tag;
|
Chris@16
|
129 typedef T1 Source;
|
Chris@16
|
130 typedef T1 Target;
|
Chris@16
|
131 typedef Event Evt;
|
Chris@16
|
132 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
133 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
134 AllStates& all_states)
|
Chris@16
|
135 {
|
Chris@16
|
136 // in this front-end, we don't need to know source and target states
|
Chris@16
|
137 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
|
Chris@16
|
138 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
139 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
|
Chris@16
|
140 return ::boost::msm::back::HANDLED_TRUE;
|
Chris@16
|
141 }
|
Chris@16
|
142 };
|
Chris@16
|
143
|
Chris@16
|
144 template<
|
Chris@16
|
145 typename T1
|
Chris@16
|
146 , class Event
|
Chris@16
|
147 , typename CalledForAction
|
Chris@16
|
148 , void (CalledForAction::*action)(Event const&)
|
Chris@16
|
149 , typename CalledForGuard
|
Chris@16
|
150 , bool (CalledForGuard::*guard)(Event const&)
|
Chris@16
|
151 >
|
Chris@16
|
152 struct irow2
|
Chris@16
|
153 {
|
Chris@16
|
154 typedef irow_tag row_type_tag;
|
Chris@16
|
155 typedef T1 Source;
|
Chris@16
|
156 typedef T1 Target;
|
Chris@16
|
157 typedef Event Evt;
|
Chris@16
|
158 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
159 static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
160 AllStates& all_states)
|
Chris@16
|
161 {
|
Chris@16
|
162 // in this front-end, we don't need to know source and target states
|
Chris@16
|
163 ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
|
Chris@16
|
164 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
165 ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
|
Chris@16
|
166 return ::boost::msm::back::HANDLED_TRUE;
|
Chris@16
|
167 }
|
Chris@16
|
168 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
169 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
170 AllStates& all_states)
|
Chris@16
|
171 {
|
Chris@16
|
172 // in this front-end, we don't need to know source and target states
|
Chris@16
|
173 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
|
Chris@16
|
174 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
175 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
|
Chris@16
|
176 }
|
Chris@16
|
177 };
|
Chris@16
|
178 template<
|
Chris@16
|
179 typename T1
|
Chris@16
|
180 , class Event
|
Chris@16
|
181 , typename CalledForGuard
|
Chris@16
|
182 , bool (CalledForGuard::*guard)(Event const&)
|
Chris@16
|
183 >
|
Chris@16
|
184 struct g_irow2
|
Chris@16
|
185 {
|
Chris@16
|
186 typedef g_irow_tag row_type_tag;
|
Chris@16
|
187 typedef T1 Source;
|
Chris@16
|
188 typedef T1 Target;
|
Chris@16
|
189 typedef Event Evt;
|
Chris@16
|
190 template <class FSM,class SourceState,class TargetState,class AllStates>
|
Chris@16
|
191 static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
|
Chris@16
|
192 AllStates& all_states)
|
Chris@16
|
193 {
|
Chris@16
|
194 // in this front-end, we don't need to know source and target states
|
Chris@16
|
195 return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
|
Chris@16
|
196 (fsm,evt,src,tgt,all_states,
|
Chris@16
|
197 ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
|
Chris@16
|
198 }
|
Chris@16
|
199 };
|
Chris@16
|
200
|
Chris@16
|
201 }}}
|
Chris@16
|
202
|
Chris@16
|
203 #endif //BOOST_MSM_ROW2_HPP
|
Chris@16
|
204
|