Reference Manual For QP/C++ 8.1.6
Loading...
Searching...
No Matches
qp.hpp File Reference

QP/C++ Framework platform-independent public interface. More...

#include "qp_cfgchk.hpp"

Go to the source code of this file.

Classes

class  QP::QEvt
 Event class. More...
class  QP::QEvtPtr
 The data type to store in the event queue ring-buffer. More...
struct  QP::QMState
 State object for the QP::QMsm class (QM State Machine). More...
struct  QP::QMTranActTable
 Transition-Action Table for the QP::QMsm State Machine . More...
union  QP::QAsmAttr
 Attribute of for the QP::QAsm class (Abstract State Machine). More...
class  QP::QAsm
 Abstract State Machine class (state machine interface). More...
class  QP::QHsm
 Hierarchical State Machine class (QHsm-style state machine implementation strategy). More...
class  QP::QMsm
 Hierarchical State Machine class (QMsm-style state machine implementation strategy). More...
class  QP::QPSet
 Set of Active Objects of up to QF_MAX_ACTIVE elements. More...
class  QP::QSubscrList
 Subscriber List (for publish-subscribe). More...
class  QP::QActive
 Active Object class (based on the QP::QHsm implementation strategy). More...
class  QP::QMActive
 Active object class (based on QMsm implementation strategy). More...
class  QP::QTimeEvt
 Time Event class. More...
class  QP::QTicker
 "Ticker" Active Object class More...

Namespaces

namespace  QP
 QP/C++ Framework namespace .
namespace  QP::QF
 QF Active Object Framework namespace.

Macros

#define QP_VERSION_STR   "8.1.6"
 Version string complying with Software Versioning specification.
#define QP_VERSION   816U
 Version number for internal use (must correspond to QP_VERSION_STR).
#define QP_RELEASE   0x645CB1FFU
 Encrypted current QP version and release date for internal use.
#define Q_UNUSED_PAR(par_)
 Helper macro to mark unused parameters of functions.
#define Q_DIM(array_)
 Helper macro to calculate static dimension of a 1-dim array.
#define Q_UINT2PTR_CAST(type_, uint_)
 Perform cast from unsigned integer uint_ to pointer of type type_.
#define Q_STATE_DECL(state_)
 Declare a state (QHsm-style) in a state machine class.
#define Q_STATE_DEF(subclass_, state_)
 Define a state (QHsm-style) declared with Q_STATE_DECL().
#define Q_EVT_CAST(subclass_)
 Perform downcast of an event onto a subclass of QP::QEvt class_.
#define Q_STATE_CAST(handler_)
 Perform cast to QP::QStateHandler.
#define QM_STATE_DECL(state_)
 Declare a state (QMsm-style) in a state machine class.
#define QM_ACTION_DECL(action_)
 Declare an action (QMsm-style) in a state machine class.
#define QM_STATE_DEF(subclass_, state_)
 Define a state (QMsm-style) declared with QM_STATE_DECL().
#define QM_ACTION_DEF(subclass_, action_)
 Define an action (QMsm-style) declared with QM_ACTION_DECL().
#define INIT(qsId_)
 Call init() of a state machine with the QS-ID only in the Spy build.
#define DISPATCH(e_, qsId_)
 Call dispatch() of a state machine with the QS-ID only in the Spy build.
#define Q_NEW(evtT_, sig_, ...)
 Macro to allocate a dynamic event and asserting successful allocation.
#define Q_NEW_X(evtT_, margin_, sig_, ...)
 Macro to allocate a dynamic event without asserting successful allocation.
#define Q_NEW_REF(evtRef_, evtT_)
 Create a new reference of the current event e.
#define Q_DELETE_REF(evtRef_)
 Delete the event reference.
#define PUBLISH(e_, sender_)
 Publish an event to all subscriber Active Objects.
#define POST(e_, sender_)
 Invoke the direct event posting facility QP::QActive::post_().
#define POST_X(e_, margin_, sender_)
 Invoke the direct event posting facility QActive::postx_() without delivery guarantee.
#define TICK_X(tickRate_, sender_)
 Invoke the system clock tick processing QP::QTimeEvt::tick().
#define TRIG(sender_)
 Asynchronously trigger the QP::QTicker::trig_() AO to perform tick processing.
#define TICK(sender_)
 Invoke the system clock tick processing for tick rate 0.

Typedefs

using int_t = int
 Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
using QP::QSignal = std::uint16_t
 The signal of event QP::QEvt.
using QP::QState = std::uint_fast8_t
 Type returned from state-handler functions .
using QP::QStateHandler = QState (*)(void * const me, QEvt const * const e)
 Pointer to a state-handler function .
using QP::QActionHandler = QState (*)(void * const me)
 Pointer to an action-handler function .
using QP::QXThreadHandler = void (*)(QXThread * const me)
 Pointer to an extended-thread handler function.
using QP::QPrioSpec = std::uint16_t
 Priority specification for Active Objects in QP.
using QP::QTimeEvtCtr = std::uint32_t
 Data type to store the time-event down-counter and interval defined based on the macro QF_TIMEEVT_CTR_SIZE.
using QP::QPSetBits = std::uint32_t
 Bitmask for the internal representation of QPSet elements.

Functions

char const * QP::version () noexcept
 Version string of the Framework embedded in the binary image.
std::uint_fast8_t QP::QF_LOG2 (QP::QPSetBits const bitmask) noexcept
 Generic (portable) integer log-base-2 of a QPSet bitmask.
void QP::QF::QF_INIT_CFGCHK_ ()
 QF initialization with the configuration-specific name (QP configuration check).
void QP::QF::init ()
 QF initialization.
void QP::QF::stop ()
 Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used in some QF ports).
int_t QP::QF::run ()
 Transfers control to QF to run the application.
void QP::QF::onStartup ()
 Startup QF callback.
void QP::QF::onCleanup ()
 Cleanup QF callback.
