QP/C++  7.4.0-rc.1
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QP::QEvt Class Reference

Event class. More...

#include "qp.hpp"

Inheritance diagram for QP::QEvt:
QP::QTimeEvt

Public Types

enum  DynEvt : std::uint8_t { DYNAMIC }
 

Public Member Functions

constexpr QEvt (QSignal const s) noexcept
 
 QEvt ()=delete
 
void init () noexcept
 
void init (DynEvt const dummy) noexcept
 
std::uint_fast8_t getPoolNum_ () const noexcept
 

Static Public Member Functions

static bool verify_ (QEvt const *const e) noexcept
 

Public Attributes

QSignal sig
 
std::uint8_t volatile refCtr_
 
std::uint8_t evtTag_
 

Static Public Attributes

static constexpr std::uint8_t MARKER {0xE0U}
 

Detailed Description

Event class.

Description
Class QEvt represents QP events and serves as the base class for derivation of events with parameters.
Attention
The QEvt subclasses are forbidden from having any virtual functions, including virtual destructors.
Traceability
Usage
The following example illustrates how to add event parameter(s) by inheriting the QP::QEvt class:
struct KeypressEvt : public QP::QEvt { // <=== inherit QP::QEvt
// event parameters...
std::uint8_t keyId; // ID of the key pressed
};
Event class.
Definition qp.hpp:137
Note
Please see QEvt::QEvt(QSignal) for examples of instantiating event objects (immutable and mutable on the stack). Please see QP::QF::q_new()/QPQF::q_new_x() for code examples of allocating dynamic mutable events.

Definition at line 137 of file qp.hpp.

Member Enumeration Documentation

◆ DynEvt

enum QP::QEvt::DynEvt : std::uint8_t
Enumerator
DYNAMIC 

dummy parameter for dynamic event initialization (see QEvt::QEvt(DynEvt))

Definition at line 145 of file qp.hpp.

Constructor & Destructor Documentation

◆ QEvt() [1/2]

QP::QEvt::QEvt ( QSignal const s)
inlineexplicitconstexprnoexcept

Event constexpr constructor applicable to immutable and mutable event instances.

Parameters
[in]ssignal of the event to initialize (for non-dynamic events)
Traceability
Usage
The following examples illustrate recommended ways to use this QEvt(QSignal) constructor to instantiate event objects based on the RAII principle (Resource Acquisition Is Initialization).
// immutable event without parameters
static QP::QEvt const myEvt { APP::MY_SIG }; // <== use constexpr QEvt ctor
// post, publish, or dispatch the immutable event...
// immutable event with parameters
static APP::KeypressEvt const keyEvt { APP::KEYPRESS_SIG, 12U };
// post, publish, or dispatch the immutable event...
// array of immutable events with parameters
static APP::KeypressEvt const keyboardEvt[] {
{ APP::KEYPRESS_SIG, 12U },
{ APP::KEYPRESS_SIG, 13U }
};
// mutable event without parameters (e.g., automatic object inside a function)
QP::QEvt myEvt { sig }; // sig is a variable
// dispatch the event (asynchronous posting or publishing probably WRONG!)
// mutable event with parameters (e.g., automatic object inside a function)
APP::KeypressEvt keyEvt { sig, keyId };
// dispatch the event (asynchronous posting or publishing probably WRONG!)
QSignal sig
Definition qp.hpp:139

Definition at line 148 of file qp.hpp.

◆ QEvt() [2/2]

QP::QEvt::QEvt ( )
delete

Disallowed default event constructor.

Description
The default event constructor is explicitly disallowed (= delete), so that all subclasses of QP::QEvt must provide constructors.

Member Function Documentation

◆ init() [1/2]

void QP::QEvt::init ( )
inlinenoexcept

Event initialization for dynamic events

Returns
void
Usage
The following example illustrates the implicit use of the QEvt::QEvt(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):
static QP::QEvt const *evtPtr = QP::QF::q_new<QP::QEvt>(MY_SIG);
. . .
evtT_ * q_new(enum_t const sig)
Definition qp.hpp:1137

Definition at line 154 of file qp.hpp.

◆ init() [2/2]

void QP::QEvt::init ( DynEvt const dummy)
inlinenoexcept

Event initialization for dynamic events

Parameters
[in]dummydummy parameter on which to overload the initialization
Returns
void
Usage
The following example illustrates the implicit use of the QEvt::QEvt(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):
static QP::QEvt const *evtPtr = QP::QF::q_new<QP::QEvt>(MY_SIG, QP::QEvt::DYNAMIC);
. . .
@ DYNAMIC
Definition qp.hpp:145

Definition at line 157 of file qp.hpp.

◆ verify_()

static bool QP::QEvt::verify_ ( QEvt const *const e)
inlinestaticnoexcept

Internal function to verify the event pointer and the memory marker in the event (QP FuSa Subsystem)

Returns
'true' if this event passes the integrity check and 'false' otherwise.

Definition at line 161 of file qp.hpp.

◆ getPoolNum_()

std::uint_fast8_t QP::QEvt::getPoolNum_ ( ) const
inlinenoexcept

Get the event pool number of the given event.

Returns
Event pool number of the event (zero for immutable (static) events, non-zero for mutable (dynamic) events from event pools).

Definition at line 165 of file qp.hpp.

Member Data Documentation

◆ sig

QSignal QP::QEvt::sig

Signal of the event (see Event Signal).

Traceability

Definition at line 139 of file qp.hpp.

◆ refCtr_

std::uint8_t volatile QP::QEvt::refCtr_

Reference counter (for mutable events, and 0 for immutable (static) events)

Traceability

Definition at line 140 of file qp.hpp.

◆ evtTag_

std::uint8_t QP::QEvt::evtTag_

Event "tag" containing pool-ID (indicating which event pool it came from) plus event marker

Description
The 8-bit evtTag_ member stores the event-pool number (in bits 0:3) and the QEvt::MARKER memory marker for integrity checking (in bits 4:7). In the special case of immutable events (not from event pools) the event-pool number bits are 0 (but bits 4:7 must still hold the QEvt::MARKER memory marker).
Traceability

Definition at line 141 of file qp.hpp.

◆ MARKER

std::uint8_t QP::QEvt::MARKER {0xE0U}
staticconstexpr

QP::QEvt memory marker (for internal integrity checks)

Description
The marker is implanted in bits 4:7 of QEvt::evtTag_.

Definition at line 144 of file qp.hpp.


The documentation for this class was generated from the following files: