Embedded Template Library 1.0
Loading...
Searching...
No Matches
fsm_cpp03.h
1/******************************************************************************
2The MIT License(MIT)
3
4Embedded Template Library.
5https://github.com/ETLCPP/etl
6https://www.etlcpp.com
7
8Copyright(c) 2026 John Wellbelove
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files(the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions :
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27******************************************************************************/
28
29//***************************************************************************
30// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
31//***************************************************************************
32
33//*************************************************************************************************
34// For C++03 and below.
35//*************************************************************************************************
36//***************************************************************************
37// The definition for all 16 message types.
38//***************************************************************************
39template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
40 typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
41 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
42 typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
43 typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
44class fsm_state : public ifsm_state
45{
46public:
47
48 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
49
50 fsm_state()
51 : ifsm_state(STATE_ID)
52 {
53 }
54
55protected:
56
57 ~fsm_state()
58 {
59 }
60
61 TContext& get_fsm_context() const
62 {
63 return static_cast<TContext&>(ifsm_state::get_fsm_context());
64 }
65
66private:
67
68 etl::fsm_state_id_t process_event(const etl::imessage& message)
69 {
70 etl::fsm_state_id_t new_state_id;
71 etl::message_id_t event_id = message.get_message_id();
72
73 switch (event_id)
74 {
75 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
76 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
77 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
78 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
79 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
80 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
81 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
82 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
83 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
84 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
85 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
86 case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
87 case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
88 case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
89 case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
90 case T16::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T16&>(message)); break;
91 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
92 }
93
94 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
95 }
96};
97
98//***************************************************************************
99// Specialisation for 15 message types.
100//***************************************************************************
101template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
102 typename T1, typename T2, typename T3, typename T4,
103 typename T5, typename T6, typename T7, typename T8,
104 typename T9, typename T10, typename T11, typename T12,
105 typename T13, typename T14, typename T15>
106class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, void> : public ifsm_state
107{
108public:
109
110 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
111
112 fsm_state()
113 : ifsm_state(STATE_ID)
114 {
115 }
116
117protected:
118
119 ~fsm_state()
120 {
121 }
122
123 TContext& get_fsm_context() const
124 {
125 return static_cast<TContext&>(ifsm_state::get_fsm_context());
126 }
127
128private:
129
130 etl::fsm_state_id_t process_event(const etl::imessage& message)
131 {
132 etl::fsm_state_id_t new_state_id;
133 etl::message_id_t event_id = message.get_message_id();
134
135 switch (event_id)
136 {
137 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
138 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
139 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
140 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
141 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
142 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
143 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
144 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
145 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
146 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
147 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
148 case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
149 case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
150 case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
151 case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
152 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
153 }
154
155 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
156 }
157};
158
159//***************************************************************************
160// Specialisation for 14 message types.
161//***************************************************************************
162template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
163 typename T1, typename T2, typename T3, typename T4,
164 typename T5, typename T6, typename T7, typename T8,
165 typename T9, typename T10, typename T11, typename T12,
166 typename T13, typename T14>
167class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, void, void> : public ifsm_state
168{
169public:
170
171 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
172
173 fsm_state()
174 : ifsm_state(STATE_ID)
175 {
176 }
177
178protected:
179
180 ~fsm_state()
181 {
182 }
183
184 TContext& get_fsm_context() const
185 {
186 return static_cast<TContext&>(ifsm_state::get_fsm_context());
187 }
188
189private:
190
191 etl::fsm_state_id_t process_event(const etl::imessage& message)
192 {
193 etl::fsm_state_id_t new_state_id;
194 etl::message_id_t event_id = message.get_message_id();
195
196 switch (event_id)
197 {
198 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
199 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
200 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
201 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
202 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
203 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
204 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
205 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
206 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
207 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
208 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
209 case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
210 case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
211 case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
212 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
213 }
214
215 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
216 }
217};
218
219//***************************************************************************
220// Specialisation for 13 message types.
221//***************************************************************************
222template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
223 typename T1, typename T2, typename T3, typename T4,
224 typename T5, typename T6, typename T7, typename T8,
225 typename T9, typename T10, typename T11, typename T12,
226 typename T13>
227class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, void, void, void> : public ifsm_state
228{
229public:
230
231 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
232
233 fsm_state()
234 : ifsm_state(STATE_ID)
235 {
236 }
237
238protected:
239
240 ~fsm_state()
241 {
242 }
243
244 TContext& get_fsm_context() const
245 {
246 return static_cast<TContext&>(ifsm_state::get_fsm_context());
247 }
248
249private:
250
251 etl::fsm_state_id_t process_event(const etl::imessage& message)
252 {
253 etl::fsm_state_id_t new_state_id;
254 etl::message_id_t event_id = message.get_message_id();
255
256 switch (event_id)
257 {
258 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
259 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
260 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
261 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
262 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
263 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
264 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
265 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
266 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
267 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
268 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
269 case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
270 case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
271 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
272 }
273
274 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
275 }
276};
277
278//***************************************************************************
279// Specialisation for 12 message types.
280//***************************************************************************
281template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
282 typename T1, typename T2, typename T3, typename T4,
283 typename T5, typename T6, typename T7, typename T8,
284 typename T9, typename T10, typename T11, typename T12>
285class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, void, void, void, void> : public ifsm_state
286{
287public:
288
289 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
290
291 fsm_state()
292 : ifsm_state(STATE_ID)
293 {
294 }
295
296protected:
297
298 ~fsm_state()
299 {
300 }
301
302 TContext& get_fsm_context() const
303 {
304 return static_cast<TContext&>(ifsm_state::get_fsm_context());
305 }
306
307private:
308
309 etl::fsm_state_id_t process_event(const etl::imessage& message)
310 {
311 etl::fsm_state_id_t new_state_id;
312 etl::message_id_t event_id = message.get_message_id();
313
314 switch (event_id)
315 {
316 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
317 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
318 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
319 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
320 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
321 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
322 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
323 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
324 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
325 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
326 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
327 case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
328 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
329 }
330
331 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
332 }
333};
334
335//***************************************************************************
336// Specialisation for 11 message types.
337//***************************************************************************
338template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
339 typename T1, typename T2, typename T3, typename T4,
340 typename T5, typename T6, typename T7, typename T8,
341 typename T9, typename T10, typename T11>
342class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, void, void, void, void, void> : public ifsm_state
343{
344public:
345
346 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
347
348 fsm_state()
349 : ifsm_state(STATE_ID)
350 {
351 }
352
353protected:
354
355 ~fsm_state()
356 {
357 }
358
359 TContext& get_fsm_context() const
360 {
361 return static_cast<TContext&>(ifsm_state::get_fsm_context());
362 }
363
364private:
365
366 etl::fsm_state_id_t process_event(const etl::imessage& message)
367 {
368 etl::fsm_state_id_t new_state_id;
369 etl::message_id_t event_id = message.get_message_id();
370
371 switch (event_id)
372 {
373 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
374 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
375 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
376 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
377 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
378 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
379 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
380 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
381 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
382 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
383 case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
384 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
385 }
386
387 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
388 }
389};
390
391//***************************************************************************
392// Specialisation for 10 message types.
393//***************************************************************************
394template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
395 typename T1, typename T2, typename T3, typename T4,
396 typename T5, typename T6, typename T7, typename T8,
397 typename T9, typename T10>
398class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, void, void, void, void, void, void> : public ifsm_state
399{
400public:
401
402 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
403
404 fsm_state()
405 : ifsm_state(STATE_ID)
406 {
407 }
408
409protected:
410
411 ~fsm_state()
412 {
413 }
414
415 TContext& get_fsm_context() const
416 {
417 return static_cast<TContext&>(ifsm_state::get_fsm_context());
418 }
419
420private:
421
422 etl::fsm_state_id_t process_event(const etl::imessage& message)
423 {
424 etl::fsm_state_id_t new_state_id;
425 etl::message_id_t event_id = message.get_message_id();
426
427 switch (event_id)
428 {
429 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
430 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
431 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
432 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
433 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
434 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
435 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
436 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
437 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
438 case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
439 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
440 }
441
442 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
443 }
444};
445
446//***************************************************************************
447// Specialisation for 9 message types.
448//***************************************************************************
449template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
450 typename T1, typename T2, typename T3, typename T4,
451 typename T5, typename T6, typename T7, typename T8,
452 typename T9>
453class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, void, void, void, void, void, void, void> : public ifsm_state
454{
455public:
456
457 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
458
459 fsm_state()
460 : ifsm_state(STATE_ID)
461 {
462 }
463
464protected:
465
466 ~fsm_state()
467 {
468 }
469
470 TContext& get_fsm_context() const
471 {
472 return static_cast<TContext&>(ifsm_state::get_fsm_context());
473 }
474
475private:
476
477 etl::fsm_state_id_t process_event(const etl::imessage& message)
478 {
479 etl::fsm_state_id_t new_state_id;
480 etl::message_id_t event_id = message.get_message_id();
481
482 switch (event_id)
483 {
484 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
485 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
486 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
487 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
488 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
489 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
490 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
491 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
492 case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
493 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
494 }
495
496 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
497 }
498};
499
500//***************************************************************************
501// Specialisation for 8 message types.
502//***************************************************************************
503template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
504 typename T1, typename T2, typename T3, typename T4,
505 typename T5, typename T6, typename T7, typename T8>
506class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, void, void, void, void, void, void, void, void> : public ifsm_state
507{
508public:
509
510 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
511
512 fsm_state()
513 : ifsm_state(STATE_ID)
514 {
515 }
516
517protected:
518
519 ~fsm_state()
520 {
521 }
522
523 TContext& get_fsm_context() const
524 {
525 return static_cast<TContext&>(ifsm_state::get_fsm_context());
526 }
527
528private:
529
530 etl::fsm_state_id_t process_event(const etl::imessage& message)
531 {
532 etl::fsm_state_id_t new_state_id;
533 etl::message_id_t event_id = message.get_message_id();
534
535 switch (event_id)
536 {
537 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
538 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
539 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
540 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
541 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
542 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
543 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
544 case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
545 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
546 }
547
548 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
549 }
550};
551
552//***************************************************************************
553// Specialisation for 7 message types.
554//***************************************************************************
555template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
556 typename T1, typename T2, typename T3, typename T4,
557 typename T5, typename T6, typename T7>
558class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, void, void, void, void, void, void, void, void, void> : public ifsm_state
559{
560public:
561
562 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
563
564 fsm_state()
565 : ifsm_state(STATE_ID)
566 {
567 }
568
569protected:
570
571 ~fsm_state()
572 {
573 }
574
575 TContext& get_fsm_context() const
576 {
577 return static_cast<TContext&>(ifsm_state::get_fsm_context());
578 }
579
580private:
581
582 etl::fsm_state_id_t process_event(const etl::imessage& message)
583 {
584 etl::fsm_state_id_t new_state_id;
585 etl::message_id_t event_id = message.get_message_id();
586
587 switch (event_id)
588 {
589 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
590 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
591 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
592 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
593 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
594 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
595 case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
596 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
597 }
598
599 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
600 }
601};
602
603//***************************************************************************
604// Specialisation for 6 message types.
605//***************************************************************************
606template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
607 typename T1, typename T2, typename T3, typename T4,
608 typename T5, typename T6>
609class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
610{
611public:
612
613 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
614
615 fsm_state()
616 : ifsm_state(STATE_ID)
617 {
618 }
619
620protected:
621
622 ~fsm_state()
623 {
624 }
625
626 TContext& get_fsm_context() const
627 {
628 return static_cast<TContext&>(ifsm_state::get_fsm_context());
629 }
630
631private:
632
633 etl::fsm_state_id_t process_event(const etl::imessage& message)
634 {
635 etl::fsm_state_id_t new_state_id;
636 etl::message_id_t event_id = message.get_message_id();
637
638 switch (event_id)
639 {
640 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
641 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
642 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
643 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
644 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
645 case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
646 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
647 }
648
649 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
650 }
651};
652
653//***************************************************************************
654// Specialisation for 5 message types.
655//***************************************************************************
656template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
657 typename T1, typename T2, typename T3, typename T4,
658 typename T5>
659class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
660{
661public:
662
663 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
664
665 fsm_state()
666 : ifsm_state(STATE_ID)
667 {
668 }
669
670protected:
671
672 ~fsm_state()
673 {
674 }
675
676 TContext& get_fsm_context() const
677 {
678 return static_cast<TContext&>(ifsm_state::get_fsm_context());
679 }
680
681private:
682
683 etl::fsm_state_id_t process_event(const etl::imessage& message)
684 {
685 etl::fsm_state_id_t new_state_id;
686 etl::message_id_t event_id = message.get_message_id();
687
688 switch (event_id)
689 {
690 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
691 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
692 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
693 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
694 case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
695 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
696 }
697
698 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
699 }
700};
701
702//***************************************************************************
703// Specialisation for 4 message types.
704//***************************************************************************
705template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
706 typename T1, typename T2, typename T3, typename T4>
707class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
708{
709public:
710
711 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
712
713 fsm_state()
714 : ifsm_state(STATE_ID)
715 {
716 }
717
718protected:
719
720 ~fsm_state()
721 {
722 }
723
724 TContext& get_fsm_context() const
725 {
726 return static_cast<TContext&>(ifsm_state::get_fsm_context());
727 }
728
729private:
730
731 etl::fsm_state_id_t process_event(const etl::imessage& message)
732 {
733 etl::fsm_state_id_t new_state_id;
734 etl::message_id_t event_id = message.get_message_id();
735
736 switch (event_id)
737 {
738 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
739 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
740 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
741 case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
742 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
743 }
744
745 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
746 }
747};
748
749//***************************************************************************
750// Specialisation for 3 message types.
751//***************************************************************************
752template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
753 typename T1, typename T2, typename T3>
754class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
755{
756public:
757
758 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
759
760 fsm_state()
761 : ifsm_state(STATE_ID)
762 {
763 }
764
765protected:
766
767 ~fsm_state()
768 {
769 }
770
771 TContext& get_fsm_context() const
772 {
773 return static_cast<TContext&>(ifsm_state::get_fsm_context());
774 }
775
776private:
777
778 etl::fsm_state_id_t process_event(const etl::imessage& message)
779 {
780 etl::fsm_state_id_t new_state_id;
781 etl::message_id_t event_id = message.get_message_id();
782
783 switch (event_id)
784 {
785 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
786 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
787 case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
788 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
789 }
790
791 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
792 }
793};
794
795//***************************************************************************
796// Specialisation for 2 message types.
797//***************************************************************************
798template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
799 typename T1, typename T2>
800class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
801{
802public:
803
804 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
805
806 fsm_state()
807 : ifsm_state(STATE_ID)
808 {
809 }
810
811protected:
812
813 ~fsm_state()
814 {
815 }
816
817 TContext& get_fsm_context() const
818 {
819 return static_cast<TContext&>(ifsm_state::get_fsm_context());
820 }
821
822private:
823
824 etl::fsm_state_id_t process_event(const etl::imessage& message)
825 {
826 etl::fsm_state_id_t new_state_id;
827 etl::message_id_t event_id = message.get_message_id();
828
829 switch (event_id)
830 {
831 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
832 case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
833 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
834 }
835
836 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
837 }
838};
839
840//***************************************************************************
841// Specialisation for 1 message type.
842//***************************************************************************
843template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
844 typename T1>
845class fsm_state<TContext, TDerived, STATE_ID_, T1, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
846{
847public:
848
849 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
850
851 fsm_state()
852 : ifsm_state(STATE_ID)
853 {
854 }
855
856protected:
857
858 ~fsm_state()
859 {
860 }
861
862 TContext& get_fsm_context() const
863 {
864 return static_cast<TContext&>(ifsm_state::get_fsm_context());
865 }
866
867private:
868
869 etl::fsm_state_id_t process_event(const etl::imessage& message)
870 {
871 etl::fsm_state_id_t new_state_id;
872 etl::message_id_t event_id = message.get_message_id();
873
874 switch (event_id)
875 {
876 case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
877 default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
878 }
879
880 return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
881 }
882};
883
884//***************************************************************************
885// Specialisation for 0 message types.
886//***************************************************************************
887template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_>
888class fsm_state<TContext, TDerived, STATE_ID_, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
889{
890public:
891
892 static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
893
894 fsm_state()
895 : ifsm_state(STATE_ID)
896 {
897 }
898
899protected:
900
901 ~fsm_state()
902 {
903 }
904
905 TContext& get_fsm_context() const
906 {
907 return static_cast<TContext&>(ifsm_state::get_fsm_context());
908 }
909private:
910
911 etl::fsm_state_id_t process_event(const etl::imessage& message)
912 {
913 return p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);
914 }
915};
916
917template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
918 typename T1, typename T2, typename T3, typename T4,
919 typename T5, typename T6, typename T7, typename T8,
920 typename T9, typename T10, typename T11, typename T12,
921 typename T13, typename T14, typename T15, typename T16>
922ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::STATE_ID;
Definition message.h:75
uint_least8_t message_id_t
Allow alternative type for message id.
Definition message_types.h:40
uint_least8_t fsm_state_id_t
Allow alternative type for state id.
Definition fsm.h:57