QP/C++  7.3.4
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

QEvtctor (DynEvt const dummy) noexcept
 
constexpr QEvt (QSignal const s) noexcept
 
 QEvt ()=delete
 
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:139
Note
Please see QEvt::QEvt(QSignal) for examples of instantiating event objects (immutable and mutable on the stack). Please see Q_NEW()/Q_NEW_X() for code examples of allocating dynamic mutable events.

Definition at line 139 of file qp.hpp.

Member Enumeration Documentation

◆ DynEvt

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

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

Definition at line 149 of file qp.hpp.

Constructor & Destructor Documentation

◆ QEvt() [1/2]

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:141

Definition at line 157 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

◆ ctor()

QEvt * QP::QEvt::ctor ( DynEvt const dummy)
noexcept

Definition at line 73 of file qf_dyn.cpp.

◆ verify_()

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 163 of file qp.hpp.

◆ getPoolNum_()

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

Definition at line 167 of file qp.hpp.

Member Data Documentation

◆ sig

QEvt::sig

Signal of the event (see Event Signal).

Traceability

Definition at line 141 of file qp.hpp.

◆ refCtr_

QEvt::refCtr_

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

Traceability

Definition at line 142 of file qp.hpp.

◆ evtTag_

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 143 of file qp.hpp.

◆ MARKER

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 146 of file qp.hpp.


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