Event class. More...
#include <qp.h>
Public Member Functions | |
| void | QEvt_ctor (QEvt *const me, enum_t const sig) |
| QEvt constructor | |
| QEvt * | QEvt_init (QEvt *const me, uint8_t const dummy) |
| Event without parameters initialization. | |
Public Attributes | |
| uint32_t | sig: 16 |
| Event signal (see Event Signal). | |
Private Member Functions | |
| void | QEvt_refCtr_inc_ (QEvt const *const me) |
| Internal function to increment the refCtr of a const event. | |
| void | QEvt_refCtr_dec_ (QEvt const *const me) |
| Internal function to decrement the refCtr of a const event. | |
| void | QEvt_update_ (QEvt *const me) |
| bool | QEvt_verify_ (QEvt const *const me) |
Private Attributes | |
| uint32_t | poolNum_: 8 |
| Event pool number of this event. | |
| uint32_t | refCtr_: 8 |
| Event reference counter. | |
| uint32_t | filler_ |
| Member of QEvt to make it identical size in QP/C and SafeQP/C. | |
Event class.
Details
Class QEvt represents both immutable and mutable QP events. It can be instantiated directly (concrete class), in which case it represents events without parameters. QP/C Applications can also inherit and extend QEvt to add custom event parameters (see also SDS_QP_QEvt).
Usage
The following example illustrates how to use the QEvt instance directly (event without parameters)
The following example illustrates how to add event parameter(s) by inheriting the QEvt class. Please note that the QEvt member super is defined as the FIRST member of the derived class.
The following examples illustrate recommended ways to instantiate event objects based on the RAII principle (Resource Acquisition Is Initialization). Please see also QEVT_INITIALIZER().
Backward Traceability
Forward Traceability
QEvt constructor
Details
The QEvt constructor initializes the given QEvt instance with the provided signal. The resulting event is NOT dynamic, meaning that it does NOT come from an event pool and the QP/C Framework won't try to recycle the event.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | sig | event signal (typically enumerated) in the numerical range 0..64K |
Example
Forward Traceability
Event without parameters initialization.
Details
The primary purpose of the QEvt initialization is to support dynamic allocation of events without parameters with the macros Q_NEW() or Q_NEW_X().
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | dummy | shall be set to QEVT_DYNAMIC for dynamic events |
Usage
The following example illustrates the use of the QEvt_init() directly (not recommended because not based on RAII):
The following example illustrates the use of the QEvt_init() implicitly (called by the macro Q_NEW()) when the configuration macro QEVT_PAR_INIT is defined:
Backward Traceability
Forward Traceability
|
private |
Internal function to increment the refCtr of a const event.
Details
This function requires "casting `const` away" from the event pointer, which violates MISRA-C:2025 Rule 11.8. This function encapsulates this violation.
Backward Traceability
Forward Traceability
|
private |
Internal function to decrement the refCtr of a const event.
Details
This function requires "casting `const` away" from the event pointer, which violates MISRA-C:2025 Rule 11.8. This function encapsulates this violation.
Backward Traceability
Forward Traceability
|
private |
|
private |
| uint32_t sig |
Event signal (see Event Signal).
Details
The 16-bit sig bitfield stores the event signal, which supports 64K signal space (65,536 unique signals). The lowest 4 signals (values 0..3) are reserved by the QP/C Framework. Application-specific signals must not overlap the reserved signals and must start with an offset (see Q_USER_SIG).
Example
The following code snippet illustrates a typical definition of Application-specific event signals as an enumeration. Please note the use of the Q_USER_SIG offset.
Forward Traceability
|
private |
Event pool number of this event.
Details
The 8-bit poolNum_ bitfield stores the event-pool number. For mutable events, the event-pool number is in the range 1..QF_MAX_EPOOL. For immutable (static) events and for time events (instances QTimeEvt), the event-pool number is 0.
Forward Traceability
|
private |
Event reference counter.
Details
For mutable events (events from event pools), the 8-bit bitfield QEvt::refCtr_ holds the reference count, which must be in the range 0 through (2*QF_MAX_ACTIVE). For immutable (static) events and for time events (instances QTimeEvt), the member QEvt::refCtr_ is not used for reference counting and instead is used as an indicator of the event origin, which is initialized in the macro QEVT_INITIALIZER().
Forward Traceability
|
private |
Member of QEvt to make it identical size in QP/C and SafeQP/C.
Details
The 32-bit filler_ member ensures that the size of QEvt instances is identical between QP/C and SafeQP/C. This avoids any subtle incompatibilities (related to the size of the event instances, including derived events) in allocating dynamic events from event pools.
Forward Traceability