Movatterモバイル変換


[0]ホーム

URL:


Logo
QP/C++ 8.1.1
Real-Time Event Framework
Loading...
Searching...
No Matches
qp.hpp File Reference

QP Framework platform-independent public interfaceMore...

Go to the source code of this file.

Classes

class  QP::QEvt
 Event class.More...
struct  QP::QMState
 State object for theQP::QMsm class (QM State Machine).More...
struct  QP::QMTranActTable
 Transition-Action Table for theQP::QMsm State Machine.More...
union  QP::QAsmAttr
 Attribute of for theQP::QAsm class (Abstract State Machine).More...
class  QP::QAsm
 Abstract State Machine class (state machine interface).More...
class  QP::QHsm
 Hierarchical State Machine class (QHsm-style state machine implementation strategy).More...
class  QP::QMsm
 Hierarchical State Machine class (QMsm-style state machine implementation strategy).More...
class  QP::QPSet
 Set of Active Objects of up toQF_MAX_ACTIVE elements.More...
class  QP::QSubscrList
 Subscriber List (for publish-subscribe).More...
class  QP::QActive
 Active object class (based on theQP::QHsm implementation strategy).More...
class  QP::QMActive
 Active object class (based onQMsm implementation strategy).More...
class  QP::QTimeEvt
 Time Event class.More...
class  QP::QTicker
 "Ticker" Active Object classMore...

Namespaces

namespace  QP
 QP/C++ Framework namespace.
namespace  QP::QF
 QF Active Object Framework namespace.

Macros

#define QP_VERSION_STR   "8.1.2"
 Version string complying with Software Versioning specification.
#define QP_VERSION   812U
 Version number for internal use (must correspond toQP_VERSION_STR).
#define QP_RELEASE   0x6A45C1C3U
 Encrypted currentQP release for internal use (7.3.5 on 2024-05-31).
#define Q_UNUSED_PAR(par_)
 Helper macro to clearly mark unused parameters of functions.
#define Q_DIM(array_)
#define Q_UINT2PTR_CAST(type_, uint_)
#define Q_STATE_DECL(state_)
#define Q_STATE_DEF(subclass_, state_)
#define Q_EVT_CAST(subclass_)
 Perform downcast of an event onto a subclass ofQP::QEvtclass_.
#define Q_STATE_CAST(handler_)
 Perform cast toQP::QStateHandler.
#define QM_STATE_DECL(state_)
#define QM_ACTION_DECL(action_)
#define QM_STATE_DEF(subclass_, state_)
#define QM_ACTION_DEF(subclass_, action_)
#define INIT(qsId_)
#define DISPATCH(e_, qsId_)
#define Q_PRIO(prio_, pthre_)
 Create aQP::QPrioSpec object to specify priority of an AO or a thread.
#define Q_NEW(evtT_, sig_, ...)
 Macro to allocate a dynamic event and asserting successful allocation.
#define Q_NEW_X(evtT_, margin_, sig_, ...)
 Macro to allocate a dynamic event without asserting successful allocation.
#define Q_NEW_REF(evtRef_, evtT_)
 Create a new reference of the current evente.
#define Q_DELETE_REF(evtRef_)
 Delete the event reference.
#define PUBLISH(e_, sender_)
 Publish an event to all subscriber Active Objects.
#define POST(e_, sender_)
 Invoke the direct event posting facilityQP::QActive::post_().
#define POST_X(e_, margin_, sender_)
 Invoke the direct event posting facility QActive::postx_() without delivery guarantee.
#define TICK_X(tickRate_, sender_)
 Invoke the system clock tick processing QP::QTimeEvt::tick_().
#define TRIG(sender_)
 Asynchronously trigger theQP::QTicker::trig_() AO to perform tick processing.
#define TICK(sender_)
 Invoke the system clock tick processing for tick rate 0.
#define QF_CRIT_EXIT_NOP()
 No-operation for exiting a critical section.