void QP::QF::psInit (QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
void QP::QF::publish_ (QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
std::uint_fast16_t QP::QF::getQueueMin (std::uint_fast8_t const prio) noexcept
void QP::QF::tick (std::uint_fast8_t const tickRate, void const *const sender) noexcept
QPrioSpec QP::QF::prioSpec (std::uint8_t const prio, std::uint8_t const pthre) noexcept
 Create a QP::QPrioSpec object to specify priority of an AO or a thread.
void QP::QF::poolInit (void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept
 Event pool initialization for dynamic allocation of events.
std::uint16_t QP::QF::poolGetMaxBlockSize () noexcept
 Obtain the block size of any registered event pools.
std::uint16_t QP::QF::getPoolUse (std::uint_fast8_t const poolNum) noexcept
 Obtain the number of used entries of the given event pool or of all event pools.
std::uint16_t QP::QF::getPoolFree (std::uint_fast8_t const poolNum) noexcept
 Obtain the number of free entries of the given event pool.
std::uint16_t QP::QF::getPoolMin (std::uint_fast8_t const poolNum) noexcept
 Obtain the minimum of free entries of the given event pool.
QEvt * QP::QF::newX_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
 Internal QF implementation of creating new mutable (dynamic) event.
void QP::QF::gc (QEvt const *const e) noexcept
 Recycle a mutable (dynamic) event.
QEvt const * QP::QF::newRef_ (QEvt const *const e, QEvt const *const evtRef) noexcept
 Internal QF implementation of creating new event reference.
void QP::QF::deleteRef_ (QEvt const *const evtRef) noexcept
 Internal QF implementation of deleting event reference.
template<class evtT_, typename... Args>
evtT_ * QP::QF::q_new (QSignal const sig, Args... args)
 Function template to allocate a dynamic event and asserting successful allocation.
template<class evtT_, typename... Args>
evtT_ * QP::QF::q_new_x (std::uint_fast16_t const margin, QSignal const sig, Args... args)
 Function template to allocate a dynamic event without asserting successful allocation.
template<class evtT_>
void QP::QF::q_new_ref (QP::QEvt const *const e, evtT_ const *&evtRef)
 Create a new reference of the current event e.
template<class evtT_>
void QP::QF::q_delete_ref (evtT_ const *&evtRef)
 Delete a new reference of the current event e.
QEvt * QP::QF::newXfromISR_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
void QP::QF::gcFromISR (QEvt const *e) noexcept
void QF_onContextSw (QP::QActive *prev, QP::QActive *next)
 QF context switch callback used in built-in kernels.

Variables

constexpr QSignal QP::Q_USER_SIG {4U}
constexpr std::uint_fast16_t QP::QF::NO_MARGIN {0xFFFFU}
 Special value of margin that causes asserting failure in case event allocation or event posting fails.

Detailed Description

QP/C++ Framework platform-independent public interface.

Backward Traceability

  • [SDS_QP_QEP] Design view: QEP Event Processor.
  • [SDS_QP_QF] Design view: QF Active Object Framework.

Definition in file qp.hpp.

Macro Definition Documentation

◆ QP_VERSION_STR

#define QP_VERSION_STR   "8.1.6"

Version string complying with Software Versioning specification.

Details

QP_VERSION_STR is a zero-terminated version string in the form MAJOR.MINOR.PATCH compliant with Software Versioning specification.

Examples

  • 7.3.5-rc.1 — version 7.3.5 release-candidate-1
  • 7.3.5 — version 7.3.5 (final release)

Backward Traceability

  • [SCM_QP_SVER] QP/C++ software component shall apply software versioning conventions.

Definition at line 33 of file qp.hpp.

◆ QP_VERSION

#define QP_VERSION   816U

Version number for internal use (must correspond to QP_VERSION_STR).

Details

QP_VERSION is an unsigned integer constant of the form MAJOR|MINOR|PATCH corresponding to QP_VERSION_STR, with digits merged together. For example QP_VERSION_STR == "7.3.5-rc.1" results in QP_VERSION == 735.

Backward Traceability

  • [SCM_QP_SVER] QP/C++ software component shall apply software versioning conventions.

Definition at line 34 of file qp.hpp.

◆ QP_RELEASE

#define QP_RELEASE   0x645CB1FFU

Encrypted current QP version and release date for internal use.

Details

QP_RELEASE contains information about QP_VERSION (e.g., 735) and release date (e.g., 2023-06-30).

Backward Traceability

  • [SCM_QP_SVER] QP/C++ software component shall apply software versioning conventions.

Definition at line 36 of file qp.hpp.

◆ Q_UNUSED_PAR

#define Q_UNUSED_PAR ( par_)
Value:
(static_cast<void>(par_))

Helper macro to mark unused parameters of functions.

Parameters
par_the unused parameter

Usage

QState QAsm::top(void * const me, QEvt const * const e) noexcept {
Q_UNUSED_PAR(me); // <==
Q_UNUSED_PAR(e); // <==
return Q_RET_IGNORED;
}
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
Definition qp.hpp:84

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qep_hsm] Unit test for qep_hsm module: QHsm-based state machine implementation.
  • [TUN_QP_qep_msm] Unit test for qep_msm module: QMsm-based state machine implementation.
  • [TUN_QP_qf_act] Unit test for qf_act: QEvt creation, management, integrity checking.
  • [TUN_QP_qf_actq8] Unit test for qf_actq: QActive native event queue implementation based on QP::QEQueue (8-bit queue counters).
  • [TUN_QP_qf_dyn] Unit test for qf_dyn: QF dynamic (mutable) event management.
  • [TUN_QP_qf_mem] Unit test for qf_mem: fixed-size memory pools.
  • [TUN_QP_qf_ps] Unit test for qf_ps: QActive publish-subscribe event delivery
  • [TUN_QP_qf_qeq8] Unit test for qf_qeq: QEQueue native thread-safe event queue (8-bit queue counters)
  • [TUN_QP_qf_time16] Unit test for qf_time: QTimeEvt class implementation (16-bit time-event counters)
  • [TUN_QP_qk] Unit test for qk: Preemptive QK kernel implementation
  • [TUN_QP_qv] Unit test for qv: Non-preemptive QV kernel implementation

Definition at line 84 of file qp.hpp.

◆ Q_DIM

#define Q_DIM ( array_)
Value:
(sizeof(array_) / sizeof((array_)[0U]))

Helper macro to calculate static dimension of a 1-dim array.

Parameters
array_1-dimensional array
Return values
dimDimension (length) of the array, i.e., number of elements it can hold

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_time16] Unit test for qf_time: QTimeEvt class implementation (16-bit time-event counters)
  • [TUN_QP_qk] Unit test for qk: Preemptive QK kernel implementation
  • [TUN_QP_qv] Unit test for qv: Non-preemptive QV kernel implementation

Definition at line 85 of file qp.hpp.

◆ Q_UINT2PTR_CAST

#define Q_UINT2PTR_CAST ( type_,
uint_ )
Value:
(reinterpret_cast<type_ *>(uint_))

Perform cast from unsigned integer uint_ to pointer of type type_.

Details

This macro encapsulates the cast to (type_ *), which QP ports or applications might use to access embedded hardware registers. This macro also helps to encapsulate the MISRA deviations listed in the "Forward Traceability" section.

Parameters
type_the pointer type to cast the integer onto
uint_the integer value

