Event class. More...
#include "qp.h"
Static Public Member Functions | |
static void | QEvt_ctor (QEvt *const me, enum_t const sig) |
static QEvt * | QEvt_init (QEvt *const me, uint8_t const dummy) |
Event without parameters initialization. | |
Public Attributes | |
QSignal | sig |
Signal of the event (see Event Signal) | |
Static Private Member Functions | |
static void | QEvt_refCtr_inc_ (QEvt const *const me) |
static void | QEvt_refCtr_dec_ (QEvt const *const me) |
Private Attributes | |
uint8_t | poolNum_ |
Event pool number of this event. | |
uint8_t volatile | refCtr_ |
Event reference counter. | |
Event class.
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).
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().
Event without parameters initialization.
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().
[in,out] | me | current instance pointer (see SAS_QP_OO) |
[in] | dummy | shall be set to QEVT_DYNAMIC for dynamic events |
me
pointer, see SAS_QP_OO).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:
|
inlinestaticprivate |
|
inlinestaticprivate |
QSignal sig |
Signal of the event (see Event Signal)
|
private |
Event pool number of this event.
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.
|
private |
Event reference counter.
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().