Typedefs

using int_t = int
 Alias for assertion-ID numbers inQP assertions and return fromQP::QF::run().
using QP::QSignal = std::uint16_t
 The signal of eventQP::QEvt.
using QP::QEvtPtr =QEvt const *
 Pointer to const event instances passed around in QP/C++ Framework.
using QP::QState = std::uint_fast8_t
 Type returned from state-handler functions.
using QP::QStateHandler =QState (*)(void * const me,QEvt const * const e)
 Pointer to a state-handler function.
using QP::QActionHandler =QState (*)(void * const me)
 Pointer to an action-handler function.
using QP::QXThreadHandler = void (*)(QXThread * const me)
 Pointer to an extended-thread handler function.
using QP::QPrioSpec = std::uint16_t
 Priority specification for Active Objects inQP.
using QP::QTimeEvtCtr = std::uint32_t
 Data type to store the block-size defined based on the macroQF_TIMEEVT_CTR_SIZE.
using QP::QPSetBits = std::uint32_t
 Bitmask for the internal representation ofQPSet elements.

Functions

char const * QP::version () noexcept
std::uint_fast8_t QP::QF_LOG2 (QP::QPSetBits const bitmask) noexcept
void QP::QF::init ()
 QF initialization.
void QP::QF::stop ()
 Invoked by the application layer to stop theQF framework and return control to the OS/Kernel (used in someQF ports).
int_t QP::QF::run ()
 Transfers control toQF to run the application.
void QP::QF::onStartup ()
 StartupQF callback.
void QP::QF::onCleanup ()
 CleanupQF callback.
void QP::QF::psInit (QSubscrList *const subscrSto,QSignal const maxSignal) noexcept
void QP::QF::publish_ (QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
static std::uint_fast16_t QP::QF::getQueueMin (std::uint_fast8_t const prio) noexcept
 This function returns the minimum of free entries of the given event queue.
void QP::QF::tick (std::uint_fast8_t const tickRate, void const *const sender) noexcept
void QP::QF::poolInit (void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept
 Event pool initialization for dynamic allocation of events.
std::uint16_t QP::QF::poolGetMaxBlockSize () noexcept
 Obtain the block size of any registered event pools.
std::uint16_t QP::QF::getPoolUse (std::uint_fast8_t const poolNum) noexcept
std::uint16_t QP::QF::getPoolFree (std::uint_fast8_t const poolNum) noexcept
std::uint16_t QP::QF::getPoolMin (std::uint_fast8_t const poolNum) noexcept
 Obtain the minimum of free entries of the given event pool.
QEvtQP::QF::newX_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin,QSignal const sig) noexcept
void QP::QF::gc (QEvt const *const e) noexcept
 Recycle a mutable (mutable) event.
QEvt const * QP::QF::newRef_ (QEvt const *const e,QEvt const *const evtRef) noexcept
void QP::QF::deleteRef_ (QEvt const *const evtRef) noexcept
template<class evtT_, typename... Args>
evtT_ * QP::QF::q_new (QSignal const sig, Args... args)
template<class evtT_, typename... Args>
evtT_ * QP::QF::q_new_x (std::uint_fast16_t const margin,QSignal const sig, Args... args)
template<class evtT_>
void QP::QF::q_new_ref (QP::QEvt const *const e, evtT_ const *&evtRef)
 Create a new reference of the current evente.
template<class evtT_>
void QP::QF::q_delete_ref (evtT_ const *&evtRef)
 Delete a new reference of the current evente.
QEvtQP::QF::newXfromISR_ (std::uint_fast16_t const evtSize, std::uint_fast16_t const margin,QSignal const sig) noexcept
void QP::QF::gcFromISR (QEvt const *e) noexcept
void QF_onContextSw (QP::QActive *prev,QP::QActive *next)

Variables

constexprQSignal QP::Q_USER_SIG {4U}
constexpr std::uint_fast16_t QP::QF::NO_MARGIN {0xFFFFU}
 Special value of margin that causes asserting failure in case event allocation or event posting fails.

Detailed Description

QP Framework platform-independent public interface

Forward Traceability

Definition in fileqp.hpp.

Macro Definition Documentation

◆ QP_VERSION_STR

#define QP_VERSION_STR   "8.1.2"

Version string complying with Software Versioning specification.

Details
QP_VERSION_STR is a zero-terminated version string in the formMAJOR.MINOR.PATCH compliant with Software Versioning specification.

Examples

  • 7.3.5-rc.1 — version 7.3.5 release-candidate-1
  • 7.3.5 — version 7.3.5 (final release)

Backward Traceability

  • SCM_SW_VER:Software Versioning

Forward Traceability

Definition at line33 of fileqp.hpp.

◆ QP_VERSION

#define QP_VERSION   812U

Version number for internal use (must correspond toQP_VERSION_STR).

Details
QP_VERSION is an unsigned integer constant of the formMAJOR|MINOR|PATCH corresponding toQP_VERSION_STR, with digits merged together. For exampleQP_VERSION_STR == "7.3.5-rc.1" results inQP_VERSION == 735.

Definition at line34 of fileqp.hpp.

◆ QP_RELEASE

#define QP_RELEASE   0x6A45C1C3U

Encrypted currentQP release for internal use (7.3.5 on 2024-05-31).

Details
QP_RELEASE contains information aboutQP_VERSION (e.g., 735) and release date (e.g., 2023-06-30).

Definition at line36 of fileqp.hpp.

◆ Q_UNUSED_PAR

#define Q_UNUSED_PAR(par_)
Value:
(static_cast<void>(par_))

Helper macro to clearly mark unused parameters of functions.

Forward Traceability

  • DVR_QP_MP2_R19_0_2:Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line89 of fileqp.hpp.

◆ Q_DIM

#define Q_DIM(array_)
Value:
(sizeof(array_) /sizeof((array_)[0U]))

Definition at line90 of fileqp.hpp.

◆ Q_UINT2PTR_CAST

#define Q_UINT2PTR_CAST(type_,
uint_ )
Value:
(reinterpret_cast<type_ *>(uint_))