Usage

// trigger the ARM Cortex-M PendSV exception
*Q_UINT2PTR_CAST(uint32_t, 0xE000ED04U) = (1U << 28U);
#define Q_UINT2PTR_CAST(type_, uint_)
Perform cast from unsigned integer uint_ to pointer of type type_.
Definition qp.hpp:86

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TIN_QP_qk] Integration test suite for the preemptive QK kernel.

Definition at line 86 of file qp.hpp.

◆ Q_STATE_DECL

#define Q_STATE_DECL ( state_)
Value:
QP::QState state_ ## _h(QP::QEvt const * const e); \
static QP::QState state_(void * const me, QP::QEvt const * const e)
Event class.
Definition qp.hpp:96
std::uint_fast8_t QState
Type returned from state-handler functions \clearpage .
Definition qp.hpp:132

Declare a state (QHsm-style) in a state machine class.

Details

Declares the static state-handler state_ (the function used by the Framework) and the member function state_ ## _h (which implements the state). Used inside the declaration of a QP::QHsm or QP::QActive subclass.

Parameters
state_name of the state

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_hsm] Unit test for qep_hsm module: QHsm-based state machine implementation.

Definition at line 361 of file qp.hpp.

◆ Q_STATE_DEF

#define Q_STATE_DEF ( subclass_,
state_ )
Value:
QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \
return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)

Define a state (QHsm-style) declared with Q_STATE_DECL().

Details

Defines the static state-handler state_, which delegates to the member function state_ ## _h, and starts the definition of state_ ## _h. The macro is followed by the body of the state-handler.

Parameters
subclass_state machine class
state_name of the state

Forward Traceability

  • [MISRA_QP_DVP_MP2_R4_1_3] MISRA-C++:2023 Rule 4.1.3(Required): There shall be no occurrence of undefined or critical unspecified behaviour (multiple use of stringize/pasting operators in definition of macro)
  • [MISRA_QP_DVP_MP2_R8_2_6] MISRA-C++:2023 Rule 8.2.6(Required): An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type (cast from pointer to void in the state-handler macros)
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_hsm] Unit test for qep_hsm module: QHsm-based state machine implementation.

Definition at line 365 of file qp.hpp.

◆ Q_EVT_CAST

#define Q_EVT_CAST ( subclass_)
Value:
(static_cast<subclass_ const *>(e))

Perform downcast of an event onto a subclass of QP::QEvt class_.

Details

This macro encapsulates the downcast of QP::QEvt pointers, which violates MISRA-C:2025 Rule 11.3(R). This macro helps to localize this deviation.

Parameters
subclass_a subclass of QP::QEvt
Note
The macro performs down-cast from the event pointer e.

Usage

Q_STATE_DEF(Table, serving) {
QP::QState status_;
switch (e->sig) {
. . .
case HUNGRY_SIG: {
std::uint8_t n = Q_EVT_CAST(TableEvt)->philoId; // <===
. . .
break;
}
. . .
}
return status_;
}
#define Q_EVT_CAST(subclass_)
Perform downcast of an event onto a subclass of QP::QEvt class_.
Definition qp.hpp:370
#define Q_STATE_DEF(subclass_, state_)
Define a state (QHsm-style) declared with Q_STATE_DECL().
Definition qp.hpp:365

Forward Traceability

  • [MISRA_QP_DVR_MP2_R8_2_6] MISRA-C++:2023 Rule 8.2.6(Required): An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TIN_QP_ao] Integration test suite for Active Objects and direct event posting.
  • [TIN_QP_evt] Integration test suite for events and event memory management.
  • [TIN_QP_ps] Integration test suite for publish-subscribe event delivery.
  • [TIN_QP_defer] Integration test suite for event deferral.
  • [TIN_QP_time] Integration test suite for Time Events.
  • [TIN_QP_sm] Integration test suite for state machines of Active Objects.
  • [TIN_QP_qk] Integration test suite for the preemptive QK kernel.
  • [TIN_QP_qv] Integration test suite for the non-preemptive QV kernel.

Definition at line 370 of file qp.hpp.

◆ Q_STATE_CAST

#define Q_STATE_CAST ( handler_)
Value:
(reinterpret_cast<QP::QStateHandler>(handler_))
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function \clearpage .
Definition qp.hpp:136

Perform cast to QP::QStateHandler.

Details

This macro encapsulates the cast of a specific state handler function pointer to QP::QStateHandler, which violates MISRA:C++2023 Rule 8.2.4 and Rule 8.2.5. This macro helps to localize these deviations.

Parameters
handler_state handler (function pointer)

Usage

Philo::Philo()
: QActive(Q_STATE_CAST(&initial)), // <===
m_timeEvt(this, TIMEOUT_SIG, 0U),
m_id(0xFFU)
{}
#define Q_STATE_CAST(handler_)
Perform cast to QP::QStateHandler.
Definition qp.hpp:371

Forward Traceability

  • [MISRA_QP_DVP_MP2_R8_2_4] MISRA-C++:2023 Rule 8.2.4(Required): Casts shall not be performed between a pointer to function and any other type
  • [MISRA_QP_DVP_MP2_R8_2_5] MISRA-C++:2023 Rule 8.2.5(Required): reinterpret_cast shall not be used (reinterpret_cast used to convert to 'QP::QStateHandler')
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qep_hsm] Unit test for qep_hsm module: QHsm-based state machine implementation.

Definition at line 371 of file qp.hpp.

◆ QM_STATE_DECL

#define QM_STATE_DECL ( state_)
Value:
QP::QState state_ ## _h(QP::QEvt const * const e); \
static QP::QState state_(void * const me, QP::QEvt const * const e); \
static QP::QMState const state_ ## _s
State object for the QP::QMsm class (QM State Machine).
Definition qp.hpp:140

Declare a state (QMsm-style) in a state machine class.

Details

Declares the static state-handler state_, the member function state_ ## _h (which implements the state), and the static state object state_ ## _s (QP::QMState). Used in the QM-generated declaration of a QP::QMsm or QP::QMActive subclass.

Parameters
state_name of the state

Forward Traceability

  • [MISRA_QP_DVP_MP2_R4_1_3] MISRA-C++:2023 Rule 4.1.3(Required): There shall be no occurrence of undefined or critical unspecified behaviour (multiple use of stringize/pasting operators in definition of macro)
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_msm] Unit test for qep_msm module: QMsm-based state machine implementation.

Definition at line 373 of file qp.hpp.

◆ QM_ACTION_DECL

#define QM_ACTION_DECL ( action_)
Value:
QP::QState action_ ## _h(); \
static QP::QState action_(void * const me)

Declare an action (QMsm-style) in a state machine class.

Details

Declares the static action function action_ (the function used by the Framework) and the member function action_ ## _h (which implements the action). Used in the QM-generated declaration of a QP::QMsm or QP::QMActive subclass.

Parameters
action_name of the action

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_msm] Unit test for qep_msm module: QMsm-based state machine implementation.

Definition at line 378 of file qp.hpp.

◆ QM_STATE_DEF

#define QM_STATE_DEF ( subclass_,
state_ )
Value:
QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)

Define a state (QMsm-style) declared with QM_STATE_DECL().

Details

Defines the static state-handler state_, which delegates to the member function state_ ## _h, and starts the definition of state_ ## _h. The macro is followed by the body of the state-handler.

Parameters
subclass_state machine class
state_name of the state

Forward Traceability

  • [MISRA_QP_DVP_MP2_R4_1_3] MISRA-C++:2023 Rule 4.1.3(Required): There shall be no occurrence of undefined or critical unspecified behaviour (multiple use of stringize/pasting operators in definition of macro)
  • [MISRA_QP_DVP_MP2_R8_2_6] MISRA-C++:2023 Rule 8.2.6(Required): An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type (cast from pointer to void in the state-handler macros)
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_msm] Unit test for qep_msm module: QMsm-based state machine implementation.

Definition at line 382 of file qp.hpp.

◆ QM_ACTION_DEF

