QP/C++  7.3.4
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qp.hpp
Go to the documentation of this file.
1//$file${include::qp.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpcpp.qm
4// File: ${include::qp.hpp}
5//
6// This code has been generated by QM 6.1.1 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// This code is covered by the following QP license:
10// License # : LicenseRef-QL-dual
11// Issued to : Any user of the QP/C++ real-time embedded framework
12// Framework(s) : qpcpp
13// Support ends : 2024-12-31
14// License scope:
15//
16// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
17//
18// Q u a n t u m L e a P s
19// ------------------------
20// Modern Embedded Software
21//
22// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
23//
24// This software is dual-licensed under the terms of the open source GNU
25// General Public License version 3 (or any later version), or alternatively,
26// under the terms of one of the closed source Quantum Leaps commercial
27// licenses.
28//
29// The terms of the open source GNU General Public License version 3
30// can be found at: <www.gnu.org/licenses/gpl-3.0>
31//
32// The terms of the closed source Quantum Leaps commercial licenses
33// can be found at: <www.state-machine.com/licensing>
34//
35// Redistributions in source code must retain this top-level comment block.
36// Plagiarizing this software to sidestep the license obligations is illegal.
37//
38// Contact information:
39// <www.state-machine.com/licensing>
40// <info@state-machine.com>
41//
42//$endhead${include::qp.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43#ifndef QP_HPP_
44#define QP_HPP_
45
46//============================================================================
47#define QP_VERSION 734U
48#define QP_VERSION_STR "7.3.4"
49
50//! Encrypted current QP release (7.3.4) and date (2024-03-21)
51#define QP_RELEASE 0x70C1EA11U
52
53//============================================================================
54//! @cond INTERNAL
55
56#ifndef Q_SIGNAL_SIZE
57#define Q_SIGNAL_SIZE 2U
58#endif // ndef Q_SIGNAL_SIZE
59
60#ifndef QF_MAX_ACTIVE
61#define QF_MAX_ACTIVE 32U
62#endif
63
64#if (QF_MAX_ACTIVE > 64U)
65#error QF_MAX_ACTIVE exceeds the maximum of 64U;
66#endif
67
68#ifndef QF_MAX_TICK_RATE
69#define QF_MAX_TICK_RATE 1U
70#endif
71
72#if (QF_MAX_TICK_RATE > 15U)
73#error QF_MAX_TICK_RATE exceeds the maximum of 15U;
74#endif
75
76#ifndef QF_MAX_EPOOL
77#define QF_MAX_EPOOL 3U
78#endif
79
80#if (QF_MAX_EPOOL > 15U)
81#error QF_MAX_EPOOL exceeds the maximum of 15U;
82#endif
83
84#ifndef QF_TIMEEVT_CTR_SIZE
85#define QF_TIMEEVT_CTR_SIZE 4U
86#endif
87
88#if (QF_TIMEEVT_CTR_SIZE > 4U)
89#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U;
90#endif
91
92#ifndef QF_EVENT_SIZ_SIZE
93#define QF_EVENT_SIZ_SIZE 2U
94#endif
95
96#if (QF_EVENT_SIZ_SIZE > 4U)
97#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U;
98#endif
99
100//! @endcond
101//============================================================================
102//$declare${glob-types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
103
104//${glob-types::int_t} .......................................................
105using int_t = int;
106
107//${glob-types::enum_t} ......................................................
108using enum_t = int;
109
110//${glob-types::float32_t} ...................................................
111using float32_t = float;
112
113//${glob-types::float64_t} ...................................................
114using float64_t = double;
115//$enddecl${glob-types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116
117//$declare${QEP} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
118namespace QP {
119
120//${QEP::versionStr[]} .......................................................
121constexpr char const versionStr[] {QP_VERSION_STR};
122
123//${QEP::QSignal} ............................................................
124#if (Q_SIGNAL_SIZE == 1U)
125using QSignal = std::uint8_t;
126#endif // (Q_SIGNAL_SIZE == 1U)
127
128//${QEP::QSignal} ............................................................
129#if (Q_SIGNAL_SIZE == 2U)
130using QSignal = std::uint16_t;
131#endif // (Q_SIGNAL_SIZE == 2U)
132
133//${QEP::QSignal} ............................................................
134#if (Q_SIGNAL_SIZE == 4U)
135using QSignal = std::uint32_t;
136#endif // (Q_SIGNAL_SIZE == 4U)
137
138//${QEP::QEvt} ...............................................................
139class QEvt {
140public:
142 std::uint8_t volatile refCtr_;
143 std::uint8_t evtTag_;
144
145public:
146 static constexpr std::uint8_t MARKER {0xE0U};
147
148#ifdef QEVT_DYN_CTOR
149 enum DynEvt: std::uint8_t { DYNAMIC };
150#endif // def QEVT_DYN_CTOR
151
152public:
153
154#ifdef QEVT_DYN_CTOR
155 QEvt * ctor(DynEvt const dummy) noexcept;
156#endif // def QEVT_DYN_CTOR
157 explicit constexpr QEvt(QSignal const s) noexcept
158 : sig(s),
159 refCtr_(0U),
161 {}
162 QEvt() = delete;
163 static bool verify_(QEvt const * const e) noexcept {
164 return (e != nullptr)
165 && ((e->evtTag_ & 0xF0U) == MARKER);
166 }
167 std::uint_fast8_t getPoolNum_() const noexcept {
168 return static_cast<std::uint8_t>(evtTag_) & 0x0FU;
169 }
170}; // class QEvt
171
172//${QEP::QState} .............................................................
173using QState = std::uint_fast8_t;
174
175//${QEP::QStateHandler} ......................................................
176using QStateHandler = QState (*)(void * const me, QEvt const * const e);
177
178//${QEP::QActionHandler} .....................................................
179using QActionHandler = QState (*)(void * const me);
180
181//${QEP::QXThread} ...........................................................
182// forward declaration
183class QXThread;
184
185//${QEP::QXThreadHandler} ....................................................
186using QXThreadHandler = void (*)(QXThread * const me);
187
188//${QEP::QMState} ............................................................
196
197//${QEP::QMTranActTable} .....................................................
201};
202
203//${QEP::QAsmAttr} ...........................................................
204union QAsmAttr {
208 QMState const *obj;
210#ifndef Q_UNSAFE
211 std::uintptr_t uint;
212#endif
213 constexpr QAsmAttr() : fun(nullptr) {}
214};
215
216//${QEP::Q_USER_SIG} .........................................................
217constexpr enum_t Q_USER_SIG {4};
218
219//${QEP::QAsm} ...............................................................
220class QAsm {
221protected:
224
225public:
226
227 //! All possible return values from state-handlers
228 //! @note
229 //! The order is important for algorithmic correctness.
231 // unhandled and need to "bubble up"
232 Q_RET_SUPER, //!< event passed to superstate to handle
233 Q_RET_SUPER_SUB, //!< event passed to submachine superstate
234 Q_RET_UNHANDLED, //!< event unhandled due to a guard
235
236 // handled and do not need to "bubble up"
237 Q_RET_HANDLED, //!< event handled (internal transition)
238 Q_RET_IGNORED, //!< event silently ignored (bubbled up to top)
239
240 // entry/exit
241 Q_RET_ENTRY, //!< state entry action executed
242 Q_RET_EXIT, //!< state exit action executed
243
244 // no side effects
245 Q_RET_NULL, //!< return value without any effect
246
247 // transitions need to execute transition-action table in QP::QMsm
248 Q_RET_TRAN, //!< regular transition
249 Q_RET_TRAN_INIT, //!< initial transition in a state or submachine
250 Q_RET_TRAN_EP, //!< entry-point transition into a submachine
251
252 // transitions that additionally clobber QHsm.m_state
253 Q_RET_TRAN_HIST, //!< transition to history of a given state
254 Q_RET_TRAN_XP //!< exit-point transition out of a submachine
255 };
256
257 //! Reserved signals by the QP-framework.
259 Q_EMPTY_SIG, //!< signal to execute the default case
260 Q_ENTRY_SIG, //!< signal for entry actions
261 Q_EXIT_SIG, //!< signal for exit actions
262 Q_INIT_SIG //!< signal for nested initial transitions
263 };
264
265protected:
266 explicit QAsm() noexcept
267 : m_state(),
268 m_temp ()
269 {}
270
271public:
272
273#ifdef Q_XTOR
274 virtual ~QAsm() noexcept {
275 // empty
276 }
277#endif // def Q_XTOR
278 virtual void init(
279 void const * const e,
280 std::uint_fast8_t const qsId) = 0;
281 virtual void init(std::uint_fast8_t const qsId) {
282 this->init(nullptr, qsId);
283 }
284 virtual void dispatch(
285 QEvt const * const e,
286 std::uint_fast8_t const qsId) = 0;
287 virtual bool isIn(QStateHandler const state) noexcept {
288 static_cast<void>(state);
289 return false;
290 }
291 QStateHandler state() const noexcept {
292 return m_state.fun;
293 }
294 QMState const * stateObj() const noexcept {
295 return m_state.obj;
296 }
297
298#ifdef Q_SPY
299 virtual QStateHandler getStateHandler() noexcept {
300 return m_state.fun;
301 }
302#endif // def Q_SPY
303 static QState top(
304 void * const me,
305 QEvt const * const e) noexcept
306 {
307 static_cast<void>(me);
308 static_cast<void>(e);
309 return Q_RET_IGNORED; // the top state ignores all events
310 }
311
312protected:
313 QState tran(QStateHandler const target) noexcept {
314 m_temp.fun = target;
315 return Q_RET_TRAN;
316 }
317 QState tran_hist(QStateHandler const hist) noexcept {
318 m_temp.fun = hist;
319 return Q_RET_TRAN_HIST;
320 }
321 QState super(QStateHandler const superstate) noexcept {
322 m_temp.fun = superstate;
323 return Q_RET_SUPER;
324 }
325 QState qm_tran(void const * const tatbl) noexcept {
326 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
327 return Q_RET_TRAN;
328 }
329 QState qm_tran_init(void const * const tatbl) noexcept {
330 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
331 return Q_RET_TRAN_INIT;
332 }
334 QMState const * const hist,
335 void const * const tatbl) noexcept
336 {
337 m_state.obj = hist;
338 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
339 return Q_RET_TRAN_HIST;
340 }
341 QState qm_tran_ep(void const * const tatbl) noexcept {
342 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
343 return Q_RET_TRAN_EP;
344 }
346 QActionHandler const xp,
347 void const * const tatbl) noexcept
348 {
349 m_state.act = xp;
350 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
351 return Q_RET_TRAN_XP;
352 }
353
354#ifdef Q_SPY
355 QState qm_entry(QMState const * const s) noexcept {
356 m_temp.obj = s;
357 return Q_RET_ENTRY;
358 }
359#endif // def Q_SPY
360
361#ifndef Q_SPY
362 QState qm_entry(QMState const * const s) noexcept {
363 static_cast<void>(s); // unused parameter
364 return Q_RET_ENTRY;
365 }
366#endif // ndef Q_SPY
367
368#ifdef Q_SPY
369 QState qm_exit(QMState const * const s) noexcept {
370 m_temp.obj = s;
371 return Q_RET_EXIT;
372 }
373#endif // def Q_SPY
374
375#ifndef Q_SPY
376 QState qm_exit(QMState const * const s) noexcept {
377 static_cast<void>(s); // unused parameter
378 return Q_RET_EXIT;
379 }
380#endif // ndef Q_SPY
381 QState qm_sm_exit(QMState const * const s) noexcept {
382 m_temp.obj = s;
383 return Q_RET_EXIT;
384 }
385 QState qm_super_sub(QMState const * const s) noexcept {
386 m_temp.obj = s;
387 return Q_RET_SUPER_SUB;
388 }
389}; // class QAsm
390
391//${QEP::QHsm} ...............................................................
392class QHsm : public QP::QAsm {
393public:
394 static constexpr std::int_fast8_t MAX_NEST_DEPTH_{6};
395
396protected:
397 explicit QHsm(QStateHandler const initial) noexcept;
398
399public:
400 void init(
401 void const * const e,
402 std::uint_fast8_t const qsId) override;
403 void init(std::uint_fast8_t const qsId) override {
404 this->init(nullptr, qsId);
405 }
406 void dispatch(
407 QEvt const * const e,
408 std::uint_fast8_t const qsId) override;
409 bool isIn(QStateHandler const state) noexcept override;
410 QStateHandler childState(QStateHandler const parent) noexcept;
411
412#ifdef Q_SPY
413 QStateHandler getStateHandler() noexcept override {
414 return m_state.fun;
415 }
416#endif // def Q_SPY
417
418private:
419 std::int_fast8_t hsm_tran(
421 std::uint_fast8_t const qsId);
422}; // class QHsm
423
424//${QEP::QMsm} ...............................................................
425class QMsm : public QP::QAsm {
426protected:
427 explicit QMsm(QStateHandler const initial) noexcept;
428
429public:
430 void init(
431 void const * const e,
432 std::uint_fast8_t const qsId) override;
433 void init(std::uint_fast8_t const qsId) override {
434 this->init(nullptr, qsId);
435 }
436 void dispatch(
437 QEvt const * const e,
438 std::uint_fast8_t const qsId) override;
439
440#ifdef Q_SPY
441 QStateHandler getStateHandler() noexcept override {
442 return m_state.obj->stateHandler;
443 }
444#endif // def Q_SPY
445 bool isIn(QStateHandler const state) noexcept override;
446
447 //! @deprecated instead use: QMsm::isIn()
448 bool isInState(QMState const * const stateObj) const noexcept;
449 QMState const * childStateObj(QMState const * const parent) const noexcept;
450
451private:
453 QMTranActTable const * const tatbl,
454 std::uint_fast8_t const qsId);
456 QMState const * const cs,
457 QMState const * const ts,
458 std::uint_fast8_t const qsId);
460 QMState const * const hist,
461 std::uint_fast8_t const qsId);
462
463public:
464 QMState const * topQMState() const noexcept;
465}; // class QMsm
466
467} // namespace QP
468//$enddecl${QEP} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
469
470//$declare${QEP-macros} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
471
472//${QEP-macros::Q_STATE_DECL} ................................................
473#define Q_STATE_DECL(state_) \
474 QP::QState state_ ## _h(QP::QEvt const * const e); \
475 static QP::QState state_(void * const me, QP::QEvt const * const e)
476
477//${QEP-macros::Q_STATE_DEF} .................................................
478#define Q_STATE_DEF(subclass_, state_) \
479 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \
480 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
481 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
482
483//${QEP-macros::Q_HANDLED} ...................................................
484#define Q_HANDLED() (Q_RET_HANDLED)
485
486//${QEP-macros::Q_UNHANDLED} .................................................
487#define Q_UNHANDLED() (Q_RET_UNHANDLED)
488
489//${QEP-macros::Q_EVT_CAST} ..................................................
490#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e))
491
492//${QEP-macros::Q_STATE_CAST} ................................................
493#define Q_STATE_CAST(handler_) \
494 (reinterpret_cast<QP::QStateHandler>(handler_))
495
496//${QEP-macros::QM_STATE_DECL} ...............................................
497#define QM_STATE_DECL(state_) \
498 QP::QState state_ ## _h(QP::QEvt const * const e); \
499 static QP::QState state_(void * const me, QP::QEvt const * const e); \
500 static QP::QMState const state_ ## _s
501
502//${QEP-macros::QM_SM_STATE_DECL} ............................................
503#define QM_SM_STATE_DECL(subm_, state_) \
504 QP::QState state_ ## _h(QP::QEvt const * const e);\
505 static QP::QState state_(void * const me, QP::QEvt const * const e); \
506 static SM_ ## subm_ const state_ ## _s
507
508//${QEP-macros::QM_ACTION_DECL} ..............................................
509#define QM_ACTION_DECL(action_) \
510 QP::QState action_ ## _h(); \
511 static QP::QState action_(void * const me)
512
513//${QEP-macros::QM_STATE_DEF} ................................................
514#define QM_STATE_DEF(subclass_, state_) \
515 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
516 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
517 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
518
519//${QEP-macros::QM_ACTION_DEF} ...............................................
520#define QM_ACTION_DEF(subclass_, action_) \
521 QP::QState subclass_::action_(void * const me) { \
522 return static_cast<subclass_ *>(me)->action_ ## _h(); } \
523 QP::QState subclass_::action_ ## _h()
524
525//${QEP-macros::QM_HANDLED} ..................................................
526#define QM_HANDLED() (Q_RET_HANDLED)
527
528//${QEP-macros::QM_UNHANDLED} ................................................
529#define QM_UNHANDLED() (Q_RET_HANDLED)
530
531//${QEP-macros::QM_SUPER} ....................................................
532#define QM_SUPER() (Q_RET_SUPER)
533
534//${QEP-macros::QM_STATE_NULL} ...............................................
535#define QM_STATE_NULL (nullptr)
536
537//${QEP-macros::Q_ACTION_NULL} ...............................................
538#define Q_ACTION_NULL (nullptr)
539
540//${QEP-macros::Q_UNUSED_PAR} ................................................
541#define Q_UNUSED_PAR(par_) (static_cast<void>(par_))
542
543//${QEP-macros::Q_DIM} .......................................................
544#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
545
546//${QEP-macros::Q_UINT2PTR_CAST} .............................................
547#define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_))
548
549//${QEP-macros::INIT} ........................................................
550#ifdef Q_SPY
551#define INIT(qsId_) init((qsId_))
552#endif // def Q_SPY
553
554//${QEP-macros::INIT} ........................................................
555#ifndef Q_SPY
556#define INIT(dummy) init(0U)
557#endif // ndef Q_SPY
558
559//${QEP-macros::DISPATCH} ....................................................
560#ifdef Q_SPY
561#define DISPATCH(e_, qsId_) dispatch((e_), (qsId_))
562#endif // def Q_SPY
563
564//${QEP-macros::DISPATCH} ....................................................
565#ifndef Q_SPY
566#define DISPATCH(e_, dummy) dispatch((e_), 0U)
567#endif // ndef Q_SPY
568//$enddecl${QEP-macros} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
569
570//$declare${QF::types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
571namespace QP {
572
573//${QF::types::QPrioSpec} ....................................................
574using QPrioSpec = std::uint16_t;
575
576//${QF::types::QTimeEvtCtr} ..................................................
577#if (QF_TIMEEVT_CTR_SIZE == 1U)
578using QTimeEvtCtr = std::uint8_t;
579#endif // (QF_TIMEEVT_CTR_SIZE == 1U)
580
581//${QF::types::QTimeEvtCtr} ..................................................
582#if (QF_TIMEEVT_CTR_SIZE == 2U)
583using QTimeEvtCtr = std::uint16_t;
584#endif // (QF_TIMEEVT_CTR_SIZE == 2U)
585
586//${QF::types::QTimeEvtCtr} ..................................................
587#if (QF_TIMEEVT_CTR_SIZE == 4U)
588using QTimeEvtCtr = std::uint32_t;
589#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
590
591//${QF::types::QPSetBits} ....................................................
592#if (QF_MAX_ACTIVE <= 8U)
593using QPSetBits = std::uint8_t;
594#endif // (QF_MAX_ACTIVE <= 8U)
595
596//${QF::types::QPSetBits} ....................................................
597#if (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
598using QPSetBits = std::uint16_t;
599#endif // (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
600
601//${QF::types::QPSetBits} ....................................................
602#if (16 < QF_MAX_ACTIVE)
603using QPSetBits = std::uint32_t;
604#endif // (16 < QF_MAX_ACTIVE)
605
606//${QF::types::QF_LOG2} ......................................................
607#ifndef QF_LOG2
608std::uint_fast8_t QF_LOG2(QP::QPSetBits x) noexcept;
609#endif // ndef QF_LOG2
610
611//${QF::types::QPSet} ........................................................
612class QPSet {
613private:
614 QPSetBits m_bits[((QF_MAX_ACTIVE + (8U*sizeof(QPSetBits))) - 1U)/(8U*sizeof(QPSetBits))];
615
616public:
617 void setEmpty() noexcept {
618 m_bits[0] = 0U;
619 #if (QF_MAX_ACTIVE > 32)
620 m_bits[1] = 0U;
621 #endif
622 }
623 bool isEmpty() const noexcept {
624 #if (QF_MAX_ACTIVE <= 32U)
625 return (m_bits[0] == 0U);
626 #else
627 return (m_bits[0] == 0U) ? (m_bits[1] == 0U) : false;
628 #endif
629 }
630 bool notEmpty() const noexcept {
631 #if (QF_MAX_ACTIVE <= 32U)
632 return (m_bits[0] != 0U);
633 #else
634 return (m_bits[0] != 0U) ? true : (m_bits[1] != 0U);
635 #endif
636 }
637 bool hasElement(std::uint_fast8_t const n) const noexcept {
638 #if (QF_MAX_ACTIVE <= 32U)
639 return (m_bits[0] & (static_cast<QPSetBits>(1U) << (n - 1U))) != 0U;
640 #else
641 return (n <= 32U)
642 ? ((m_bits[0] & (static_cast<QPSetBits>(1U) << (n - 1U))) != 0U)
643 : ((m_bits[1] & (static_cast<QPSetBits>(1U) << (n - 33U))) != 0U);
644 #endif
645 }
646 void insert(std::uint_fast8_t const n) noexcept {
647 #if (QF_MAX_ACTIVE <= 32U)
648 m_bits[0] = (m_bits[0] | (static_cast<QPSetBits>(1U) << (n - 1U)));
649 #else
650 if (n <= 32U) {
651 m_bits[0] = (m_bits[0] | (static_cast<QPSetBits>(1U) << (n - 1U)));
652 }
653 else {
654 m_bits[1] = (m_bits[1] | (static_cast<QPSetBits>(1U) << (n - 33U)));
655 }
656 #endif
657 }
658 void remove(std::uint_fast8_t const n) noexcept {
659 #if (QF_MAX_ACTIVE <= 32U)
660 m_bits[0] = (m_bits[0] & static_cast<QPSetBits>(~(1U << (n - 1U))));
661 #else
662 if (n <= 32U) {
663 (m_bits[0] = (m_bits[0] & ~(static_cast<QPSetBits>(1U) << (n - 1U))));
664 }
665 else {
666 (m_bits[1] = (m_bits[1] & ~(static_cast<QPSetBits>(1U) << (n - 33U))));
667 }
668 #endif
669 }
670 std::uint_fast8_t findMax() const noexcept {
671 #if (QF_MAX_ACTIVE <= 32U)
672 return QF_LOG2(m_bits[0]);
673 #else
674 return (m_bits[1] != 0U)
675 ? (QF_LOG2(m_bits[1]) + 32U)
676 : (QF_LOG2(m_bits[0]));
677 #endif
678 }
679
680#ifndef Q_UNSAFE
681 void update_(QPSet * const dis) const noexcept {
682 dis->m_bits[0] = ~m_bits[0];
683 #if (QF_MAX_ACTIVE > 32U)
684 dis->m_bits[1] = ~m_bits[1];
685 #endif
686 }
687#endif // ndef Q_UNSAFE
688
689#ifndef Q_UNSAFE
690 bool verify_(QPSet const * const dis) const noexcept {
691 #if (QF_MAX_ACTIVE <= 32U)
692 return m_bits[0] == static_cast<QPSetBits>(~dis->m_bits[0]);
693 #else
694 return (m_bits[0] == static_cast<QPSetBits>(~dis->m_bits[0]))
695 && (m_bits[1] == static_cast<QPSetBits>(~dis->m_bits[1]));
696 #endif
697 }
698#endif // ndef Q_UNSAFE
699}; // class QPSet
700
701//${QF::types::QSubscrList} ..................................................
703private:
705
706#ifndef Q_UNSAFE
708#endif // ndef Q_UNSAFE
709
710 // friends...
711 friend class QActive;
712}; // class QSubscrList
713
714//${QF::types::QEQueue} ......................................................
715class QEQueue;
716
717} // namespace QP
718//$enddecl${QF::types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
719
720//$declare${QF::QActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
721namespace QP {
722
723//${QF::QActive} .............................................................
724class QActive : public QP::QAsm {
725protected:
726 std::uint8_t m_prio;
727 std::uint8_t m_pthre;
728
729#ifdef QACTIVE_THREAD_TYPE
731#endif // def QACTIVE_THREAD_TYPE
732
733#ifdef QACTIVE_OS_OBJ_TYPE
735#endif // def QACTIVE_OS_OBJ_TYPE
736
737#ifdef QACTIVE_EQUEUE_TYPE
739#endif // def QACTIVE_EQUEUE_TYPE
740
741public:
742
743#ifndef Q_UNSAFE
744 std::uint8_t m_prio_dis;
745#endif // ndef Q_UNSAFE
746
747#ifndef Q_UNSAFE
748 std::uint8_t m_pthre_dis;
749#endif // ndef Q_UNSAFE
750 static QActive * registry_[QF_MAX_ACTIVE + 1U];
753
754 // friends...
755 friend class QTimeEvt;
756 friend class QTicker;
757 friend class QXThread;
758 friend class QXMutex;
759 friend class QXSemaphore;
760 friend class QActiveDummy;
761 friend class GuiQActive;
762 friend class GuiQMActive;
763 friend void schedLock();
764
765protected:
766 explicit QActive(QStateHandler const initial) noexcept
767 : QAsm(),
768 m_prio(0U),
769 m_pthre(0U)
770 {
771 m_state.fun = Q_STATE_CAST(&top);
772 m_temp.fun = initial;
773
774 #ifndef Q_UNSAFE
775 m_prio_dis = static_cast<std::uint8_t>(~m_prio);
776 m_pthre_dis = static_cast<std::uint8_t>(~m_pthre);
777 #endif
778 }
779
780public:
781 void init(
782 void const * const e,
783 std::uint_fast8_t const qsId) override
784 {
785 reinterpret_cast<QHsm *>(this)->QHsm::init(e, qsId);
786 }
787 void init(std::uint_fast8_t const qsId) override {
788 this->init(nullptr, qsId);
789 }
791 QEvt const * const e,
792 std::uint_fast8_t const qsId) override
793 {
794 reinterpret_cast<QHsm *>(this)->QHsm::dispatch(e, qsId);
795 }
796 bool isIn(QStateHandler const state) noexcept override {
797 return reinterpret_cast<QHsm *>(this)->QHsm::isIn(state);
798 }
799 QStateHandler childState(QStateHandler const parent) noexcept {
800 return reinterpret_cast<QHsm *>(this)->QHsm::childState(parent);
801 }
803 std::uint32_t attr1,
804 void const * attr2 = nullptr);
805 void start(
806 QPrioSpec const prioSpec,
807 QEvt const * * const qSto,
808 std::uint_fast16_t const qLen,
809 void * const stkSto,
810 std::uint_fast16_t const stkSize,
811 void const * const par);
812 void start(
813 QPrioSpec const prioSpec,
814 QEvt const * * const qSto,
815 std::uint_fast16_t const qLen,
816 void * const stkSto,
817 std::uint_fast16_t const stkSize)
818 {
819 this->start(prioSpec, qSto, qLen, stkSto, stkSize, nullptr);
820 }
821
822#ifdef QACTIVE_CAN_STOP
823 void stop();
824#endif // def QACTIVE_CAN_STOP
825 void register_() noexcept;
826 void unregister_() noexcept;
827 bool post_(
828 QEvt const * const e,
829 std::uint_fast16_t const margin,
830 void const * const sender) noexcept;
831 void postLIFO(QEvt const * const e) noexcept;
832 QEvt const * get_() noexcept;
833 static std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept;
834 static void psInit(
835 QSubscrList * const subscrSto,
836 enum_t const maxSignal) noexcept;
837 static void publish_(
838 QEvt const * const e,
839 void const * const sender,
840 std::uint_fast8_t const qsId) noexcept;
841 void subscribe(enum_t const sig) const noexcept;
842 void unsubscribe(enum_t const sig) const noexcept;
843 void unsubscribeAll() const noexcept;
844 bool defer(
845 QEQueue * const eq,
846 QEvt const * const e) const noexcept;
847 bool recall(QEQueue * const eq) noexcept;
848 std::uint_fast16_t flushDeferred(
849 QEQueue * const eq,
850 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
851 std::uint_fast8_t getPrio() const noexcept {
852 return static_cast<std::uint_fast8_t>(m_prio);
853 }
854 void setPrio(QPrioSpec const prio) noexcept {
855 m_prio = static_cast<std::uint8_t>(prio & 0xFFU);
856 m_pthre = static_cast<std::uint8_t>(prio >> 8U);
857 }
858 std::uint_fast8_t getPThre() const noexcept {
859 return static_cast<std::uint_fast8_t>(m_pthre);
860 }
861
862#ifdef QACTIVE_EQUEUE_TYPE
863 QACTIVE_EQUEUE_TYPE const & getEQueue() const noexcept {
864 return m_eQueue;
865 }
866#endif // def QACTIVE_EQUEUE_TYPE
867
868#ifdef QACTIVE_OS_OBJ_TYPE
869 QACTIVE_OS_OBJ_TYPE const & getOsObject() const noexcept {
870 return m_osObject;
871 }
872#endif // def QACTIVE_OS_OBJ_TYPE
873
874#ifdef QACTIVE_THREAD_TYPE
875 QACTIVE_THREAD_TYPE const & getThread() const noexcept {
876 return m_thread;
877 }
878#endif // def QACTIVE_THREAD_TYPE
879
880#ifdef QACTIVE_THREAD_TYPE
881 void setThread(QACTIVE_THREAD_TYPE const & thr) {
882 m_thread = thr;
883 }
884#endif // def QACTIVE_THREAD_TYPE
885 static void evtLoop_(QActive * act);
886
887#ifdef QF_ISR_API
888 virtual bool postFromISR(
889 QEvt const * const e,
890 std::uint_fast16_t const margin,
891 void * par,
892 void const * const sender) noexcept;
893#endif // def QF_ISR_API
894
895#ifdef QF_ISR_API
896 static void publishFromISR(
897 QEvt const * e,
898 void * par,
899 void const * sender) noexcept;
900#endif // def QF_ISR_API
901}; // class QActive
902
903} // namespace QP
904//$enddecl${QF::QActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
905
906//$declare${QF::QMActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
907namespace QP {
908
909//${QF::QMActive} ............................................................
910class QMActive : public QP::QActive {
911protected:
912 QMActive(QStateHandler const initial) noexcept;
913
914public:
915 void init(
916 void const * const e,
917 std::uint_fast8_t const qsId) override
918 {
919 reinterpret_cast<QMsm *>(this)->QMsm::init(e, qsId);
920 }
921 void init(std::uint_fast8_t const qsId) override {
922 this->init(nullptr, qsId);
923 }
925 QEvt const * const e,
926 std::uint_fast8_t const qsId) override
927 {
928 reinterpret_cast<QMsm *>(this)->QMsm::dispatch(e, qsId);
929 }
930 bool isIn(QStateHandler const state) noexcept override {
931 return reinterpret_cast<QMsm *>(this)->QMsm::isIn(state);
932 }
933
934#ifdef Q_SPY
935 QStateHandler getStateHandler() noexcept override {
936 return reinterpret_cast<QMsm *>(this)->QMsm::getStateHandler();
937 }
938#endif // def Q_SPY
939 bool isInState(QMState const * const st) const noexcept {
940 return reinterpret_cast<QMsm const *>(this)->QMsm::isInState(st);
941 }
942 QMState const * childStateObj(QMState const * const parent) const noexcept {
943 return reinterpret_cast<QMsm const *>(this)
944 ->QMsm::childStateObj(parent);
945 }
946}; // class QMActive
947
948} // namespace QP
949//$enddecl${QF::QMActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
950
951//$declare${QF::QTimeEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
952namespace QP {
953
954//${QF::QTimeEvt} ............................................................
955class QTimeEvt : public QP::QEvt {
956private:
957 QTimeEvt * volatile m_next;
958 void * m_act;
961
962public:
963 static QTimeEvt timeEvtHead_[QF_MAX_TICK_RATE];
964
965private:
966 friend class QXThread;
967
968public:
969 QTimeEvt(
970 QActive * const act,
971 QSignal const sig,
972 std::uint_fast8_t const tickRate = 0U) noexcept;
973
974#ifdef Q_XTOR
975 ~QTimeEvt();
976#endif // def Q_XTOR
977 void armX(
978 QTimeEvtCtr const nTicks,
979 QTimeEvtCtr const interval = 0U) noexcept;
980 bool disarm() noexcept;
981 bool rearm(QTimeEvtCtr const nTicks) noexcept;
982 bool wasDisarmed() noexcept;
983 void const * getAct() const noexcept {
984 return m_act;
985 }
986 QTimeEvtCtr getCtr() const noexcept {
987 return m_ctr;
988 }
989 QTimeEvtCtr getInterval() const noexcept {
990 return m_interval;
991 }
992 static void tick(
993 std::uint_fast8_t const tickRate,
994 void const * const sender) noexcept;
995
996#ifdef Q_UTEST
997 static void tick1_(
998 std::uint_fast8_t const tickRate,
999 void const * const sender);
1000#endif // def Q_UTEST
1001
1002#ifdef QF_ISR_API
1003 static void tickFromISR(
1004 std::uint_fast8_t const tickRate,
1005 void * par,
1006 void const * sender) noexcept;
1007#endif // def QF_ISR_API
1008 static bool noActive(std::uint_fast8_t const tickRate) noexcept;
1009 QActive * toActive() noexcept {
1010 return static_cast<QActive *>(m_act);
1011 }
1012 QTimeEvt * toTimeEvt() noexcept {
1013 return static_cast<QTimeEvt *>(m_act);
1014 }
1015
1016private:
1017 QTimeEvt() noexcept;
1018 QTimeEvt(QTimeEvt const & other) = delete;
1019 QTimeEvt & operator=(QTimeEvt const & other) = delete;
1020}; // class QTimeEvt
1021
1022} // namespace QP
1023//$enddecl${QF::QTimeEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1024
1025//$declare${QF::QTicker} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1026namespace QP {
1027
1028//${QF::QTicker} .............................................................
1029class QTicker : public QP::QActive {
1030public:
1031 explicit QTicker(std::uint_fast8_t const tickRate) noexcept;
1032 void init(
1033 void const * const e,
1034 std::uint_fast8_t const qsId) override;
1035 void init(std::uint_fast8_t const qsId) override {
1036 this->init(nullptr, qsId);
1037 }
1038 void dispatch(
1039 QEvt const * const e,
1040 std::uint_fast8_t const qsId) override;
1041 void trig_(void const * const sender) noexcept;
1042}; // class QTicker
1043
1044} // namespace QP
1045//$enddecl${QF::QTicker} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1046
1047//$declare${QF::QF-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1048namespace QP {
1049namespace QF {
1050
1051//${QF::QF-base::init} .......................................................
1052void init();
1053
1054//${QF::QF-base::stop} .......................................................
1055void stop();
1056
1057//${QF::QF-base::run} ........................................................
1058int_t run();
1059
1060//${QF::QF-base::onStartup} ..................................................
1062
1063//${QF::QF-base::onCleanup} ..................................................
1065
1066//${QF::QF-base::psInit} .....................................................
1067//! @deprecated
1068inline void psInit(
1069 QSubscrList * const subscrSto,
1070 enum_t const maxSignal) noexcept
1071{
1072 QActive::psInit(subscrSto, maxSignal);
1073}
1074
1075//${QF::QF-base::publish_} ...................................................
1076//! @deprecated
1077inline void publish_(
1078 QEvt const * const e,
1079 void const * const sender,
1080 std::uint_fast8_t const qsId) noexcept
1081{
1082 QActive::publish_(e, sender, qsId);
1083}
1084
1085//${QF::QF-base::tick} .......................................................
1086//! @deprecated
1087inline void tick(
1088 std::uint_fast8_t const tickRate,
1089 void const * const sender) noexcept
1090{
1091 QTimeEvt::tick(tickRate, sender);
1092}
1093
1094//${QF::QF-base::getQueueMin} ................................................
1095//! @deprecated
1096inline std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept {
1097 return QActive::getQueueMin(prio);
1098}
1099
1100//${QF::QF-base::NO_MARGIN} ..................................................
1101constexpr std::uint_fast16_t NO_MARGIN {0xFFFFU};
1102
1103} // namespace QF
1104} // namespace QP
1105//$enddecl${QF::QF-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1106
1107//$declare${QF::QF-dyn} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1108namespace QP {
1109namespace QF {
1110
1111//${QF::QF-dyn::poolInit} ....................................................
1112void poolInit(
1113 void * const poolSto,
1114 std::uint_fast32_t const poolSize,
1115 std::uint_fast16_t const evtSize) noexcept;
1116
1117//${QF::QF-dyn::poolGetMaxBlockSize} .........................................
1118std::uint_fast16_t poolGetMaxBlockSize() noexcept;
1119
1120//${QF::QF-dyn::getPoolMin} ..................................................
1121std::uint_fast16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept;
1122
1123//${QF::QF-dyn::newX_} .......................................................
1124QEvt * newX_(
1125 std::uint_fast16_t const evtSize,
1126 std::uint_fast16_t const margin,
1127 enum_t const sig) noexcept;
1128
1129//${QF::QF-dyn::gc} ..........................................................
1130void gc(QEvt const * const e) noexcept;
1131
1132//${QF::QF-dyn::newRef_} .....................................................
1133QEvt const * newRef_(
1134 QEvt const * const e,
1135 QEvt const * const evtRef) noexcept;
1136
1137//${QF::QF-dyn::deleteRef_} ..................................................
1138void deleteRef_(QEvt const * const evtRef) noexcept;
1139
1140//${QF::QF-dyn::newXfromISR_} ................................................
1141#ifdef QF_ISR_API
1143 std::uint_fast16_t const evtSize,
1144 std::uint_fast16_t const margin,
1145 enum_t const sig) noexcept;
1146#endif // def QF_ISR_API
1147
1148//${QF::QF-dyn::gcFromISR} ...................................................
1149#ifdef QF_ISR_API
1150void gcFromISR(QEvt const * e) noexcept;
1151#endif // def QF_ISR_API
1152
1153} // namespace QF
1154} // namespace QP
1155//$enddecl${QF::QF-dyn} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1156
1157extern "C" {
1158//$declare${QF-extern-C} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1159
1160//${QF-extern-C::QF_onContextSw} .............................................
1161#ifdef QF_ON_CONTEXT_SW
1163 QP::QActive * prev,
1164 QP::QActive * next);
1165#endif // def QF_ON_CONTEXT_SW
1166//$enddecl${QF-extern-C} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1167} // extern "C"
1168
1169//$declare${QF-macros} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1170
1171//${QF-macros::Q_PRIO} .......................................................
1172#define Q_PRIO(prio_, pthre_) \
1173 (static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U))
1174
1175//${QF-macros::Q_NEW} ........................................................
1176#ifndef QEVT_DYN_CTOR
1177#define Q_NEW(evtT_, sig_) (static_cast<evtT_ *>( \
1178 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, (sig_))))
1179#endif // ndef QEVT_DYN_CTOR
1180
1181//${QF-macros::Q_NEW} ........................................................
1182#ifdef QEVT_DYN_CTOR
1183#define Q_NEW(evtT_, sig_, ...) ( static_cast<evtT_ *>( \
1184 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, (sig_)))->ctor(__VA_ARGS__))
1185#endif // def QEVT_DYN_CTOR
1186
1187//${QF-macros::Q_NEW_X} ......................................................
1188#ifndef QEVT_DYN_CTOR
1189#define Q_NEW_X(evtT_, margin_, sig_) (static_cast<evtT_ *>( \
1190 QP::QF::newX_(sizeof(evtT_), (margin_), (sig_))))
1191#endif // ndef QEVT_DYN_CTOR
1192
1193//${QF-macros::Q_NEW_X} ......................................................
1194#ifdef QEVT_DYN_CTOR
1195#define Q_NEW_X(evtT_, margin_, sig_, ...) ( static_cast<evtT_ *>( \
1196 QP::QF::newX_(sizeof(evtT_), (margin_), (sig_)))->ctor(__VA_ARGS__))
1197#endif // def QEVT_DYN_CTOR
1198
1199//${QF-macros::Q_NEW_REF} ....................................................
1200#define Q_NEW_REF(evtRef_, evtT_) \
1201 ((evtRef_) = static_cast<evtT_ const *>(QP::QF::newRef_(e, (evtRef_))))
1202
1203//${QF-macros::Q_DELETE_REF} .................................................
1204#define Q_DELETE_REF(evtRef_) do { \
1205 QP::QF::deleteRef_((evtRef_)); \
1206 (evtRef_) = 0U; \
1207} while (false)
1208
1209//${QF-macros::PUBLISH} ......................................................
1210#ifdef Q_SPY
1211#define PUBLISH(e_, sender_) \
1212 publish_((e_), (sender_), (sender_)->getPrio())
1213#endif // def Q_SPY
1214
1215//${QF-macros::PUBLISH} ......................................................
1216#ifndef Q_SPY
1217#define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U)
1218#endif // ndef Q_SPY
1219
1220//${QF-macros::POST} .........................................................
1221#ifdef Q_SPY
1222#define POST(e_, sender_) post_((e_), QP::QF::NO_MARGIN, (sender_))
1223#endif // def Q_SPY
1224
1225//${QF-macros::POST} .........................................................
1226#ifndef Q_SPY
1227#define POST(e_, dummy) post_((e_), QP::QF::NO_MARGIN, nullptr)
1228#endif // ndef Q_SPY
1229
1230//${QF-macros::POST_X} .......................................................
1231#ifdef Q_SPY
1232#define POST_X(e_, margin_, sender_) \
1233 post_((e_), (margin_), (sender_))
1234#endif // def Q_SPY
1235
1236//${QF-macros::POST_X} .......................................................
1237#ifndef Q_SPY
1238#define POST_X(e_, margin_, dummy) post_((e_), (margin_), nullptr)
1239#endif // ndef Q_SPY
1240
1241//${QF-macros::TICK_X} .......................................................
1242#ifdef Q_SPY
1243#define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_))
1244#endif // def Q_SPY
1245
1246//${QF-macros::TICK_X} .......................................................
1247#ifndef Q_SPY
1248#define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr)
1249#endif // ndef Q_SPY
1250
1251//${QF-macros::TICK} .........................................................
1252#define TICK(sender_) TICK_X(0U, (sender_))
1253
1254//${QF-macros::TRIG} .........................................................
1255#ifdef Q_SPY
1256#define TRIG(sender_) trig_((sender_))
1257#endif // def Q_SPY
1258
1259//${QF-macros::TRIG} .........................................................
1260#ifndef Q_SPY
1261#define TRIG(sender_) trig_(nullptr)
1262#endif // ndef Q_SPY
1263
1264//${QF-macros::QF_CRIT_EXIT_NOP} .............................................
1265#ifndef QF_CRIT_EXIT_NOP
1266#define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
1267#endif // ndef QF_CRIT_EXIT_NOP
1268
1269//${QF-macros::QF_MEM_SYS} ...................................................
1270#ifndef QF_MEM_SYS
1271#define QF_MEM_SYS() (static_cast<void>(0))
1272#endif // ndef QF_MEM_SYS
1273
1274//${QF-macros::QF_MEM_APP} ...................................................
1275#ifndef QF_MEM_APP
1276#define QF_MEM_APP() (static_cast<void>(0))
1277#endif // ndef QF_MEM_APP
1278//$enddecl${QF-macros} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1279
1280#endif // QP_HPP_
Dummy Active Object for testing.
Definition qs.hpp:844
Active object class (based on the QHsm implementation strategy)
Definition qp.hpp:724
QACTIVE_OS_OBJ_TYPE const & getOsObject() const noexcept
Definition qp.hpp:869
void init(void const *const e, std::uint_fast8_t const qsId) override
Definition qp.hpp:781
void setThread(QACTIVE_THREAD_TYPE const &thr)
Definition qp.hpp:881
std::uint8_t m_pthre_dis
Definition qp.hpp:748
std::uint_fast8_t getPThre() const noexcept
Definition qp.hpp:858
QACTIVE_THREAD_TYPE const & getThread() const noexcept
Definition qp.hpp:875
static QSubscrList * subscrList_
Definition qp.hpp:751
void setAttr(std::uint32_t attr1, void const *attr2=nullptr)
static enum_t maxPubSignal_
Definition qp.hpp:752
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Definition qp.hpp:790
static void publishFromISR(QEvt const *e, void *par, void const *sender) noexcept
virtual bool postFromISR(QEvt const *const e, std::uint_fast16_t const margin, void *par, void const *const sender) noexcept
QACTIVE_EQUEUE_TYPE m_eQueue
Definition qp.hpp:738
bool isIn(QStateHandler const state) noexcept override
Definition qp.hpp:796
void init(std::uint_fast8_t const qsId) override
Definition qp.hpp:787
void setPrio(QPrioSpec const prio) noexcept
Definition qp.hpp:854
QActive(QStateHandler const initial) noexcept
Definition qp.hpp:766
void start(QPrioSpec const prioSpec, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize)
Definition qp.hpp:812
static void evtLoop_(QActive *act)
friend void schedLock()
std::uint8_t m_pthre
Definition qp.hpp:727
QStateHandler childState(QStateHandler const parent) noexcept
Definition qp.hpp:799
QACTIVE_EQUEUE_TYPE const & getEQueue() const noexcept
Definition qp.hpp:863
std::uint8_t m_prio_dis
Definition qp.hpp:744
QACTIVE_THREAD_TYPE m_thread
Definition qp.hpp:730
std::uint8_t m_prio
Definition qp.hpp:726
QACTIVE_OS_OBJ_TYPE m_osObject
Definition qp.hpp:734
Abstract State Machine class (state machine interface)
Definition qp.hpp:220
QState qm_tran_init(void const *const tatbl) noexcept
Definition qp.hpp:329
QAsm() noexcept
Definition qp.hpp:266
QStateHandler state() const noexcept
Definition qp.hpp:291
QAsmAttr m_state
Definition qp.hpp:222
virtual void dispatch(QEvt const *const e, std::uint_fast8_t const qsId)=0
QStateRet
Definition qp.hpp:230
@ Q_RET_HANDLED
event handled (internal transition)
Definition qp.hpp:237
@ Q_RET_ENTRY
state entry action executed
Definition qp.hpp:241
@ Q_RET_IGNORED
event silently ignored (bubbled up to top)
Definition qp.hpp:238
@ Q_RET_UNHANDLED
event unhandled due to a guard
Definition qp.hpp:234
@ Q_RET_TRAN
regular transition
Definition qp.hpp:248
@ Q_RET_TRAN_HIST
transition to history of a given state
Definition qp.hpp:253
@ Q_RET_TRAN_XP
exit-point transition out of a submachine
Definition qp.hpp:254
@ Q_RET_SUPER_SUB
event passed to submachine superstate
Definition qp.hpp:233
@ Q_RET_NULL
return value without any effect
Definition qp.hpp:245
@ Q_RET_TRAN_INIT
initial transition in a state or submachine
Definition qp.hpp:249
@ Q_RET_TRAN_EP
entry-point transition into a submachine
Definition qp.hpp:250
@ Q_RET_EXIT
state exit action executed
Definition qp.hpp:242
@ Q_RET_SUPER
event passed to superstate to handle
Definition qp.hpp:232
QState qm_sm_exit(QMState const *const s) noexcept
Definition qp.hpp:381
QState super(QStateHandler const superstate) noexcept
Definition qp.hpp:321
static QState top(void *const me, QEvt const *const e) noexcept
Definition qp.hpp:303
QState qm_super_sub(QMState const *const s) noexcept
Definition qp.hpp:385
virtual bool isIn(QStateHandler const state) noexcept
Definition qp.hpp:287
QState qm_tran_ep(void const *const tatbl) noexcept
Definition qp.hpp:341
QState qm_entry(QMState const *const s) noexcept
Definition qp.hpp:355
QState qm_exit(QMState const *const s) noexcept
Definition qp.hpp:369
QMState const * stateObj() const noexcept
Definition qp.hpp:294
QState qm_tran_hist(QMState const *const hist, void const *const tatbl) noexcept
Definition qp.hpp:333
QState tran(QStateHandler const target) noexcept
Definition qp.hpp:313
QState qm_tran_xp(QActionHandler const xp, void const *const tatbl) noexcept
Definition qp.hpp:345
QState qm_tran(void const *const tatbl) noexcept
Definition qp.hpp:325
ReservedSig
Reserved signals by the QP-framework.
Definition qp.hpp:258
@ Q_EXIT_SIG
signal for exit actions
Definition qp.hpp:261
@ Q_INIT_SIG
signal for nested initial transitions
Definition qp.hpp:262
@ Q_ENTRY_SIG
signal for entry actions
Definition qp.hpp:260
@ Q_EMPTY_SIG
signal to execute the default case
Definition qp.hpp:259
virtual void init(void const *const e, std::uint_fast8_t const qsId)=0
virtual void init(std::uint_fast8_t const qsId)
Definition qp.hpp:281
virtual QStateHandler getStateHandler() noexcept
Definition qp.hpp:299
QAsmAttr m_temp
Definition qp.hpp:223
QState tran_hist(QStateHandler const hist) noexcept
Definition qp.hpp:317
Native QP event queue.
Definition qequeue.hpp:70
Event class.
Definition qp.hpp:139
static constexpr std::uint8_t MARKER
Definition qp.hpp:146
constexpr QEvt(QSignal const s) noexcept
Definition qp.hpp:157
@ DYNAMIC
Definition qp.hpp:149
std::uint8_t evtTag_
Definition qp.hpp:143
std::uint_fast8_t getPoolNum_() const noexcept
Definition qp.hpp:167
QEvt()=delete
QEvt * ctor(DynEvt const dummy) noexcept
Definition qf_dyn.cpp:73
std::uint8_t volatile refCtr_
Definition qp.hpp:142
static bool verify_(QEvt const *const e) noexcept
Definition qp.hpp:163
QSignal sig
Definition qp.hpp:141
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition qp.hpp:392
static constexpr std::int_fast8_t MAX_NEST_DEPTH_
Definition qp.hpp:394
QStateHandler getStateHandler() noexcept override
Definition qp.hpp:413
QStateHandler childState(QStateHandler const parent) noexcept
Definition qep_hsm.cpp:488
void init(std::uint_fast8_t const qsId) override
Definition qp.hpp:403
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Definition qep_hsm.cpp:249
bool isIn(QStateHandler const state) noexcept override
Definition qep_hsm.cpp:452
std::int_fast8_t hsm_tran(QStateHandler(&path)[MAX_NEST_DEPTH_], std::uint_fast8_t const qsId)
Definition qep_hsm.cpp:520
void init(void const *const e, std::uint_fast8_t const qsId) override
Definition qep_hsm.cpp:127
QHsm(QStateHandler const initial) noexcept
Definition qep_hsm.cpp:119
Active object class (based on QMsm implementation strategy)
Definition qp.hpp:910
bool isIn(QStateHandler const state) noexcept override
Definition qp.hpp:930
QStateHandler getStateHandler() noexcept override
Definition qp.hpp:935
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Definition qp.hpp:924
bool isInState(QMState const *const st) const noexcept
Definition qp.hpp:939
void init(void const *const e, std::uint_fast8_t const qsId) override
Definition qp.hpp:915
QMState const * childStateObj(QMState const *const parent) const noexcept
Definition qp.hpp:942
void init(std::uint_fast8_t const qsId) override
Definition qp.hpp:921
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
Definition qp.hpp:425
void exitToTranSource_(QMState const *const cs, QMState const *const ts, std::uint_fast8_t const qsId)
Definition qep_msm.cpp:546
QState enterHistory_(QMState const *const hist, std::uint_fast8_t const qsId)
Definition qep_msm.cpp:591
QStateHandler getStateHandler() noexcept override
Definition qp.hpp:441
bool isIn(QStateHandler const state) noexcept override
Definition qep_msm.cpp:374
QMsm(QStateHandler const initial) noexcept
Definition qep_msm.cpp:98
void init(std::uint_fast8_t const qsId) override
Definition qp.hpp:433
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Definition qep_msm.cpp:167
bool isInState(QMState const *const stateObj) const noexcept
Definition qep_msm.cpp:398
void init(void const *const e, std::uint_fast8_t const qsId) override
Definition qep_msm.cpp:106
QMState const * topQMState() const noexcept
Definition qep_msm.cpp:660
QMState const * childStateObj(QMState const *const parent) const noexcept
Definition qep_msm.cpp:422
QState execTatbl_(QMTranActTable const *const tatbl, std::uint_fast8_t const qsId)
Definition qep_msm.cpp:471
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.hpp:612
bool isEmpty() const noexcept
Definition qp.hpp:623
void update_(QPSet *const dis) const noexcept
Definition qp.hpp:681
bool verify_(QPSet const *const dis) const noexcept
Definition qp.hpp:690
void remove(std::uint_fast8_t const n) noexcept
Definition qp.hpp:658
std::uint_fast8_t findMax() const noexcept
Definition qp.hpp:670
void insert(std::uint_fast8_t const n) noexcept
Definition qp.hpp:646
bool hasElement(std::uint_fast8_t const n) const noexcept
Definition qp.hpp:637
void setEmpty() noexcept
Definition qp.hpp:617
bool notEmpty() const noexcept
Definition qp.hpp:630
Subscriber List (for publish-subscribe)
Definition qp.hpp:702
QPSet m_set_dis
Definition qp.hpp:707
QPSet m_set
Definition qp.hpp:704
"Ticker" Active Object class
Definition qp.hpp:1029
void init(std::uint_fast8_t const qsId) override
Definition qp.hpp:1035
Time Event class.
Definition qp.hpp:955
QTimeEvt * toTimeEvt() noexcept
Definition qp.hpp:1012
QTimeEvtCtr m_interval
Definition qp.hpp:960
QTimeEvt *volatile m_next
Definition qp.hpp:957
QTimeEvtCtr volatile m_ctr
Definition qp.hpp:959
void * m_act
Definition qp.hpp:958
QTimeEvtCtr getInterval() const noexcept
Definition qp.hpp:989
static void tickFromISR(std::uint_fast8_t const tickRate, void *par, void const *sender) noexcept
QTimeEvtCtr getCtr() const noexcept
Definition qp.hpp:986
QActive * toActive() noexcept
Definition qp.hpp:1009
Blocking Mutex of the QXK preemptive kernel.
Definition qxk.hpp:164
Counting Semaphore of the QXK preemptive kernel.
Definition qxk.hpp:142
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.hpp:88
void psInit(QSubscrList *const subscrSto, enum_t const maxSignal) noexcept
Definition qp.hpp:1068
void onStartup()
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qp.hpp:1087
int_t run()
Definition qk.cpp:396
void onCleanup()
void stop()
Definition qk.cpp:390
void gcFromISR(QEvt const *e) noexcept
std::uint_fast16_t poolGetMaxBlockSize() noexcept
Definition qf_dyn.cpp:126
void poolInit(void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept
Definition qf_dyn.cpp:87
std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qp.hpp:1096
constexpr std::uint_fast16_t NO_MARGIN
Definition qp.hpp:1101
QEvt * newXfromISR_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, enum_t const sig) noexcept
void init()
Definition qk.cpp:368
void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
Definition qp.hpp:1077
QP/C++ framework.
Definition qequeue.hpp:50
constexpr enum_t Q_USER_SIG
Definition qp.hpp:217
std::uint32_t QPSetBits
Definition qp.hpp:603
std::uint32_t QTimeEvtCtr
Definition qp.hpp:588
void(*)(QXThread *const me) QXThreadHandler
Definition qp.hpp:186
std::uint_fast8_t QState
Definition qp.hpp:173
std::uint_fast8_t QF_LOG2(QP::QPSetBits x) noexcept
Definition qf_act.cpp:101
std::uint16_t QSignal
Definition qp.hpp:130
std::uint16_t QPrioSpec
Definition qp.hpp:574
QState(*)(void *const me) QActionHandler
Definition qp.hpp:179
QState(*)(void *const me, QEvt const *const e) QStateHandler
Definition qp.hpp:176
constexpr char const versionStr[]
Definition qp.hpp:121
int enum_t
Definition qp.hpp:108
double float64_t
Definition qp.hpp:114
#define QP_VERSION_STR
Definition qp.hpp:48
int int_t
Definition qp.hpp:105
#define Q_STATE_CAST(handler_)
Definition qp.hpp:493
float float32_t
Definition qp.hpp:111
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
#define QF_MAX_TICK_RATE
#define QF_MAX_ACTIVE
#define QACTIVE_OS_OBJ_TYPE
QP::QActive "OS-object" type used in various QP/C++ ports.
Definition qp_port.hpp:29
#define QACTIVE_EQUEUE_TYPE
QP::QActive event queue type used in various QP/C++ ports.
Definition qp_port.hpp:26
#define QACTIVE_THREAD_TYPE
QP::QActive "thread" type used in various QP/C++ ports.
Definition qp_port.hpp:32
State object for the QP::QMsm class (QM State Machine).
Definition qp.hpp:189
QActionHandler const entryAction
Definition qp.hpp:192
QStateHandler const stateHandler
Definition qp.hpp:191
QActionHandler const exitAction
Definition qp.hpp:193
QMState const * superstate
Definition qp.hpp:190
QActionHandler const initAction
Definition qp.hpp:194
Transition-Action Table for the QP::QMsm State Machine.
Definition qp.hpp:198
QMState const * target
Definition qp.hpp:199
QActionHandler const act[1]
Definition qp.hpp:200
Attribute of for the QP::QAsm class (Abstract State Machine).
Definition qp.hpp:204
std::uintptr_t uint
Definition qp.hpp:211
QMState const * obj
Definition qp.hpp:208
QStateHandler fun
Definition qp.hpp:205
QMTranActTable const * tatbl
Definition qp.hpp:209
constexpr QAsmAttr()
Definition qp.hpp:213
QXThreadHandler thr
Definition qp.hpp:207
QActionHandler act
Definition qp.hpp:206