Definition at line91 of fileqp.hpp.

◆ Q_STATE_DECL

#define Q_STATE_DECL(state_)
Value:
QP::QState state_ ## _h(QP::QEvtconst *const e); \
staticQP::QState state_(void *const me,QP::QEvtconst *const e)
Event class.
Definitionqp.hpp:101
std::uint_fast8_t QState
Type returned from state-handler functions.
Definitionqp.hpp:134

Definition at line375 of fileqp.hpp.

◆ Q_STATE_DEF

#define Q_STATE_DEF(subclass_,
state_ )
Value:
QP::QState subclass_::state_(void *const me,QP::QEvtconst *const e) { \
returnstatic_cast<subclass_ *>(me)->state_ ## _h(e); } \
QP::QState subclass_::state_ ## _h(QP::QEvtconst *const e)

Definition at line379 of fileqp.hpp.

◆ Q_EVT_CAST

#define Q_EVT_CAST(subclass_)
Value:
(static_cast<subclass_const*>(e))

Perform downcast of an event onto a subclass ofQP::QEvtclass_.

Details
This macro encapsulates the downcast ofQP::QEvt pointers, which violates MISRA-C:2025 Rule 11.3(R). This macro helps to localize this deviation.

Parameters
subclass_a subclass ofQP::QEvt
Note
The macro performs down-cast from the event pointere.

Usage

Q_STATE_DEF(Table, serving) {
QP::QState status_;
switch (e->sig) {
. . .
case HUNGRY_SIG: {
std::uint8_t n =Q_EVT_CAST(TableEvt)->philoId;// <===
. . .
break;
}
. . .
}
return status_;
}
#define Q_EVT_CAST(subclass_)
Perform downcast of an event onto a subclass of QP::QEvt class_.
Definitionqp.hpp:384
#define Q_STATE_DEF(subclass_, state_)
Definitionqp.hpp:379

Backward Traceability

  • SRS_QP_EVT_30:QP Framework shall allow Application to create event instances withParameters defined by the Application

Forward Traceability

  • DVR_QP_MP2_R19_0_2:Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line384 of fileqp.hpp.

◆ Q_STATE_CAST

#define Q_STATE_CAST(handler_)
Value:
(reinterpret_cast<QP::QStateHandler>(handler_))
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definitionqp.hpp:138

Perform cast toQP::QStateHandler.

Details
This macro encapsulates the cast of a specific state handler function pointer toQP::QStateHandler, which violates MISRA:C++2023 Rule 8.2.4 and Rule 8.2.5. This macro helps to localize these deviations.

Parameters
handler_state handler (function pointer)

Usage

Philo::Philo()
: QActive(Q_STATE_CAST(&initial)),// <===
m_timeEvt(this, TIMEOUT_SIG, 0U),
m_id(0xFFU)
{}
#define Q_STATE_CAST(handler_)
Perform cast to QP::QStateHandler.
Definitionqp.hpp:385

Forward Traceability

  • DVP_QP_MP2_R8_2_4:Directive 8.2.4(Required): Casts shall not be performed between a pointer to function and any other type
  • DVP_QP_MP2_R8_2_5:Rule 8.2.5(Required): reinterpret_cast used to convert to 'QP::QStateHandler'
  • DVR_QP_MP2_R19_0_2:Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line385 of fileqp.hpp.

◆ QM_STATE_DECL

#define QM_STATE_DECL(state_)
Value:
QP::QState state_ ## _h(QP::QEvtconst *const e); \
staticQP::QState state_(void *const me,QP::QEvtconst *const e); \
staticQP::QMStateconst state_ ## _s
State object for the QP::QMsm class (QM State Machine).
Definitionqp.hpp:142

Definition at line387 of fileqp.hpp.

◆ QM_ACTION_DECL

#define QM_ACTION_DECL(action_)
Value:
QP::QState action_ ## _h(); \
staticQP::QState action_(void *const me)

Definition at line392 of fileqp.hpp.

◆ QM_STATE_DEF

#define QM_STATE_DEF(subclass_,
state_ )
Value:
QP::QState subclass_::state_(void *const me,QP::QEvtconst *const e) {\
returnstatic_cast<subclass_ *>(me)->state_ ## _h(e); } \
QP::QState subclass_::state_ ## _h(QP::QEvtconst *const e)

Definition at line396 of fileqp.hpp.

◆ QM_ACTION_DEF

#define QM_ACTION_DEF(subclass_,
action_ )
Value:
QP::QState subclass_::action_(void *const me) { \
returnstatic_cast<subclass_ *>(me)->action_ ## _h(); } \
QP::QState subclass_::action_ ## _h()

Definition at line401 of fileqp.hpp.

◆ INIT

#define INIT(qsId_)
Value:
init((qsId_))

Definition at line407 of fileqp.hpp.

◆ DISPATCH

#define DISPATCH(e_,
qsId_ )
Value:
dispatch((e_), (qsId_))