#define QM_ACTION_DEF ( subclass_,
action_ )
Value:
QP::QState subclass_::action_(void * const me) { \
return static_cast<subclass_ *>(me)->action_ ## _h(); } \
QP::QState subclass_::action_ ## _h()

Define an action (QMsm-style) declared with QM_ACTION_DECL().

Details

Defines the static action function action_, which delegates to the member function action_ ## _h, and starts the definition of action_ ## _h. The macro is followed by the body of the action.

Parameters
subclass_state machine class
action_name of the action

Forward Traceability

  • [MISRA_QP_DVP_MP2_R4_1_3] MISRA-C++:2023 Rule 4.1.3(Required): There shall be no occurrence of undefined or critical unspecified behaviour (multiple use of stringize/pasting operators in definition of macro)
  • [MISRA_QP_DVP_MP2_R8_2_6] MISRA-C++:2023 Rule 8.2.6(Required): An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type (cast from pointer to void in the state-handler macros)
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [MISRA_QP_DVR_MP2_R19_3_1] MISRA-C++:2023 Rule 19.3.1(Advisory): The # and ## preprocessor operators should not be used
  • [TUN_QP_qep_msm] Unit test for qep_msm module: QMsm-based state machine implementation.

Definition at line 387 of file qp.hpp.

◆ INIT

#define INIT ( qsId_)
Value:
init((qsId_))

Call init() of a state machine with the QS-ID only in the Spy build.

Details

When Q_SPY is defined, the macro expands to init(qsId_). Otherwise, it expands to init(0U), so the QS-ID argument does not need to exist in non-Spy builds.

Parameters
qsId_QS-ID (used only when Q_SPY is defined)

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 393 of file qp.hpp.

◆ DISPATCH

#define DISPATCH ( e_,
qsId_ )
Value:
dispatch((e_), (qsId_))

Call dispatch() of a state machine with the QS-ID only in the Spy build.

Details

When Q_SPY is defined, the macro expands to dispatch(e_, qsId_). Otherwise, it expands to dispatch(e_, 0U), so the QS-ID argument does not need to exist in non-Spy builds.

Parameters
e_pointer to the event to dispatch
qsId_QS-ID (used only when Q_SPY is defined)

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_act] Unit test for qf_act: QEvt creation, management, integrity checking.

Definition at line 394 of file qp.hpp.

◆ Q_NEW

#define Q_NEW ( evtT_,
sig_,
... )
Value:
(QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
evtT_ * q_new(QSignal const sig, Args... args)
Function template to allocate a dynamic event and asserting successful allocation.
Definition qp.hpp:847

Macro to allocate a dynamic event and asserting successful allocation.

Details

This deprecated macro is equivalent to invoking the function template QP::QF::q_new<evtT_>(sig_, ...).

Deprecated

See also

Parameters
[in]evtT_event type (class name) of the event to allocate
[in]sig_signal to assign to the newly allocated event
Return values
pointerA valid event pointer of the type evtT_*.

Backward Traceability

  • [SRS_QP_REQ_370] QP/C++ Framework shall provide a method of allocating mutable events at runtime.
  • [SRS_QP_REQ_334] Mutable event allocation shall be reliable. This requirement also means that the QP/C++ Application is responsible for adequately sizing all event pools.

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_dyn] Unit test for qf_dyn: QF dynamic (mutable) event management.
  • [TUN_QP_qf_dyn_raii] Unit test for qf_dyn with QEVT_PAR_INIT: initialization of mutable events at allocation (RAII).
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 917 of file qp.hpp.

◆ Q_NEW_X

#define Q_NEW_X ( evtT_,
margin_,
sig_,
... )
Value:
(QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
Function template to allocate a dynamic event without asserting successful allocation.
Definition qp.hpp:859

Macro to allocate a dynamic event without asserting successful allocation.

Details

This deprecated macro is equivalent to invoking the function template QP::QF::q_new_x<evtT_>(margin_, sig_, ...).

Deprecated

See also

Parameters
[in]evtT_event type (class name) of the event to allocate
[in]margin_number of events that must remain available in the given pool after this allocation. The special value ::QF_NO_MARGIN causes asserting failure in case event allocation fails.
[in]sig_signal to assign to the newly allocated event
Return values
pointerAn event pointer of the type evtT_*
`nullptr`if the event cannot be allocated with the specified margin_ of events still left in the event pool.

Backward Traceability

  • [SRS_QP_REQ_335] QP/C++ Framework may provide alternative unreliable method of allocating mutable events.

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_dyn] Unit test for qf_dyn: QF dynamic (mutable) event management.
  • [TUN_QP_qf_dyn_raii] Unit test for qf_dyn with QEVT_PAR_INIT: initialization of mutable events at allocation (RAII).
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 919 of file qp.hpp.

◆ Q_NEW_REF

#define Q_NEW_REF ( evtRef_,
evtT_ )
Value:
(QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
Definition qp.hpp:878

Create a new reference of the current event e.

Details

This deprecated macro is equivalent to invoking the function template QP::QF::q_new_ref<evtT_>(e, evtRef).

Deprecated

See also

Parameters
[in,out]evtRef_event reference to create
[in]evtT_event type (class name) of the event reference

Forward Traceability

  • [SSM_QP_ASR_413] Application-level state machines must not internally poll or block for events.
  • [SSM_QP_ASR_417] Application-level state machines must not use the current event after the dispatch.
  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_dyn] Unit test for qf_dyn: QF dynamic (mutable) event management.
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 923 of file qp.hpp.

