]>
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_HPP | |
12 | #define BOOST_MSM_ROW2_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 | typename T1 | |
25 | , class Event | |
26 | , typename T2 | |
27 | > | |
28 | struct _row2 | |
29 | { | |
30 | typedef _row_tag row_type_tag; | |
31 | typedef T1 Source; | |
32 | typedef T2 Target; | |
33 | typedef Event Evt; | |
34 | }; | |
35 | ||
36 | template< | |
37 | typename T1 | |
38 | , class Event | |
39 | , typename T2 | |
40 | , typename CalledForAction | |
41 | , void (CalledForAction::*action)(Event const&) | |
42 | > | |
43 | struct a_row2 | |
44 | { | |
45 | typedef a_row_tag row_type_tag; | |
46 | typedef T1 Source; | |
47 | typedef T2 Target; | |
48 | typedef Event Evt; | |
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) | |
52 | { | |
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; | |
58 | } | |
59 | }; | |
60 | ||
61 | template< | |
62 | typename T1 | |
63 | , class Event | |
64 | , typename T2 | |
65 | , typename CalledForAction | |
66 | , void (CalledForAction::*action)(Event const&) | |
67 | , typename CalledForGuard | |
68 | , bool (CalledForGuard::*guard)(Event const&) | |
69 | > | |
70 | struct row2 | |
71 | { | |
72 | typedef row_tag row_type_tag; | |
73 | typedef T1 Source; | |
74 | typedef T2 Target; | |
75 | typedef Event Evt; | |
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) | |
79 | { | |
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; | |
85 | } | |
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) | |
89 | { | |
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>()); | |
94 | } | |
95 | }; | |
96 | template< | |
97 | typename T1 | |
98 | , class Event | |
99 | , typename T2 | |
100 | , typename CalledForGuard | |
101 | , bool (CalledForGuard::*guard)(Event const&) | |
102 | > | |
103 | struct g_row2 | |
104 | { | |
105 | typedef g_row_tag row_type_tag; | |
106 | typedef T1 Source; | |
107 | typedef T2 Target; | |
108 | typedef Event Evt; | |
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) | |
112 | { | |
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>()); | |
117 | } | |
118 | }; | |
119 | // internal transitions | |
120 | template< | |
121 | typename T1 | |
122 | , class Event | |
123 | , typename CalledForAction | |
124 | , void (CalledForAction::*action)(Event const&) | |
125 | > | |
126 | struct a_irow2 | |
127 | { | |
128 | typedef a_irow_tag row_type_tag; | |
129 | typedef T1 Source; | |
130 | typedef T1 Target; | |
131 | typedef Event Evt; | |
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) | |
135 | { | |
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; | |
141 | } | |
142 | }; | |
143 | ||
144 | template< | |
145 | typename T1 | |
146 | , class Event | |
147 | , typename CalledForAction | |
148 | , void (CalledForAction::*action)(Event const&) | |
149 | , typename CalledForGuard | |
150 | , bool (CalledForGuard::*guard)(Event const&) | |
151 | > | |
152 | struct irow2 | |
153 | { | |
154 | typedef irow_tag row_type_tag; | |
155 | typedef T1 Source; | |
156 | typedef T1 Target; | |
157 | typedef Event Evt; | |
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) | |
161 | { | |
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; | |
167 | } | |
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) | |
171 | { | |
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>()); | |
176 | } | |
177 | }; | |
178 | template< | |
179 | typename T1 | |
180 | , class Event | |
181 | , typename CalledForGuard | |
182 | , bool (CalledForGuard::*guard)(Event const&) | |
183 | > | |
184 | struct g_irow2 | |
185 | { | |
186 | typedef g_irow_tag row_type_tag; | |
187 | typedef T1 Source; | |
188 | typedef T1 Target; | |
189 | typedef Event Evt; | |
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) | |
193 | { | |
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>()); | |
198 | } | |
199 | }; | |
200 | ||
201 | }}} | |
202 | ||
203 | #endif //BOOST_MSM_ROW2_HPP | |
204 |