QP/C++ 8.1.1
Real-Time Event Framework
Loading...
Searching...
No Matches
qf_qmact.cpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
20// The GPL does NOT permit the incorporation of this code into proprietary
21// programs. Please contact Quantum Leaps for commercial licensing options,
22// which expressly supersede the GPL and are designed explicitly for
23// closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#define QP_IMPL // this is QP implementation
30#include "qp_port.hpp" // QP port
31#include "qp_pkg.hpp" // QP package-scope interface
32#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
33#ifdef Q_SPY // QS software tracing enabled?
34 #include "qs_port.hpp" // QS port
35 #include "qs_pkg.hpp" // QS facilities for pre-defined trace records
36#else
37 #include "qs_dummy.hpp" // disable the QS software tracing
38#endif // Q_SPY
39
40// unnamed namespace for local definitions with internal linkage
41namespace {
42//Q_DEFINE_THIS_MODULE("qf_qmact")
43} // unnamed namespace
44
45namespace QP {
46
47//............................................................................
48QMActive::QMActive(QStateHandler const initial) noexcept
49 : QActive(initial)
50{
51 // NOTE: QMActive indirectly inherits the abstract QAsm base class,
52 // but it will delegate the state machine behavior to the QMsm class,
53 // so the following initialization is identical as in QMsm ctor:
55 m_temp.fun = initial;
56}
57//............................................................................
59 void const * const e,
60 std::uint_fast8_t const qsId)
61{
62 // delegate to the QMsm class
63 reinterpret_cast<QMsm *>(this)->QMsm::init(e, qsId);
64}
65//............................................................................
67 QEvt const * const e,
68 std::uint_fast8_t const qsId)
69{
70 // delegate to the QMsm class
71 reinterpret_cast<QMsm *>(this)->QMsm::dispatch(e, qsId);
72}
73//............................................................................
74bool QMActive::isIn(QStateHandler const stateHndl) noexcept {
75 // delegate to the QMsm class
76 return reinterpret_cast<QMsm *>(this)->QMsm::isIn(stateHndl);
77}
78//............................................................................
79QMState const * QMActive::childStateObj(QMState const * const parent) const noexcept {
80 // delegate to the QMsm class
81 return reinterpret_cast<QMsm const *>(this)
82 ->QMsm::childStateObj(parent);
83}
84//............................................................................
86 // delegate to the QMsm class
87 return reinterpret_cast<QMsm const *>(this)->QMsm::getStateHandler();
88}
89
90} // namespace QP
friend void QF::init()
QActive(QStateHandler const initial) noexcept
QActive constructor (abstract base class).
Definition qf_qact.cpp:55
friend class QMActive
Definition qp.hpp:624
QAsmAttr m_temp
Temporary storage for target/act-table etc.
Definition qp.hpp:170
QAsmAttr m_state
Current state (pointer to the current state-handler function).
Definition qp.hpp:169
Event class.
Definition qp.hpp:101
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
Definition qf_qmact.cpp:85
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
Definition qf_qmact.cpp:74
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
Definition qf_qmact.cpp:66
QMState const * childStateObj(QMState const *const parent) const noexcept
Definition qf_qmact.cpp:79
Hierarchical State Machine class (QMsm-style state machine implementation strategy).
Definition qp.hpp:335
QMState const * childStateObj(QMState const *const parentHndl) const noexcept
Obtain the current active child state of a given parent in QP::QMsm.
static QMState const * topQMState() noexcept
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
void init(void const *const e, std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine.
bool isIn(QStateHandler const stateHndl) noexcept override
Tests if a given state is part of the current active state configuration.
QStateHandler getStateHandler() const noexcept override
Obtain the current active state from a MSM (read only).
QP/C++ Framework namespace.
Definition qequeue.hpp:36
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:138
QP Framework in C++ internal (package-scope) interface
Sample QP/C++ port.
QS (QP/Spy software tracing) internal (package-scope) interface.
Sample QS/C++ port.
QP Functional Safety (FuSa) Subsystem.
State object for the QP::QMsm class (QM State Machine).
Definition qp.hpp:142