Definition at line408 of fileqp.hpp.

◆ Q_PRIO

#define Q_PRIO(prio_,
pthre_ )
Value:
(static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U))
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definitionqp.hpp:417

Create aQP::QPrioSpec object to specify priority of an AO or a thread.

Parameters
[in]prio_QF priority [1..QF_MAX_ACTIVE]
[in]pthre_Preemption threshold [1..QF_MAX_ACTIVE]
Returns
The combined 16-bit priority specification (prio_ in bits [0..7] andpthre_ in bits [8..15].

Definition at line893 of fileqp.hpp.

◆ Q_NEW

#define Q_NEW(evtT_,
sig_,
... )
Value:
(QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
evtT_ * q_new(QSignal const sig, Args... args)
Definitionqp.hpp:829

Macro to allocate a dynamic event and asserting successful allocation.

Details
This deprecated macro is equivalent to invoking the function templateQP::QF::q_new<evtT_>(sig_, ...).

Deprecated
See also
QP::QF::q_new()
Parameters
[in]evtT_event type (class name) of the event to allocate
[in]sig_signal to assign to the newly allocated event
Returns
A valid event pointer of the typeevtT_*.

Definition at line901 of fileqp.hpp.

◆ Q_NEW_X

#define Q_NEW_X(evtT_,
margin_,
sig_,
... )
Value:
(QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
Definitionqp.hpp:838

Macro to allocate a dynamic event without asserting successful allocation.

Details
This deprecated macro is equivalent to invoking the function templateQP::QF::q_new_x<evtT_>(margin_, sig_, ...).

Deprecated
See also
QP::QF::q_new_x()
Parameters
[in]evtT_event type (class name) of the event to allocate
[in]margin_number of events that must remain available in the given pool after this allocation. The special value ::QF_NO_MARGIN causes asserting failure in case event allocation fails.
[in]sig_signal to assign to the newly allocated event
Returns
An event pointer of the typeevtT_* ornullptr if the event cannot be allocated with the specifiedmargin_ of events still left in the event pool.

Definition at line903 of fileqp.hpp.

◆ Q_NEW_REF

#define Q_NEW_REF(evtRef_,
evtT_ )
Value:
(QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
Definitionqp.hpp:854

Create a new reference of the current evente.

Details
This deprecated macro is equivalent to invoking the function templateQP::QF::q_new_ref<evtT_>(e, evtRef).

Deprecated
See also
QP::QF::q_new_ref()
Parameters
[in,out]evtRef_event reference to create
[in]evtT_event type (class name) of the event reference

Definition at line907 of fileqp.hpp.

◆ Q_DELETE_REF

#define Q_DELETE_REF(evtRef_)
Value:
do { \
QP::QF::deleteRef_((evtRef_)); \
(evtRef_) =nullptr; \
}while (false)

Delete the event reference.

Details
This deprecated macro is equivalent to invoking the function templateQP::QF::q_new_ref<evtT_>(e, evtRef).

Deprecated
See also
QP::QF::q_delete_ref()
Parameters
[in,out]evtRef_event reference to delete

Definition at line908 of fileqp.hpp.

◆ PUBLISH

#define PUBLISH(e_,
sender_ )
Value:
publish_((e_), (sender_), (sender_)->getPrio())

Publish an event to all subscriber Active Objects.

Details
IfQ_SPY is defined, this macro callsQP::QActive::publish_() with thesender_ parameter to identify the publisher of the event. Otherwise,sender_ is not used.

Parameters
[in]e_pointer to the posted event
[in]sender_pointer to the sender object (actually used only whenQ_SPY is defined)
Note
The pointer to thesender_ object is not necessarily a pointer to an active object. In fact, if QACTIVE_PUBLISH() is called from an interrupt or other context, you can create a unique object just to unambiguously identify the sender of the event.

Definition at line914 of fileqp.hpp.

◆ POST

#define POST(e_,
sender_ )
Value:
post_((e_), (sender_))

Invoke the direct event posting facilityQP::QActive::post_().

Details
This macro asserts if the queue overflows and cannot accept the event.

Parameters
[in]e_pointer to the event to post
[in]sender_pointer to the sender object.
Note
Thesender_ parameter is actually only used when QSsoftware tracing is enabled (macroQ_SPY is defined). When QS software tracing is disabled, this macro does not use thesender_ parameter, so it does not need to be defined.
See also

Definition at line916 of fileqp.hpp.

◆ POST_X

#define POST_X(e_,
margin_,
sender_ )
Value:
postx_((e_), (margin_), (sender_))

Invoke the direct event posting facility QActive::postx_() without delivery guarantee.

Details
This macro does not assert if the queue overflows and cannot accept the event with the specified margin of free slots remaining.

Parameters
[in]e_pointer to the event to post
[in]margin_the minimum free slots in the queue, which must still be available after posting the event. The special value QF::NO_MARGIN causes asserting failure in case event posting fails.
[in]sender_pointer to the sender object.
Returns
'true' if the posting succeeded, and 'false' if the posting failed due to insufficient margin of free entries available in the queue.
Note
Thesender_ parameter is actually only used when QS tracing is enabled (macroQ_SPY is defined). When QS software tracing is disabled, thePOST_X() macro does not pass thesender_ parameter, so the overhead of passing this extra parameter is entirely avoided.
The pointer to the sender object is not necessarily a pointer to an active object. In fact, ifPOST_X() is called from an interrupt or other context, you can create a unique object just to unambiguously identify the sender of the event.

Backward Traceability

Definition at line917 of fileqp.hpp.

◆ TICK_X

#define TICK_X(tickRate_,
sender_ )
Value:
tick((tickRate_), (sender_))

Invoke the system clock tick processing QP::QTimeEvt::tick_().

Details
This macro is the recommended way of invoking clock tick processing, because it provides the vital information for software tracing and avoids any overhead when the tracing is disabled.

Parameters
[in]tickRate_clock tick rate to be serviced through this call
[in]sender_pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macroQ_SPY is defined)
Note
When QS software tracing is disabled, the macro calls QTimeEvt::tick_() without thesender parameter, so the overhead of passing this extra parameter is entirely avoided.
The pointer to the sender object is not necessarily a pointer to an active object. In fact, whenTICK_X() is called from an interrupt, you would create a unique object just to unambiguously identify the ISR as the sender of the time events.

Definition at line919 of fileqp.hpp.

◆ TRIG

#define TRIG(sender_)
Value:
trig_((sender_))

Asynchronously trigger theQP::QTicker::trig_() AO to perform tick processing.

Details
This macro is the recommended way to trigger clock tick processing, because it provides the vital information for software tracing and avoids any overhead when the tracing is disabled.

Parameters
[in]sender_pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macroQ_SPY is defined)
Note
When QS software tracing is disabled, the macro calls QTicker_trig_() without thesender parameter, so the overhead of passing this extra parameter is entirely avoided.
The pointer to the sender object is not necessarily a pointer to an active object. In fact, when QTICKER_TRIG() is called from an interrupt, you would create a unique object just to unambiguously identify the ISR as the sender of the time events.

Definition at line920 of fileqp.hpp.

◆ TICK

#define TICK(sender_)
Value:
TICK_X(0U, (sender_))
#define TICK_X(tickRate_, sender_)
Invoke the system clock tick processing QP::QTimeEvt::tick_().
Definitionqp.hpp:919

Invoke the system clock tick processing for tick rate 0.

Parameters
[in]sender_pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macroQ_SPY is defined)

Definition at line929 of fileqp.hpp.

◆ QF_CRIT_EXIT_NOP

#define QF_CRIT_EXIT_NOP()
Value:
(static_cast<void>(0))

No-operation for exiting a critical section.

Details
In some QF ports the critical section exit takes effect only on the next machine instruction. If this next instruction is another entry to a critical section, the critical section won't be really exited, but rather the two adjacent critical sections would be merged. TheQF_CRIT_EXIT_NOP() macro contains minimal code required to prevent such merging of critical sections in such merging of critical sections in QF ports, in which it can occur.

Definition at line932 of fileqp.hpp.

Typedef Documentation

◆ int_t

usingint_t = int

Alias for assertion-ID numbers inQP assertions and return fromQP::QF::run().

Definition at line87 of fileqp.hpp.

Function Documentation

◆ QF_onContextSw()

void QF_onContextSw(QP::QActive *prev,
QP::QActive *next )

[8]ページ先頭

©2009-2025 Movatter.jp