QP/C++ Real-Time Event Framework 8.1.5
Toggle main menu visibility
Loading...
Searching...
No Matches
qf_act.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
41
namespace
{
42
Q_DEFINE_THIS_MODULE(
"qf_act"
)
43
}
// unnamed namespace
44
45
//----------------------------------------------------------------------------
46
namespace
QP
{
47
48
// QP version string embedded in the binary image
49
static
constexpr
char
versionStr
[24] =
"QP/C++ "
QP_VERSION_STR
;
50
51
//............................................................................
52
char
const
*
version
() noexcept {
53
// public access to versionStr[] so that it won't be eliminated as unused
54
return
&
versionStr
[0];
55
}
56
//............................................................................
57
void
QEvt_refCtr_inc_
(
QEvt
const
*
const
me)
noexcept
{
58
// NOTE: this function must be called *inside* a critical section
59
60
// the event reference count must not exceed the number of AOs
61
// in the system plus each AO possibly holding one event reference
62
Q_REQUIRE_INCRIT
(200, me->refCtr_ < (
QF_MAX_ACTIVE
+
QF_MAX_ACTIVE
));
63
64
QEvt
*
const
mut_me =
const_cast<
QEvt
*
>
(me);
// cast 'const' away
65
++mut_me->
refCtr_
;
66
}
67
//............................................................................
68
void
QEvt_refCtr_dec_
(
QEvt
const
*
const
me)
noexcept
{
69
// NOTE: this function must be called inside a critical section
70
QEvt
*
const
mut_me =
const_cast<
QEvt
*
>
(me);
// cast 'const' away
71
--mut_me->
refCtr_
;
72
}
73
74
//----------------------------------------------------------------------------
75
QAsm::QAsm
() noexcept
// default QAsm ctor
76
:
m_state
(),
77
m_temp
()
78
{}
79
//............................................................................
80
QState
QAsm::top
(
void
*
const
me,
QEvt
const
*
const
e)
noexcept
{
81
Q_UNUSED_PAR
(me);
82
Q_UNUSED_PAR
(e);
83
return
Q_RET_IGNORED
;
// the top state ignores all events
84
}
85
//............................................................................
86
void
QAsm::init
(std::uint_fast8_t
const
qsId) {
87
// this init() overload delegates to the init() without margin parameter
88
this->
init
(
nullptr
, qsId);
89
}
90
91
}
// namespace QP
QP::QAsm::QAsm
QAsm() noexcept
Constructor of the QP::QAsm base class.
Definition
qf_act.cpp:75
QP::QAsm::m_temp
QAsmAttr m_temp
Temporary storage for target/act-table etc.
Definition
qp.hpp:175
QP::QAsm::Q_RET_IGNORED
static constexpr QState Q_RET_IGNORED
Definition
qp.hpp:186
QP::QAsm::init
virtual void init(void const *const e, std::uint_fast8_t const qsId)=0
Virtual function to take the top-most initial transition in the state machine.
QP::QAsm::m_state
QAsmAttr m_state
Current state (pointer to the current state-handler function).
Definition
qp.hpp:174
QP::QAsm::top
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
Definition
qf_act.cpp:80
QP::QEvt
Event class.
Definition
qp.hpp:101
QP::QEvt::refCtr_
std::uint32_t refCtr_
Event reference counter.
Definition
qp.hpp:105
QP
QP/C++ Framework namespace.
Definition
qequeue.hpp:36
QP::version
char const * version() noexcept
Definition
qf_act.cpp:52
QP::QEvt_refCtr_inc_
void QEvt_refCtr_inc_(QEvt const *const me) noexcept
Internal function to increment the refCtr of a const event.
Definition
qf_act.cpp:57
QP::versionStr
static constexpr char versionStr[24]
Definition
qf_act.cpp:49
QP::QState
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition
qp.hpp:139
QP::QEvt_refCtr_dec_
void QEvt_refCtr_dec_(QEvt const *const me) noexcept
Internal function to decrement the refCtr of a const event.
Definition
qf_act.cpp:68
Q_UNUSED_PAR
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
Definition
qp.hpp:89
QP_VERSION_STR
#define QP_VERSION_STR
Version string complying with Software Versioning specification.
Definition
qp.hpp:33
QF_MAX_ACTIVE
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64).
Definition
qp_config.hpp:72
qp_pkg.hpp
QP/C++ Framework in C++ internal (package-scope) interface.
qp_port.hpp
Sample QP/C++ port.
qs_pkg.hpp
QS (QP/Spy software tracing) internal (package-scope) interface.
qs_port.hpp
Sample QS/C++ port.
qsafe.h
QP Functional Safety (FuSa) Subsystem.
Q_REQUIRE_INCRIT
#define Q_REQUIRE_INCRIT(id_, expr_)
Assertion for checking a precondition (in critical section).
Definition
qsafe.h:98
qpcpp
src
qf
qf_act.cpp
©
Quantum Leaps
|
LinkedIn
|
YouTube
|
GitHub
| created with
Spexygen
©
Quantum Leaps
|
LinkedIn
|
YouTube
|
GitHub
| created with
Spexygen