forked from QuantumLeaps/qpcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qpcpp.qm
12229 lines (10941 loc) · 432 KB
/
qpcpp.qm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<model version="5.3.0" links="1">
<documentation>QP/C++ Real-Time Embedded Framework (RTEF)
The model is used to generate the whole QP/C++ source code.
Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
This software is dual-licensed under the terms of the open source GNU
General Public License version 3 (or any later version), or alternatively,
under the terms of one of the closed source Quantum Leaps commercial
licenses.
The terms of the open source GNU General Public License version 3
can be found at: <www.gnu.org/licenses/gpl-3.0>
The terms of the closed source Quantum Leaps commercial licenses
can be found at: <www.state-machine.com/licensing>
Redistributions in source code must retain this copyright notice.
Plagiarizing this software to sidestep the license obligations is illegal.
Contact information:
<www.state-machine.com/licensing>
<[email protected]></documentation>
<!--${qpcpp}-->
<framework name="qpcpp" license="LICENSES/LicenseRef-QL-dual.qlc"/>
<!--${glob-types}-->
<package name="glob-types" stereotype="0x00">
<!--${glob-types::int_t}-->
<attribute name="int_t" type="using" visibility="0x04" properties="0x00">
<code> = int;</code>
</attribute>
<!--${glob-types::enum_t}-->
<attribute name="enum_t" type="using" visibility="0x04" properties="0x00">
<code> = int;</code>
</attribute>
<!--${glob-types::float32_t}-->
<attribute name="float32_t" type="using" visibility="0x04" properties="0x00">
<code> = float;</code>
</attribute>
<!--${glob-types::float64_t}-->
<attribute name="float64_t" type="using" visibility="0x04" properties="0x00">
<code> = double;</code>
</attribute>
</package>
<!--${QEP}-->
<package name="QEP" stereotype="0x05" namespace="QP::">
<!--${QEP::versionStr[]}-->
<attribute name="versionStr[]" type="constexpr char const" visibility="0x04" properties="0x01">
<code>{QP_VERSION_STR};</code>
</attribute>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 1U)" type="using" visibility="0x04" properties="0x00">
<code>= std::uint8_t;</code>
</attribute>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 2U)" type="using" visibility="0x04" properties="0x00">
<code>= std::uint16_t;</code>
</attribute>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 4U)" type="using" visibility="0x04" properties="0x00">
<code>= std::uint32_t;</code>
</attribute>
<!--${QEP::QEvt}-->
<class name="QEvt">
<!--${QEP::QEvt::sig}-->
<attribute name="sig" type="QSignal" visibility="0x00" properties="0x00"/>
<!--${QEP::QEvt::refCtr_}-->
<attribute name="refCtr_" type="std::uint8_t volatile" visibility="0x00" properties="0x00"/>
<!--${QEP::QEvt::evtTag_}-->
<attribute name="evtTag_" type="std::uint8_t" visibility="0x00" properties="0x00"/>
<!--${QEP::QEvt::MARKER}-->
<attribute name="MARKER" type="static constexpr std::uint8_t" visibility="0x04" properties="0x01">
<code> {0xE0U};</code>
</attribute>
<!--${QEP::QEvt::DynEvt}-->
<attribute name="DynEvt?def QEVT_DYN_CTOR" type="enum" visibility="0x04" properties="0x00">
<code>: std::uint8_t { DYNAMIC };</code>
</attribute>
<!--${QEP::QEvt::QEvt}-->
<operation name="QEvt" type="" visibility="0x00" properties="0x00">
<specifiers>= delete</specifiers>
</operation>
<!--${QEP::QEvt::QEvt}-->
<operation name="QEvt" type="explicit constexpr" visibility="0x00" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QEvt::QEvt::s}-->
<parameter name="s" type="QSignal const"/>
<code> : sig(s),
refCtr_(0U),
evtTag_(MARKER)</code>
</operation>
<!--${QEP::QEvt::QEvt}-->
<operation name="QEvt?def QEVT_DYN_CTOR" type="explicit" visibility="0x00" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QEvt::QEvt::dummy}-->
<parameter name="dummy" type="DynEvt"/>
<code>static_cast<void>(dummy); // unused parameter
// dynamic event already initialized in QP::QF::newX_()</code>
</operation>
<!--${QEP::QEvt::verify_}-->
<operation name="verify_" type="bool" visibility="0x00" properties="0x03">
<specifiers>noexcept</specifiers>
<!--${QEP::QEvt::verify_::e}-->
<parameter name="e" type="QEvt const * const"/>
<code>return (e != nullptr)
&& ((e->evtTag_ & 0xF0U) == MARKER);</code>
</operation>
<!--${QEP::QEvt::getPoolId_}-->
<operation name="getPoolId_" type="std::uint_fast8_t" visibility="0x00" properties="0x02">
<specifiers>const noexcept</specifiers>
<code>return static_cast<std::uint8_t>(evtTag_) & 0x0FU;</code>
</operation>
</class>
<!--${QEP::QState}-->
<attribute name="QState" type="using" visibility="0x04" properties="0x00">
<code>= std::uint_fast8_t;</code>
</attribute>
<!--${QEP::QStateHandler}-->
<attribute name="QStateHandler" type="using" visibility="0x04" properties="0x00">
<code>= QState (*)(void * const me, QEvt const * const e);</code>
</attribute>
<!--${QEP::QActionHandler}-->
<attribute name="QActionHandler" type="using" visibility="0x04" properties="0x00">
<code>= QState (*)(void * const me);</code>
</attribute>
<!--${QEP::QXThread}-->
<attribute name="QXThread" type="class" visibility="0x04" properties="0x00">
<documentation>// forward declaration</documentation>
</attribute>
<!--${QEP::QXThreadHandler}-->
<attribute name="QXThreadHandler" type="using" visibility="0x04" properties="0x00">
<code>= void (*)(QXThread * const me);</code>
</attribute>
<!--${QEP::QMState}-->
<attribute name="QMState" type="struct" visibility="0x04" properties="0x00">
<code>{
QMState const * superstate;
QStateHandler const stateHandler;
QActionHandler const entryAction;
QActionHandler const exitAction;
QActionHandler const initAction;
};</code>
</attribute>
<!--${QEP::QMTranActTable}-->
<attribute name="QMTranActTable" type="struct" visibility="0x04" properties="0x00">
<code>{
QMState const * target;
QActionHandler const act[1];
};</code>
</attribute>
<!--${QEP::QAsmAttr}-->
<attribute name="QAsmAttr" type="union" visibility="0x04" properties="0x00">
<code>{
QStateHandler fun;
QActionHandler act;
QXThreadHandler thr;
QMState const *obj;
QMTranActTable const *tatbl;
#ifndef Q_UNSAFE
std::uintptr_t uint;
#endif
constexpr QAsmAttr() : fun(nullptr) {}
};</code>
</attribute>
<!--${QEP::Q_USER_SIG}-->
<attribute name="Q_USER_SIG" type="constexpr enum_t " visibility="0x04" properties="0x00">
<code>{4};</code>
</attribute>
<!--${QEP::QAsm}-->
<class name="QAsm">
<documentation>Abstract State Machine</documentation>
<!--${QEP::QAsm::m_state}-->
<attribute name="m_state" type="QAsmAttr" visibility="0x01" properties="0x00"/>
<!--${QEP::QAsm::m_temp}-->
<attribute name="m_temp" type="QAsmAttr" visibility="0x01" properties="0x00"/>
<!--${QEP::QAsm::QStateRet}-->
<attribute name="QStateRet" type="enum" visibility="0x04" properties="0x01">
<documentation>//! All possible return values from state-handlers
//! @note
//! The order is important for algorithmic correctness.</documentation>
<code> : QState {
// unhandled and need to "bubble up"
Q_RET_SUPER, //!< event passed to superstate to handle
Q_RET_SUPER_SUB, //!< event passed to submachine superstate
Q_RET_UNHANDLED, //!< event unhandled due to a guard
// handled and do not need to "bubble up"
Q_RET_HANDLED, //!< event handled (internal transition)
Q_RET_IGNORED, //!< event silently ignored (bubbled up to top)
// entry/exit
Q_RET_ENTRY, //!< state entry action executed
Q_RET_EXIT, //!< state exit action executed
// no side effects
Q_RET_NULL, //!< return value without any effect
// transitions need to execute transition-action table in QP::QMsm
Q_RET_TRAN, //!< regular transition
Q_RET_TRAN_INIT, //!< initial transition in a state or submachine
Q_RET_TRAN_EP, //!< entry-point transition into a submachine
// transitions that additionally clobber QHsm.m_state
Q_RET_TRAN_HIST, //!< transition to history of a given state
Q_RET_TRAN_XP //!< exit-point transition out of a submachine
};</code>
</attribute>
<!--${QEP::QAsm::ReservedSig}-->
<attribute name="ReservedSig" type="enum" visibility="0x04" properties="0x01">
<documentation>//! Reserved signals by the QP-framework.</documentation>
<code> : QSignal {
Q_EMPTY_SIG, //!< signal to execute the default case
Q_ENTRY_SIG, //!< signal for entry actions
Q_EXIT_SIG, //!< signal for exit actions
Q_INIT_SIG //!< signal for nested initial transitions
};</code>
</attribute>
<!--${QEP::QAsm::QAsm}-->
<operation name="QAsm" type="explicit" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<code> : m_state(),
m_temp ()</code>
</operation>
<!--${QEP::QAsm::~QAsm}-->
<operation name="~QAsm?def Q_XTOR" type="" visibility="0x00" properties="0x06">
<specifiers>noexcept</specifiers>
<code>// empty</code>
</operation>
<!--${QEP::QAsm::init}-->
<operation name="init" type="void" visibility="0x00" properties="0x04">
<specifiers>= 0</specifiers>
<!--${QEP::QAsm::init::e}-->
<parameter name="e" type="void const * const"/>
<!--${QEP::QAsm::init::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
</operation>
<!--${QEP::QAsm::init}-->
<operation name="init" type="void" visibility="0x00" properties="0x06">
<!--${QEP::QAsm::init::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>this->init(nullptr, qs_id);</code>
</operation>
<!--${QEP::QAsm::dispatch}-->
<operation name="dispatch" type="void" visibility="0x00" properties="0x04">
<specifiers>= 0</specifiers>
<!--${QEP::QAsm::dispatch::e}-->
<parameter name="e" type="QEvt const * const"/>
<!--${QEP::QAsm::dispatch::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
</operation>
<!--${QEP::QAsm::isIn}-->
<operation name="isIn" type="bool" visibility="0x00" properties="0x06">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::isIn::state}-->
<parameter name="state" type="QStateHandler const"/>
<code>static_cast<void>(state);
return false;</code>
</operation>
<!--${QEP::QAsm::getStateHandler}-->
<operation name="getStateHandler?def Q_SPY" type="QStateHandler" visibility="0x00" properties="0x06">
<specifiers>noexcept</specifiers>
<code>return m_state.fun;</code>
</operation>
<!--${QEP::QAsm::top}-->
<operation name="top" type="QState" visibility="0x00" properties="0x03">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::top::me}-->
<parameter name="me" type="void * const"/>
<!--${QEP::QAsm::top::e}-->
<parameter name="e" type="QEvt const * const"/>
<code>static_cast<void>(me);
static_cast<void>(e);
return Q_RET_IGNORED; // the top state ignores all events</code>
</operation>
<!--${QEP::QAsm::tran}-->
<operation name="tran" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::tran::target}-->
<parameter name="target" type="QStateHandler const"/>
<code>m_temp.fun = target;
return Q_RET_TRAN;</code>
</operation>
<!--${QEP::QAsm::tran_hist}-->
<operation name="tran_hist" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::tran_hist::hist}-->
<parameter name="hist" type="QStateHandler const"/>
<code>m_temp.fun = hist;
return Q_RET_TRAN_HIST;</code>
</operation>
<!--${QEP::QAsm::super}-->
<operation name="super" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::super::superstate}-->
<parameter name="superstate" type="QStateHandler const"/>
<code>m_temp.fun = superstate;
return Q_RET_SUPER;</code>
</operation>
<!--${QEP::QAsm::qm_tran}-->
<operation name="qm_tran" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_tran::tatbl}-->
<parameter name="tatbl" type="void const * const"/>
<code>m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
return Q_RET_TRAN;</code>
</operation>
<!--${QEP::QAsm::qm_tran_init}-->
<operation name="qm_tran_init" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_tran_init::tatbl}-->
<parameter name="tatbl" type="void const * const"/>
<code>m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
return Q_RET_TRAN_INIT;</code>
</operation>
<!--${QEP::QAsm::qm_tran_hist}-->
<operation name="qm_tran_hist" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_tran_hist::hist}-->
<parameter name="hist" type="QMState const * const"/>
<!--${QEP::QAsm::qm_tran_hist::tatbl}-->
<parameter name="tatbl" type="void const * const"/>
<code>m_state.obj = hist;
m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
return Q_RET_TRAN_HIST;</code>
</operation>
<!--${QEP::QAsm::qm_tran_ep}-->
<operation name="qm_tran_ep" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_tran_ep::tatbl}-->
<parameter name="tatbl" type="void const * const"/>
<code>m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
return Q_RET_TRAN_EP;</code>
</operation>
<!--${QEP::QAsm::qm_tran_xp}-->
<operation name="qm_tran_xp" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_tran_xp::xp}-->
<parameter name="xp" type="QActionHandler const"/>
<!--${QEP::QAsm::qm_tran_xp::tatbl}-->
<parameter name="tatbl" type="void const * const"/>
<code>m_state.act = xp;
m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
return Q_RET_TRAN_XP;</code>
</operation>
<!--${QEP::QAsm::qm_entry}-->
<operation name="qm_entry?def Q_SPY" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_entry::s}-->
<parameter name="s" type="QMState const * const"/>
<code>m_temp.obj = s;
return Q_RET_ENTRY;</code>
</operation>
<!--${QEP::QAsm::qm_entry}-->
<operation name="qm_entry?ndef Q_SPY" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_entry::s}-->
<parameter name="s" type="QMState const * const"/>
<code>static_cast<void>(s); // unused parameter
return Q_RET_ENTRY;</code>
</operation>
<!--${QEP::QAsm::qm_exit}-->
<operation name="qm_exit?def Q_SPY" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_exit::s}-->
<parameter name="s" type="QMState const * const"/>
<code>m_temp.obj = s;
return Q_RET_EXIT;</code>
</operation>
<!--${QEP::QAsm::qm_exit}-->
<operation name="qm_exit?ndef Q_SPY" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_exit::s}-->
<parameter name="s" type="QMState const * const"/>
<code>static_cast<void>(s); // unused parameter
return Q_RET_EXIT;</code>
</operation>
<!--${QEP::QAsm::qm_sm_exit}-->
<operation name="qm_sm_exit" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_sm_exit::s}-->
<parameter name="s" type="QMState const * const"/>
<code>m_temp.obj = s;
return Q_RET_EXIT;</code>
</operation>
<!--${QEP::QAsm::qm_super_sub}-->
<operation name="qm_super_sub" type="QState" visibility="0x01" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${QEP::QAsm::qm_super_sub::s}-->
<parameter name="s" type="QMState const * const"/>
<code>m_temp.obj = s;
return Q_RET_SUPER_SUB;</code>
</operation>
</class>
<!--${QEP::QHsm}-->
<class name="QHsm" superclass="QEP::QAsm">
<documentation>Human-generated State Machine</documentation>
<!--${QEP::QHsm::MAX_NEST_DEPTH_}-->
<attribute name="MAX_NEST_DEPTH_" type="static constexpr std::int_fast8_t" visibility="0x04" properties="0x01">
<code>{6};</code>
</attribute>
<!--${QEP::QHsm::QHsm}-->
<operation name="QHsm" type="explicit" visibility="0x01" properties="0x00">
<specifiers>noexcept</specifiers>
<!--${QEP::QHsm::QHsm::initial}-->
<parameter name="initial" type="QStateHandler const"/>
<code>: QAsm()
m_state.fun = Q_STATE_CAST(&top);
m_temp.fun = initial;</code>
</operation>
<!--${QEP::QHsm::init}-->
<operation name="init" type="void" visibility="0x00" properties="0x04">
<specifiers>override</specifiers>
<!--${QEP::QHsm::init::e}-->
<parameter name="e" type="void const * const"/>
<!--${QEP::QHsm::init::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>QF_CRIT_STAT
#ifdef Q_SPY
QS_CRIT_ENTRY();
QS_MEM_SYS();
if ((QS::priv_.flags & 0x01U) == 0U) {
QS::priv_.flags |= 0x01U;
QS_MEM_APP();
QS_CRIT_EXIT();
QS_FUN_DICTIONARY(&QP::QHsm::top);
}
else {
QS_MEM_APP();
QS_CRIT_EXIT();
}
#else
Q_UNUSED_PAR(qs_id);
#endif
QStateHandler t = m_state.fun;
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(200, (m_temp.fun != nullptr)
&& (t == Q_STATE_CAST(&top)));
QF_CRIT_EXIT();
// execute the top-most initial tran.
QState r = (*m_temp.fun)(this, Q_EVT_CAST(QEvt));
QF_CRIT_ENTRY();
// the top-most initial tran. must be taken
Q_ASSERT_INCRIT(210, r == Q_RET_TRAN);
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_STATE_INIT, qs_id)
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(t); // the source state
QS_FUN_PRE_(m_temp.fun); // the target of the initial tran.
QS_END_PRE_()
QS_MEM_APP();
QF_CRIT_EXIT();
// drill down into the state hierarchy with initial transitions...
do {
QStateHandler path[MAX_NEST_DEPTH_]; // tran entry path array
std::int_fast8_t ip = 0; // entry path index
path[0] = m_temp.fun;
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
while (m_temp.fun != t) {
++ip;
QF_CRIT_ENTRY();
Q_ASSERT_INCRIT(220, ip < MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
path[ip] = m_temp.fun;
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
}
m_temp.fun = path[0];
// retrace the entry path in reverse (desired) order...
do {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qs_id);
}
--ip;
} while (ip >= 0);
t = path[0]; // current state becomes the new source
r = QHSM_RESERVED_EVT_(t, Q_INIT_SIG); // execute initial tran.
#ifdef Q_SPY
if (r == Q_RET_TRAN) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_STATE_INIT, qs_id)
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(t); // the source state
QS_FUN_PRE_(m_temp.fun); // the target of the initial tran.
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
} while (r == Q_RET_TRAN);
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_INIT_TRAN, qs_id)
QS_TIME_PRE_(); // time stamp
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(t); // the new active state
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
m_state.fun = t; // change the current active state
#ifndef Q_UNSAFE
m_temp.uint = ~m_state.uint;
#endif</code>
</operation>
<!--${QEP::QHsm::init}-->
<operation name="init" type="void" visibility="0x00" properties="0x06">
<specifiers>override</specifiers>
<!--${QEP::QHsm::init::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>this->init(nullptr, qs_id);</code>
</operation>
<!--${QEP::QHsm::dispatch}-->
<operation name="dispatch" type="void" visibility="0x00" properties="0x04">
<specifiers>override</specifiers>
<!--${QEP::QHsm::dispatch::e}-->
<parameter name="e" type="QEvt const * const"/>
<!--${QEP::QHsm::dispatch::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>#ifndef Q_SPY
Q_UNUSED_PAR(qs_id);
#endif
QStateHandler s = m_state.fun;
QStateHandler t = s;
QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(300, (s != Q_STATE_CAST(0))
&& (m_state.uint == static_cast<std::uintptr_t>(~m_temp.uint)));
Q_REQUIRE_INCRIT(302, QEvt::verify_(e));
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_DISPATCH, qs_id)
QS_TIME_PRE_(); // time stamp
QS_SIG_PRE_(e->sig); // the signal of the event
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(s); // the current state
QS_END_PRE_()
QS_MEM_APP();
QF_CRIT_EXIT();
// process the event hierarchically...
QState r;
m_temp.fun = s;
do {
s = m_temp.fun;
r = (*s)(this, e); // invoke state handler s
if (r == Q_RET_UNHANDLED) { // unhandled due to a guard?
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_UNHANDLED, qs_id)
QS_SIG_PRE_(e->sig); // the signal of the event
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(s); // the current state
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG); // superstate of s
}
} while (r == Q_RET_SUPER);
if (r >= Q_RET_TRAN) { // regular tran. taken?
QStateHandler path[MAX_NEST_DEPTH_];
path[0] = m_temp.fun; // tran. target
path[1] = t; // current state
path[2] = s; // tran. source
// exit current state to tran. source s...
for (; t != s; t = m_temp.fun) {
// exit from t
if (QHSM_RESERVED_EVT_(t, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(t, qs_id);
// find superstate of t
static_cast<void>(QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG));
}
}
std::int_fast8_t ip = hsm_tran(path, qs_id); // take the tran.
#ifdef Q_SPY
if (r == Q_RET_TRAN_HIST) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_TRAN_HIST, qs_id)
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(t); // the source of the transition
QS_FUN_PRE_(path[0]); // the target of the tran. to history
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
// execute state entry actions in the desired order...
for (; ip >= 0; --ip) {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qs_id);
}
}
t = path[0]; // stick the target into register
m_temp.fun = t; // update the next state
// drill into the target hierarchy...
while (QHSM_RESERVED_EVT_(t, Q_INIT_SIG) == Q_RET_TRAN) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_STATE_INIT, qs_id)
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(t); // the source (pseudo)state
QS_FUN_PRE_(m_temp.fun); // the target of the tran.
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
ip = 0;
path[0] = m_temp.fun;
// find superstate
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
while (m_temp.fun != t) {
++ip;
path[ip] = m_temp.fun;
// find superstate
static_cast<void>(
QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
}
m_temp.fun = path[0];
// entry path must not overflow
QF_CRIT_ENTRY();
Q_ASSERT_INCRIT(410, ip < MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
// retrace the entry path in reverse (correct) order...
do {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qs_id);
}
--ip;
} while (ip >= 0);
t = path[0]; // current state becomes the new source
}
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_TRAN, qs_id)
QS_TIME_PRE_(); // time stamp
QS_SIG_PRE_(e->sig); // the signal of the event
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(s); // the source of the tran.
QS_FUN_PRE_(t); // the new active state
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#ifdef Q_SPY
else if (r == Q_RET_HANDLED) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_INTERN_TRAN, qs_id)
QS_TIME_PRE_(); // time stamp
QS_SIG_PRE_(e->sig); // the signal of the event
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(s); // the source state
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
}
else {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_IGNORED, qs_id)
QS_TIME_PRE_(); // time stamp
QS_SIG_PRE_(e->sig); // the signal of the event
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(m_state.fun); // the current state
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
m_state.fun = t; // change the current active state
#ifndef Q_UNSAFE
m_temp.uint = ~m_state.uint;
#endif</code>
</operation>
<!--${QEP::QHsm::isIn}-->
<operation name="isIn" type="bool" visibility="0x00" properties="0x00">
<specifiers>noexcept override</specifiers>
<!--${QEP::QHsm::isIn::state}-->
<parameter name="state" type="QStateHandler const"/>
<code>QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(602, m_state.uint
== static_cast<std::uintptr_t>(~m_temp.uint));
QF_CRIT_EXIT();
bool inState = false; // assume that this HSM is not in 'state'
// scan the state hierarchy bottom-up
QStateHandler s = m_state.fun;
std::int_fast8_t limit = MAX_NEST_DEPTH_ + 1; // loop hard limit
QState r = Q_RET_SUPER;
for (; (r != Q_RET_IGNORED) && (limit > 0); --limit) {
if (s == state) { // do the states match?
inState = true; // 'true' means that match found
break; // break out of the for-loop
}
else {
r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG);
s = m_temp.fun;
}
}
QF_CRIT_ENTRY();
Q_ENSURE_INCRIT(690, limit > 0);
QF_CRIT_EXIT();
#ifndef Q_UNSAFE
m_temp.uint = ~m_state.uint;
#endif
return inState; // return the status</code>
</operation>
<!--${QEP::QHsm::state}-->
<operation name="state" type="QStateHandler" visibility="0x00" properties="0x02">
<specifiers>const noexcept</specifiers>
<code>return m_state.fun;</code>
</operation>
<!--${QEP::QHsm::childState}-->
<operation name="childState" type="QStateHandler" visibility="0x00" properties="0x00">
<specifiers>noexcept</specifiers>
<!--${QEP::QHsm::childState::parent}-->
<parameter name="parent" type="QStateHandler const"/>
<code>QStateHandler child = m_state.fun; // start with the current state
bool isFound = false; // start with the child not found
// establish stable state configuration
m_temp.fun = child;
QState r;
do {
// is this the parent of the current child?
if (m_temp.fun == parent) {
isFound = true; // child is found
r = Q_RET_IGNORED; // break out of the loop
}
else {
child = m_temp.fun;
r = QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG);
}
} while (r != Q_RET_IGNORED); // QHsm::top() state not reached
#ifndef Q_UNSAFE
m_temp.uint = ~m_state.uint;
#endif
QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_ASSERT_INCRIT(890, isFound);
QF_CRIT_EXIT();
return child; // return the child</code>
</operation>
<!--${QEP::QHsm::getStateHandler}-->
<operation name="getStateHandler?def Q_SPY" type="QStateHandler" visibility="0x00" properties="0x06">
<specifiers>noexcept override</specifiers>
<code>return m_state.fun;</code>
</operation>
<!--${QEP::QHsm::hsm_tran}-->
<operation name="hsm_tran" type="std::int_fast8_t" visibility="0x02" properties="0x00">
<!--${QEP::QHsm::hsm_tran::(&path)[MAX_NEST_DEPTH_]}-->
<parameter name="(&path)[MAX_NEST_DEPTH_]" type="QStateHandler"/>
<!--${QEP::QHsm::hsm_tran::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>#ifndef Q_SPY
Q_UNUSED_PAR(qs_id);
#endif
std::int_fast8_t ip = -1; // tran. entry path index
QStateHandler t = path[0];
QStateHandler const s = path[2];
QF_CRIT_STAT
// (a) check source==target (tran. to self)...
if (s == t) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qs_id);
}
ip = 0; // enter the target
}
else {
// find superstate of target
static_cast<void>(QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG));
t = m_temp.fun;
// (b) check source==target->super...
if (s == t) {
ip = 0; // enter the target
}
else {
// find superstate of src
static_cast<void>(QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG));
// (c) check source->super==target->super...
if (m_temp.fun == t) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qs_id);
}
ip = 0; // enter the target
}
else {
// (d) check source->super==target...
if (m_temp.fun == path[0]) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qs_id);
}
}
else {
// (e) check rest of source==target->super->super..
// and store the entry path along the way
std::int_fast8_t iq = 0; // indicate that LCA was found
ip = 1; // enter target and its superstate
path[1] = t; // save the superstate of target
t = m_temp.fun; // save source->super
// find target->super->super...
QState r = QHSM_RESERVED_EVT_(path[1], Q_EMPTY_SIG);
while (r == Q_RET_SUPER) {
++ip;
path[ip] = m_temp.fun; // store the entry path
if (m_temp.fun == s) { // is it the source?
iq = 1; // indicate that the LCA found
// entry path must not overflow
QF_CRIT_ENTRY();
Q_ASSERT_INCRIT(510, ip < MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
--ip; // do not enter the source
r = Q_RET_HANDLED; // terminate the loop
}
else { // it is not the source, keep going up
r = QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG);
}
}
// the LCA not found yet?
if (iq == 0) {
// entry path must not overflow
QF_CRIT_ENTRY();
Q_ASSERT_INCRIT(520, ip < MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG)
== Q_RET_HANDLED)
{
QS_STATE_EXIT_(s, qs_id);
}
// (f) check the rest of source->super
// == target->super->super...
iq = ip;
r = Q_RET_IGNORED; // indicate that the LCA NOT found
do {
if (t == path[iq]) { // is this the LCA?
r = Q_RET_HANDLED; // indicate the LCA found
ip = iq - 1; // do not enter the LCA
iq = -1; // cause termination of the loop
}
else {
--iq; // try lower superstate of target
}
} while (iq >= 0);
// the LCA not found yet?
if (r != Q_RET_HANDLED) {
// (g) check each source->super->...
// for each target->super...
r = Q_RET_IGNORED; // keep looping
do {
// exit from t
if (QHSM_RESERVED_EVT_(t, Q_EXIT_SIG)
== Q_RET_HANDLED)
{
QS_STATE_EXIT_(t, qs_id);
// find superstate of t
static_cast<void>(
QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG));
}
t = m_temp.fun; // set to super of t
iq = ip;
do {
// is this the LCA?
if (t == path[iq]) {
ip = iq - 1; // do not enter the LCA
iq = -1; // break out of inner loop
r = Q_RET_HANDLED; // break outer loop
}
else {
--iq;
}
} while (iq >= 0);
} while (r != Q_RET_HANDLED);
}
}
}
}
}
}
return ip;</code>
</operation>
</class>
<!--${QEP::QMsm}-->
<class name="QMsm" superclass="QEP::QAsm">
<documentation>Machine-generated State Machine</documentation>
<!--${QEP::QMsm::QMsm}-->
<operation name="QMsm" type="explicit" visibility="0x01" properties="0x00">
<specifiers>noexcept</specifiers>
<!--${QEP::QMsm::QMsm::initial}-->
<parameter name="initial" type="QStateHandler const"/>
<code> : QAsm()
m_state.obj = &l_msm_top_s; // the current state (top)
m_temp.fun = initial; // the initial tran. handler</code>
</operation>
<!--${QEP::QMsm::init}-->
<operation name="init" type="void" visibility="0x00" properties="0x04">
<specifiers>override</specifiers>
<!--${QEP::QMsm::init::e}-->
<parameter name="e" type="void const * const"/>
<!--${QEP::QMsm::init::qs_id}-->
<parameter name="qs_id" type="std::uint_fast8_t const"/>
<code>#ifndef Q_SPY
Q_UNUSED_PAR(qs_id);
#endif
QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(200, (m_temp.fun != nullptr)
&& (m_state.obj == &l_msm_top_s));
QF_CRIT_EXIT();
// execute the top-most initial tran.
QState r = (*m_temp.fun)(this, Q_EVT_CAST(QEvt));
QF_CRIT_ENTRY();
// the top-most initial tran. must be taken
Q_ASSERT_INCRIT(210, r == Q_RET_TRAN_INIT);
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QEP_STATE_INIT, qs_id)
QS_OBJ_PRE_(this); // this state machine object
QS_FUN_PRE_(m_state.obj->stateHandler); // source state
QS_FUN_PRE_(m_temp.tatbl->target->stateHandler); // target state
QS_END_PRE_()
QS_MEM_APP();
QF_CRIT_EXIT();