Event class.
More...
#include "qp.h"
|
uint8_t | poolNum_ |
| Event pool number of this event.
|
|
uint8_t volatile | refCtr_ |
| Event reference counter.
|
|
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 QP::QEvt to add custom event parameters (see also SDS_QP_QEvt).
- Attention
- Event parameters must be included in the event instance directly (as opposed to being referenced by pointers or references). Therefore, the QEvt sublcasses are restricted to have both "standard layout" and be "trivially copyable". In QP/C this means that QEvt sublcasses should:
- contain NO pointers (including NO virtual pointer); The only exception is passing an opaque pointer to Active Object intended as the recipient of future events.
- contain NO virtual functions (consequence of no virtual pointer);
- contain NO access specifiers (protected, and private);
- contain NO non-trivial copy or move constructor;
- contain NO non-trivial copy or move assignment operator;
- Backward Traceability
-
- Forward Traceability
-
- Usage
- 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: typedef struct {
uint8_t keyId;
} KeypressEvt;
The following examples illustrate recommended ways to instantiate event objects based on the RAII principle (Resource Acquisition Is Initialization). Please see also QEVT_INITIALIZER().
static KeypressEvt const keyEvt = {
.keyId = 12U
}
KeypressEvt keyEvt = {
.keyId = keyId
};
#define QEVT_INITIALIZER(sig_)
Initializer for immutable (constant) QEvt instances.
QSignal sig
Signal of the event (see Event Signal)
- Note
- Please see macros Q_NEW() or Q_NEW_X() for code examples of allocating dynamic mutable events.
Definition at line 112 of file qp.h.
◆ QEvt_ctor()
static void QEvt_ctor |
( |
QEvt *const | me, |
|
|
enum_t const | sig ) |
|
inlinestatic |
Definition at line 120 of file qp.h.
◆ QEvt_init()
static QEvt * QEvt_init |
( |
QEvt *const | me, |
|
|
uint8_t const | dummy ) |
|
inlinestatic |
Event without parameters initialization.
- Details
- The main purpose of the QEvt initialization is to support dynamic allocation of events without parameters with the macros Q_NEW() or Q_NEW_X().
- Parameters
-
[in,out] | me | current instance pointer (see SAS_QP_OO) |
[in] | dummy | shall be set to QEVT_DYNAMIC for dynamic events |
- Returns
- Pointer to the initialized event (the
me
pointer, see SAS_QP_OO).
- Backward Traceability
- SRS_QP_EVT_40: QP Framework may be compile-time configurable to allow customized constructor and other custom operations on event instances
- QEvt: Event class
- Usage
- The following example illustrates the use of the QEvt_init() directly (not recommended because not based on RAII):
KeypressEvt keypressEvt;
keypressEvt.keyId = 23U;
static QEvt * QEvt_init(QEvt *const me, uint8_t const dummy)
Event without parameters initialization.
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:
#define Q_NEW(evtT_, sig_,...)
Allocate a mutable (dynamic) event.
#define QEVT_DYNAMIC
dummy parameter for dynamic event initialization (see QEvt::QEvt_init())
Definition at line 129 of file qp.h.
◆ QEvt_refCtr_inc_()
static void QEvt_refCtr_inc_ |
( |
QEvt const *const | me | ) |
|
|
inlinestaticprivate |
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:2023 Rule 11.8. This function encapsulates this violation.
- Backward Traceability
-
Definition at line 60 of file qp_pkg.h.
◆ QEvt_refCtr_dec_()
static void QEvt_refCtr_dec_ |
( |
QEvt const *const | me | ) |
|
|
inlinestaticprivate |
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:2023 Rule 11.8. This function encapsulates this violation.
- Backward Traceability
-
Definition at line 67 of file qp_pkg.h.
◆ sig
Signal of the event (see Event Signal)
- Backward Traceability
-
Definition at line 113 of file qp.h.
◆ poolNum_
Event pool number of this event.
- Details
- The 8-bit
poolNum_
member 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.
- Backward Traceability
- QEvt: Event class
- SRS_QP_EVT_31: Event abstraction may contain other data items for internal event management inside QP Framework
- SRS_QP_EVT_30: QP Framework shall allow Application to create event instances with Parameters defined by the Application
Definition at line 114 of file qp.h.
◆ refCtr_
Event reference counter.
- Details
- For mutable events (events from event pools), the 8-bit member QEvt::refCtr_ holds the reference count, which must be in the rage 0..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().
- Backward Traceability
- QEvt: Event class
- SRS_QP_EVT_31: Event abstraction may contain other data items for internal event management inside QP Framework
- SRS_QP_EVT_30: QP Framework shall allow Application to create event instances with Parameters defined by the Application
Definition at line 115 of file qp.h.
The documentation for this class was generated from the following files: