QP/C++  7.0.1
Real-Time Embedded Framework
qep.hpp File Reference

QEP/C++ platform-independent public interface. More...

Go to the source code of this file.

Classes

struct  QEvt
 QEvt base class. More...
 
union  QHsmAttr
 Attribute of for the QHsm class (Hierarchical State Machine) More...
 
class  QHsm
 Hierarchical State Machine base class. More...
 
class  QMsm
 QM State Machine implementation strategy. More...
 
struct  QMState
 State object for the QP::QMsm class (QM State Machine). More...
 
struct  QMTranActTable
 Transition-Action Table for the QP::QMsm State Machine. More...
 

Namespaces

namespace  QP
 namespace associated with the QP/C++ framework
 

Macros

#define QP_VERSION   701U
 The current QP version as a decimal constant XXYZ, where XX is a 2-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number. More...
 
#define QP_VERSION_STR   "7.0.1"
 The current QP version number string of the form XX.Y.Z, where XX is a 2-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number. More...
 
#define QP_RELEASE   0x7C7E85E2U
 Encrypted current QP release (7.0.1) and date (2022-06-30) More...
 
#define Q_SIGNAL_SIZE   2U
 The size (in bytes) of the signal of an event. More...
 
#define Q_EVT_CAST(class_)   (static_cast<class_ const *>(e))
 Perform downcast of an event onto a subclass of QEvt class_. More...
 
#define Q_UINT2PTR_CAST(type_, uint_)   (reinterpret_cast<type_ *>(uint_))
 Perform cast from unsigned integer uint_ to pointer of type type_. More...
 
#define QEVT_INITIALIZER(sig_)   { static_cast<QP::QSignal>(sig_), 0U, 0U }
 Initializer of static constant QEvt instances. More...
 
#define Q_STATE_DECL(state_)
 Macro to generate a declaration of a state-handler, state-caller and a state-object for a given state in a subclass of QP::QHsm. More...
 
#define Q_STATE_DEF(subclass_, state_)
 Macro to generate a definition of a state-handler for a given state in a subclass of QP::QHsm. More...
 
#define Q_HANDLED()   (Q_RET_HANDLED)
 Macro to specify that the event was handled. More...
 
#define Q_UNHANDLED()   (Q_RET_UNHANDLED)
 Macro to specify that the event was NOT handled due to a guard condition evaluating to 'false'. More...
 
#define Q_STATE_CAST(handler_)    (reinterpret_cast<QP::QStateHandler>(handler_))
 Macro to perform casting to QStateHandler. More...
 
#define Q_ACTION_CAST(act_)   (reinterpret_cast<QP::QActionHandler>(act_))
 Macro to perform casting to QActionHandler. More...
 
#define Q_ACTION_NULL   (nullptr)
 Macro to provide strictly-typed zero-action to terminate action lists in the transition-action-tables. More...
 
#define QM_STATE_DECL(state_)
 Macro to generate a declaration of a state-handler, state-caller and a state-object for a given state in a subclass of QP::QMsm. More...
 
#define QM_SM_STATE_DECL(subm_, state_)
 Macro to generate a declaration of a state-handler, state-caller and a state-object for a given submachine state in a subclass of QP::QMsm. More...
 
#define QM_ACTION_DECL(action_)
 Macro to generate a declaration of an action-handler and action-caller in a subclass of QP::QMsm. More...
 
#define QM_STATE_DEF(subclass_, state_)
 Macro to generate a definition of a state-caller and state-handler for a given state in a subclass of QP::QMsm. More...
 
#define QM_ACTION_DEF(subclass_, action_)
 Macro to generate a definition of an action-caller and action-handler in a subclass of QP::QMsm. More...
 
#define QM_HANDLED()   (Q_RET_HANDLED)
 Macro for a QM action-handler when it handles the event. More...
 
#define QM_UNHANDLED()   (Q_RET_UNHANDLED)
 Macro for a QM action-handler when it does not handle the event due to a guard condition evaluating to false. More...
 
#define QM_SUPER()   (Q_RET_SUPER)
 Macro for a QM action-handler when it passes the event to the superstate. More...
 
#define QM_STATE_NULL   (nullptr)
 Macro to provide strictly-typed zero-state to use for submachines. More...
 

Typedefs

using int_t = int
 alias for line numbers in assertions and return from QF::run() More...
 
using enum_t = int
 alias for enumerations used for event signals More...
 
using float32_t = float
 alias for 32-bit IEEE 754 floating point numbers More...
 
using float64_t = double
 alias for 64-bit IEEE 754 floating point numbers More...
 
using QSignal = std::uint16_t
 QSignal represents the signal of an event. More...
 
using QState = std::uint_fast8_t
 Type returned from state-handler functions. More...
 
using QStateHandler = QState(*)(void *const me, QEvt const *const e)
 Pointer to state-handler function. More...
 
using QActionHandler = QState(*)(void *const me)
 Pointer to an action-handler function. More...
 
using QXThreadHandler = void(*)(QXThread *const me)
 Pointer to a thread-handler function. More...
 

Variables

constexpr char const versionStr [] {QP_VERSION_STR}
 the current QP version number string based on QP_VERSION_STR More...
 
constexpr enum_t Q_USER_SIG {4}
 Offset or the user signals. More...
 

Detailed Description

Date
Last updated on: 2022-06-15
Version
Last updated for: Version 7.0.1, 2022-06-30 (planned)

Definition in file qep.hpp.


Class Documentation

◆ QP::QHsmAttr

union QP::QHsmAttr
Description
This union represents possible values stored in the 'state' and 'temp' attributes of the QP::QHsm class.

Definition at line 229 of file qep.hpp.

Class Members
QStateHandler fun pointer to a state handler function
QActionHandler act pointer to an action-handler function
QXThreadHandler thr pointer to an thread-handler function
QMState const * obj pointer to QMState object
QMTranActTable const * tatbl transition-action table

◆ QP::QMState

struct QP::QMState
Description
This class groups together the attributes of a QP::QMsm state, such as the parent state (state nesting), the associated state handler function and the exit action handler function. These attributes are used inside the QP::QMsm::dispatch() and QP::QMsm::init() functions.
Attention
The QP::QMState class is only intended for the QM code generator and should not be used in hand-crafted code.

Definition at line 780 of file qep.hpp.

Class Members
QMState const * superstate superstate of this state
QStateHandler const stateHandler state handler function
QActionHandler const entryAction entry action handler function
QActionHandler const exitAction exit action handler function
QActionHandler const initAction init action handler function

◆ QP::QMTranActTable

struct QP::QMTranActTable

Definition at line 789 of file qep.hpp.

Class Members
QMState const * target
QActionHandler const act[1]

Macro Definition Documentation

◆ QP_VERSION

#define QP_VERSION   701U

Definition at line 38 of file qep.hpp.

◆ QP_VERSION_STR

#define QP_VERSION_STR   "7.0.1"

Definition at line 43 of file qep.hpp.

◆ QP_RELEASE

#define QP_RELEASE   0x7C7E85E2U

Definition at line 46 of file qep.hpp.

◆ Q_SIGNAL_SIZE

#define Q_SIGNAL_SIZE   2U

Valid values: 1U, 2U, or 4U; default 2U

Description
This macro can be defined in the QEP port file (qep_port.hpp) to configure the QP::QSignal type. When the macro is not defined, the default of 2 bytes is applied.

Definition at line 57 of file qep.hpp.

◆ Q_EVT_CAST

#define Q_EVT_CAST (   class_)    (static_cast<class_ const *>(e))
Description
This macro encapsulates the downcast of QEvt pointers, which violates MISRA-C 2004 rule 11.4(advisory). This macro helps to localize this deviation.

Definition at line 97 of file qep.hpp.

◆ Q_UINT2PTR_CAST

#define Q_UINT2PTR_CAST (   type_,
  uint_ 
)    (reinterpret_cast<type_ *>(uint_))
Description
This macro encapsulates the cast to (type_ *), which QP ports or application might use to access embedded hardware registers. Such uses can trigger PC-Lint "Note 923: cast from int to pointer" and this macro helps to encapsulate this deviation.

Definition at line 107 of file qep.hpp.

◆ QEVT_INITIALIZER

#define QEVT_INITIALIZER (   sig_)    { static_cast<QP::QSignal>(sig_), 0U, 0U }
Description
This macro encapsulates the ugly casting of enumerated signals to QSignal and constants for QEvt.poolID and QEvt.refCtr_.

Definition at line 115 of file qep.hpp.

◆ Q_STATE_DECL

#define Q_STATE_DECL (   state_)
Value:
QP::QState state_ ## _h(QP::QEvt const * const e); \
static QP::QState state_(void * const me, QP::QEvt const * const e)
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition: qep.hpp:213
QEvt base class.
Definition: qep.hpp:155

Definition at line 805 of file qep.hpp.

◆ Q_STATE_DEF

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

Definition at line 811 of file qep.hpp.

◆ Q_HANDLED

#define Q_HANDLED ( )    (Q_RET_HANDLED)

Definition at line 817 of file qep.hpp.

◆ Q_UNHANDLED

#define Q_UNHANDLED ( )    (Q_RET_UNHANDLED)

Definition at line 821 of file qep.hpp.

◆ Q_STATE_CAST

#define Q_STATE_CAST (   handler_)     (reinterpret_cast<QP::QStateHandler>(handler_))
Description
This macro encapsulates the cast of a specific state handler function pointer to QStateHandler, which violates MISRA-C 2004 rule 11.4(advisory). This macro helps to localize this deviation.

Definition at line 828 of file qep.hpp.

◆ Q_ACTION_CAST

#define Q_ACTION_CAST (   act_)    (reinterpret_cast<QP::QActionHandler>(act_))
Description
This macro encapsulates the cast of a specific action handler function pointer to QActionHandler, which violates MISRA-C2004 rule 11.4(advisory). This macro helps to localize this deviation.

Definition at line 836 of file qep.hpp.

◆ Q_ACTION_NULL

#define Q_ACTION_NULL   (nullptr)

Definition at line 840 of file qep.hpp.

◆ QM_STATE_DECL

#define QM_STATE_DECL (   state_)
Value:
QP::QState state_ ## _h(QP::QEvt const * const e); \
static QP::QState state_(void * const me, QP::QEvt const * const e); \
static QP::QMState const state_ ## _s
State object for the QP::QMsm class (QM State Machine).
Definition: qep.hpp:780

Definition at line 847 of file qep.hpp.

◆ QM_SM_STATE_DECL

#define QM_SM_STATE_DECL (   subm_,
  state_ 
)
Value:
QP::QState state_ ## _h(QP::QEvt const * const e); \
static QP::QState state_(void * const me, QP::QEvt const * const e); \
static SM_ ## subm_ const state_ ## _s

Definition at line 854 of file qep.hpp.

◆ QM_ACTION_DECL

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

Definition at line 861 of file qep.hpp.

◆ QM_STATE_DEF

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

Definition at line 867 of file qep.hpp.

◆ QM_ACTION_DEF

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

Definition at line 874 of file qep.hpp.

◆ QM_HANDLED

#define QM_HANDLED ( )    (Q_RET_HANDLED)

Definition at line 880 of file qep.hpp.

◆ QM_UNHANDLED

#define QM_UNHANDLED ( )    (Q_RET_UNHANDLED)

Definition at line 884 of file qep.hpp.

◆ QM_SUPER

#define QM_SUPER ( )    (Q_RET_SUPER)

Definition at line 887 of file qep.hpp.

◆ QM_STATE_NULL

#define QM_STATE_NULL   (nullptr)

Applicable to suclasses of QP::QMsm.

Definition at line 891 of file qep.hpp.

Typedef Documentation

◆ int_t

using int_t = int

Definition at line 64 of file qep.hpp.

◆ enum_t

using enum_t = int

Definition at line 67 of file qep.hpp.

◆ float32_t

using float32_t = float
Note
QP does not use floating-point types anywhere in the internal implementation, except in QS software tracing, where utilities for output of floating-point numbers are provided for application-level trace records.

Definition at line 77 of file qep.hpp.

◆ float64_t

using float64_t = double
Note
QP does not use floating-point types anywhere in the internal implementation, except in QS software tracing, where utilities for output of floating-point numbers are provided for application-level trace records.

Definition at line 87 of file qep.hpp.