Event class. More...
#include <qp.hpp>
Public Types | |
| enum | DynEvt : std::uint8_t { DYNAMIC } |
Public Member Functions | |
| constexpr | QEvt (QSignal const s) noexcept |
| Event constexpr constructor applicable to immutable and mutable event instances. | |
| QEvt ()=delete | |
| Disallowed default event constructor. | |
| void | init () const noexcept |
| Event initialization for dynamic events. | |
| void | init (DynEvt const dummy) const noexcept |
| Event initialization for dynamic events (overload). | |
Public Attributes | |
| std::uint32_t | sig: 16 |
| Signal of the event (see Event Signal). | |
| std::uint32_t | poolNum_: 8 |
| Event pool number of this event. | |
| std::uint32_t | refCtr_: 8 |
| Event reference counter. | |
| std::uint32_t | filler_ |
| Member of QP::QEvt to make it identical size in QP/C++ and SafeQP/C++. | |
Event class.
Details
Class QP::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).
Usage
The following example illustrates how to add event parameter(s) by inheriting the QP::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 QP::QEvt::QEvt().
Backward Traceability
Forward Traceability
| enum QP::QEvt::DynEvt : std::uint8_t |
|
inlineexplicitconstexprnoexcept |
Event constexpr constructor applicable to immutable and mutable event instances.
| [in] | s | signal of the event to initialize (for non-dynamic events) |
Usage
The following examples illustrate recommended ways to use the QEvt(QSignal) constructor to instantiate event objects based on the RAII principle (Resource Acquisition Is Initialization).
Forward Traceability
|
delete |
Disallowed default event constructor.
Details
The default event constructor is explicitly disallowed (= delete), so that all subclasses of QP::QEvt must provide constructors.
Forward Traceability
|
inlinenoexcept |
Event initialization for dynamic events.
Usage
When QEVT_PAR_INIT is defined, the template QP::QF::q_new() calls the init() member function of the derived event class to initialize the event parameters. The following example illustrates the implicit use of the QP::QEvt::init() initialization for dynamically allocated events.
Forward Traceability
|
inlinenoexcept |
Event initialization for dynamic events (overload).
| [in] | dummy | dummy parameter on which to overload the initialization |
Usage
The following example illustrates the implicit use of the QP::QEvt::init(DynEvt) initialization for dynamically allocated events. (When QEVT_PAR_INIT is defined, the template QP::QF::q_new() calls the init() member function of the derived event class to initialize event parameters):
Backward Traceability
| std::uint32_t QP::QEvt::sig |
Signal of the event (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 QP::Q_USER_SIG offset.
Backward Traceability
Forward Traceability
| std::uint32_t QP::QEvt::poolNum_ |
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 QP::QTimeEvt), the event-pool number is 0.
Forward Traceability
| std::uint32_t QP::QEvt::refCtr_ |
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 QP::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
| std::uint32_t QP::QEvt::filler_ |
Member of QP::QEvt to make it identical size in QP/C++ and SafeQP/C++.
Details
The 32-bit filler_ member ensures that the size of QP::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