QP/C++  7.0.1
Real-Time Embedded Framework
qf_qmact.cpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Embedded Framework (RTEF)
3// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4//
5// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6//
7// This software is dual-licensed under the terms of the open source GNU
8// General Public License version 3 (or any later version), or alternatively,
9// under the terms of one of the closed source Quantum Leaps commercial
10// licenses.
11//
12// The terms of the open source GNU General Public License version 3
13// can be found at: <www.gnu.org/licenses/gpl-3.0>
14//
15// The terms of the closed source Quantum Leaps commercial licenses
16// can be found at: <www.state-machine.com/licensing>
17//
18// Redistributions in source code must retain this top-level comment block.
19// Plagiarizing this software to sidestep the license obligations is illegal.
20//
21// Contact information:
22// <www.state-machine.com>
23// <info@state-machine.com>
24//============================================================================
30
31#define QP_IMPL // this is QP implementation
32#include "qf_port.hpp" // QF port
33#include "qassert.h" // QP embedded systems-friendly assertions
34
42#define QF_QMACTIVE_TO_QMSM_CAST_(qact_) \
43 reinterpret_cast<QMsm *>((qact_))
44
46#define QF_QMACTIVE_TO_QMSM_CONST_CAST_(qact_) \
47 reinterpret_cast<QMsm const *>((qact_))
48
49// unnamed namespace for local definitions with internal linkage
50namespace {
51
52//Q_DEFINE_THIS_MODULE("qf_qmact")
53
54} // unnamed namespace
55
56namespace QP {
57
58//............................................................................
59QMActive::QMActive(QStateHandler const initial) noexcept
60 : QActive(initial)
61{
62 m_temp.fun = initial;
63}
64
65//............................................................................
66void QMActive::init(void const * const e, std::uint_fast8_t const qs_id) {
68 QF_QMACTIVE_TO_QMSM_CAST_(this)->QMsm::init(e, qs_id);
69}
70//............................................................................
71void QMActive::init(std::uint_fast8_t const qs_id) {
73 QF_QMACTIVE_TO_QMSM_CAST_(this)->QMsm::init(qs_id);
74}
75//............................................................................
76void QMActive::dispatch(QEvt const * const e,
77 std::uint_fast8_t const qs_id)
78{
79 QF_QMACTIVE_TO_QMSM_CAST_(this)->QMsm::dispatch(e, qs_id);
80}
81
82//............................................................................
83bool QMActive::isInState(QMState const * const st) const noexcept {
84 return QF_QMACTIVE_TO_QMSM_CONST_CAST_(this)->QMsm::isInState(st);
85}
86//............................................................................
87QMState const *QMActive::childStateObj(QMState const * const parent)
88 const noexcept
89{
91 ->QMsm::childStateObj(parent);
92}
93
94//............................................................................
95#ifdef Q_SPY
96
98 return QF_QMACTIVE_TO_QMSM_CAST_(this)->QMsm::getStateHandler();
99}
100
101#endif
102
103} // namespace QP
QActive active object (based on QP::QHsm implementation)
Definition: qf.hpp:136
QHsmAttr m_state
current active state (state-variable)
Definition: qep.hpp:250
friend class QMActive
Definition: qep.hpp:451
QStateHandler getStateHandler() noexcept override
Get the current state handler of the QMsm.
Definition: qf_qmact.cpp:97
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) override
Dispatches an event to QHsm.
Definition: qf_qmact.cpp:76
QMState const * childStateObj(QMState const *const parent) const noexcept
Obtain the current active child state of a given parent (read only)
Definition: qf_qmact.cpp:87
void init(void const *const e, std::uint_fast8_t const qs_id) override
executes the top-most initial transition in QP::QHsm
Definition: qf_qmact.cpp:66
bool isInState(QMState const *const st) const noexcept
Tests if a given state is part of the active state configuration.
Definition: qf_qmact.cpp:83
static QMState const msm_top_s
the top state object for the QMsm
Definition: qep.hpp:550
namespace associated with the QP/C++ framework
Definition: exa_native.dox:1
QMState const * obj
pointer to QMState object
Definition: qep.hpp:224
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to state-handler function.
Definition: qep.hpp:208
State object for the QP::QMsm class (QM State Machine).
Definition: qep.hpp:565
Customizable and memory-efficient assertions for embedded systems.
#define QF_QMACTIVE_TO_QMSM_CONST_CAST_(qact_)
Internal macro to cast a QP::QMActive pointer qact_ to QP::QMsm const *.
Definition: qf_qmact.cpp:46
#define QF_QMACTIVE_TO_QMSM_CAST_(qact_)
Internal macro to cast a QP::QMActive pointer qact_ to QP::QMsm*.
Definition: qf_qmact.cpp:42
QEvt base class.
Definition: qep.hpp:191