QP/C++  8.0.0
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
 
bool verify_ () const noexcept
 Internal function to verify the internal integrity of the event instance (QP FuSa Subsystem)
 
std::uint_fast8_t getPoolNum_ () const noexcept
 Internal function to get the event pool-number of the given event.
 

Public Attributes

QSignal sig
 Signal of the event (see Event Signal)
 
std::uint8_t evtTag_
 Event "tag" contains pool-ID plus the Duplicate Inverted Storage of the QEvt::refCtr_.
 
std::uint8_t volatile refCtr_
 Event reference counter.)
 

Detailed Description

Event class.

Details
Class QP QEvt represents QP events and serves as the base class for derivation of events with parameters (see also Object Orientation). Please see the QP QEvt class design specifications linked in the "Backward Traceability" section.
Backward Traceability
Forward Traceability
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:
struct KeypressEvt : public QP::QEvt { // <=== inherit QP::QEvt
// event parameters...
std::uint8_t keyId; // ID of the key pressed
};
Event class.
Definition qp.hpp:131
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().
// immutable event without parameters
static QEvt const myEvt { MY_SIG };
// post, publish, or dispatch the immutable event...
// immutable event with parameters
static KeypressEvt const keyEvt {
KEYPRESS_SIG, // signal
12U // .keyId attribute
}
// post, publish, or dispatch the immutable event...
// mutable event without parameters (e.g., automatic object inside a function)
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)
KeypressEvt keyEvt { // sig and keyId are variables
sig, // signal
keyId // .keyId attribute
};
// dispatch the event (asynchronous posting or publishing probably WRONG!)
QSignal sig
Signal of the event (see Event Signal)
Definition qp.hpp:133
QEvt()=delete
Note
Please see QP 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 131 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 138 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)
Backward 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!)

Definition at line 141 of file qp.hpp.

◆ QEvt() [2/2]

QP::QEvt::QEvt ( )
delete

Disallowed default event constructor.

Details
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, Args... args)
Definition qp.hpp:1137

Definition at line 147 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:138

Definition at line 150 of file qp.hpp.

◆ verify_()

bool QP::QEvt::verify_ ( ) const
inlinenoexcept

Internal function to verify the internal integrity of the event instance (QP FuSa Subsystem)

Description
The integrity checks include:
  • range check of the reference counter
  • Duplicate Inverse Storage check of bits reference counter bits 0:3
Returns
'true' if this event passes the integrity check and 'false' otherwise.

Definition at line 154 of file qp.hpp.

◆ getPoolNum_()

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

Internal function to get the event pool-number of the given event.

Returns
Pool-ID of the event. The Pool-ID is zero for immutable (static) events.

Definition at line 159 of file qp.hpp.

Member Data Documentation

◆ sig

QSignal QP::QEvt::sig

Signal of the event (see Event Signal)

Backward Traceability

Definition at line 133 of file qp.hpp.

◆ evtTag_

std::uint8_t QP::QEvt::evtTag_

Event "tag" contains pool-ID plus the Duplicate Inverted Storage of the QEvt::refCtr_.

Details
The 8-bit evtTag_ member stores the event-pool number (in bits 4:7) and the Duplicate Inverted Storage of the QEvt::refCtr_ for integrity checking (in bits 0:3). For mutable events, the QEvt_ctor() initializes refCtr_ to 0 and consequently evtTag_ to 0xF. For immutable events (not from event pools) the constexpr constructor QP QEvt::QEvt() initializes refCtr_ to 0xE and consequently evtTag_ to 0x1.
Backward Traceability
  • QP::QEvt : Event class
  • SRS_QP_EVT_31 : Event abstraction may contain other data items for internal event management inside QP/C++ Framework
  • SRS_QP_EVT_30 : QP/C++ Framework shall allow Application to create event instances with Parameters defined by the Application

Definition at line 134 of file qp.hpp.

◆ refCtr_

std::uint8_t volatile QP::QEvt::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, the member QEvt::refCtr_ holds the fixed value 0xE, which is initialized in the constexpr constructor QP QEvt::QEvt().
Backward Traceability
  • QP::QEvt : Event class
  • SRS_QP_EVT_31 : Event abstraction may contain other data items for internal event management inside QP/C++ Framework
  • SRS_QP_EVT_30 : QP/C++ Framework shall allow Application to create event instances with Parameters defined by the Application

Definition at line 135 of file qp.hpp.


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