◆ Q_DELETE_REF

#define Q_DELETE_REF ( evtRef_)
Value:
do { \
QP::QF::deleteRef_((evtRef_)); \
(evtRef_) = nullptr; \
} while (false)

Delete the event reference.

Details

This deprecated macro is equivalent to invoking the function template QP::QF::q_delete_ref(evtRef).

Deprecated

See also

Parameters
[in,out]evtRef_event reference to delete

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_dyn] Unit test for qf_dyn: QF dynamic (mutable) event management.
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 924 of file qp.hpp.

◆ PUBLISH

#define PUBLISH ( e_,
sender_ )
Value:
publish_((e_), (sender_), (sender_)->getPrio())

Publish an event to all subscriber Active Objects.

Details

If Q_SPY is defined, this macro calls QP::QActive::publish_() with the sender_ parameter to identify the publisher of the event. Otherwise, sender_ is not used.

Parameters
[in]e_pointer to the posted event
[in]sender_pointer to the sender object (actually used only when Q_SPY is defined)
Note
The pointer to the sender_ object is not necessarily a pointer to an active object. In fact, if QACTIVE_PUBLISH() is called from an interrupt or other context, you can create a unique object just to unambiguously identify the sender of the event.

Backward Traceability

  • [SRS_QP_REQ_320] QP/C++ Framework shall provide publish-subscribe event delivery mechanism

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_ps] Unit test for qf_ps: QActive publish-subscribe event delivery

Definition at line 930 of file qp.hpp.

◆ POST

#define POST ( e_,
sender_ )
Value:
post_((e_), (sender_))

Invoke the direct event posting facility QP::QActive::post_().

Details

This macro asserts if the queue overflows and cannot accept the event.

Parameters
[in]e_pointer to the event to post
[in]sender_pointer to the sender object.
Note
The sender_ parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, this macro does not use the sender_ parameter, so it does not need to be defined.

See also

Backward Traceability

  • [SRS_QP_REQ_300] QP/C++ Framework shall provide direct event posting to Active Object instances based on the FIFO policy.
  • [SRS_QP_REQ_310] QP/C++ Framework shall provide event delivery guarantee for the direct event posting mechanism.

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_actq8] Unit test for qf_actq: QActive native event queue implementation based on QP::QEQueue (8-bit queue counters).

Definition at line 932 of file qp.hpp.

◆ POST_X

#define POST_X ( e_,
margin_,
sender_ )
Value:
postx_((e_), (margin_), (sender_))

Invoke the direct event posting facility QActive::postx_() without delivery guarantee.

Details

This macro does not assert if the queue overflows and cannot accept the event with the specified margin of free slots remaining.

Parameters
[in]e_pointer to the event to post
[in]margin_the minimum free slots in the queue, which must still be available after posting the event. The special value QF::NO_MARGIN causes asserting failure in case event posting fails.
[in]sender_pointer to the sender object.
Return values
trueIf the posting succeeded
falseIf the posting failed due to insufficient margin of free entries available in the queue.
Note
The sender_ parameter is actually only used when QS tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, the POST_X() macro does not pass the sender_ parameter, so the overhead of passing this extra parameter is entirely avoided.
The pointer to the sender object is not necessarily a pointer to an active object. In fact, if POST_X() is called from an interrupt or other context, you can create a unique object just to unambiguously identify the sender of the event.

Backward Traceability

  • [SRS_QP_REQ_331] QP/C++ Framework may provide alternative best-effort event posting mechanism without event delivery guarantee

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TUN_QP_qf_actq8] Unit test for qf_actq: QActive native event queue implementation based on QP::QEQueue (8-bit queue counters).

Definition at line 933 of file qp.hpp.

◆ TICK_X

#define TICK_X ( tickRate_,
sender_ )
Value:
tick((tickRate_), (sender_))

Invoke the system clock tick processing QP::QTimeEvt::tick().

Details

This macro is the recommended way of invoking clock tick processing, because it provides the vital information for software tracing and avoids any overhead when the tracing is disabled.

Parameters
[in]tickRate_clock tick rate to be serviced through this call
[in]sender_pointer to the sender object. This parameter is only used when QS software tracing is enabled (macro Q_SPY is defined)
Note
The sender_ parameter is only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, the sender_ parameter is unused and does not even need to be specified in the program.

Backward Traceability

  • [SRS_QP_REQ_411] QP/C++ Framework shall provide clock-tick processing operations for all supported clock rates that QP/C++ Application must call periodically to service the armed Time Events.

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TIN_QP_time] Integration test suite for Time Events.

Definition at line 935 of file qp.hpp.

◆ TRIG

#define TRIG ( sender_)
Value:
trig_((sender_))

Asynchronously trigger the QP::QTicker::trig_() AO to perform tick processing.

Details

This macro is the recommended way to trigger clock tick processing, because it provides the vital information for software tracing and avoids any overhead when the tracing is disabled.

Parameters
[in]sender_pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined)
Note
When QS software tracing is disabled, the macro calls QTicker_trig_() without the sender parameter, so the overhead of passing this extra parameter is entirely avoided.
The pointer to the sender object is not necessarily a pointer to an active object. In fact, when QTICKER_TRIG() is called from an interrupt, you would create a unique object just to unambiguously identify the ISR as the sender of the time events.

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [TIN_QP_time] Integration test suite for Time Events.

Definition at line 936 of file qp.hpp.

◆ TICK

#define TICK ( sender_)
Value:
TICK_X(0U, (sender_))
#define TICK_X(tickRate_, sender_)
Invoke the system clock tick processing QP::QTimeEvt::tick().
Definition qp.hpp:935

Invoke the system clock tick processing for tick rate 0.

Parameters
[in]sender_pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined)

See also

Forward Traceability

  • [MISRA_QP_DVR_MP2_R19_0_2] MISRA-C++:2023 Rule 19.0.2(Required): Function-like macros shall not be defined
  • [STP_QP_NOTEST_CODE] Code elements verified other than by a direct test trace.

Definition at line 945 of file qp.hpp.

Typedef Documentation

◆ int_t

using int_t = int

Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().

Forward Traceability

  • [MISRA_QP_DVR_PCLP_9141] global declaration of symbol

Definition at line 82 of file qp.hpp.

Function Documentation

◆ QF_onContextSw()

void QF_onContextSw ( QP::QActive * prev,
QP::QActive * next )

QF context switch callback used in built-in kernels.

Details

This callback function provides a mechanism to perform additional custom operations when one of the built-in kernels switches context from one thread to another.

Parameters
[in]prevpointer to the previous thread (active object) (prev==0 means that prev was the idle loop)
[in]nextpointer to the next thread (active object) (next==0) means that next is the idle loop)
Attention
QF_onContextSw() uses "C" linkage (extern "C") and is invoked with interrupts disabled and must also return with interrupts disabled.

Usage

This callback is enabled by defining the macro #QF_ON_CONTEXT_SW.

#ifdef QF_ON_CONTEXT_SW
extern "C" {
// NOTE: the context-switch callback is called with interrupts DISABLED
void QF_onContextSw(QActive *prev, QActive *next) {
if (next != nullptr) {
MPU->CTRL = 0U; // disable the MPU
MPU_Region const * const region = (MPU_Region const *)next->thread;
MPU->RBAR = region[0].RBAR;
MPU->RASR = region[0].RASR;
MPU->RBAR = region[1].RBAR;
MPU->RASR = region[1].RASR;
MPU->RBAR = region[2].RBAR;
MPU->RASR = region[2].RASR;
MPU->CTRL = MPU_CTRL_ENABLE_Msk // enable the MPU
| MPU_CTRL_PRIVDEFENA_Msk; // enable background region
__ISB();
__DSB();
}
}
} // extern "C"
#endif // QF_ON_CONTEXT_SW
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
QF context switch callback used in built-in kernels.

Backward Traceability

  • [SSRS_QP_SREQ_112] QP/C++ software component should support dynamic memory isolation between Active Objects.
  • [SAS_QP_FFI_03] Architectural view: Memory isolation programming model.
  • [SDS_QP_CB_MEM] Design view: Memory-isolation callbacks.

Forward Traceability

  • [TUN_QP_qk] Unit test for qk: Preemptive QK kernel implementation
  • [TUN_QP_qv] Unit test for qv: Non-preemptive QV kernel implementation
  • [TIN_QP_qk] Integration test suite for the preemptive QK kernel.
  • [TIN_QP_qv] Integration test suite for the non-preemptive QV kernel.