QP/C++ 8.1.2
Real-Time Event Framework
Loading...
Searching...
No Matches
QP::QAsm Class Referenceabstract

Abstract State Machine class (state machine interface). More...

#include <qp.hpp>

Inheritance diagram for QP::QAsm:
QP::QActive QP::QHsm QP::QHsmDummy QP::QMsm QP::QActiveDummy QP::QMActive QP::QTicker QP::QXThread

Public Member Functions

virtual ~QAsm () noexcept
 Virtual destructor of the QP::QAsm abstract base class.
virtual void init (void const *const e, std::uint_fast8_t const qsId)=0
 Virtual function to take the top-most initial transition in the state machine.
virtual void init (std::uint_fast8_t const qsId)
 Virtual function to take the top-most initial transition in the state machine (overloaded).
virtual void dispatch (QEvt const *const e, std::uint_fast8_t const qsId)=0
 Virtual function to dispatch an event to the state machine.
virtual bool isIn (QStateHandler const stateHndl)=0
 Virtual function to check whether the state machine is in a given state.
virtual QStateHandler getStateHandler () const noexcept=0
 Virtual method for getting the current state handler.
QStateHandler state () const noexcept
QMState const * stateObj () const noexcept

Static Public Member Functions

static constexpr QState Q_HANDLED ()
static constexpr QState Q_UNHANDLED ()
static constexpr QState QM_HANDLED ()
static constexpr QState QM_UNHANDLED ()
static constexpr QState QM_SUPER ()
static QState top (void *const me, QEvt const *const e) noexcept
 Top state handler that ignores all events.

Public Attributes

QAsmAttr m_state
 Current state (pointer to the current state-handler function).
QAsmAttr m_temp
 Temporary storage for target/act-table etc.

Static Public Attributes

static constexpr QState Q_RET_SUPER {0U}
static constexpr QState Q_RET_UNHANDLED {1U}
static constexpr QState Q_RET_HANDLED {2U}
static constexpr QState Q_RET_TRAN {3U}
static constexpr QState Q_RET_TRAN_HIST {4U}
static constexpr QState Q_RET_IGNORED {5U}
static constexpr QState Q_RET_ENTRY {6U}
static constexpr QState Q_RET_EXIT {7U}
static constexpr QState Q_RET_TRAN_INIT {8U}
static constexpr QSignal Q_EMPTY_SIG {0U}
static constexpr QSignal Q_ENTRY_SIG {1U}
static constexpr QSignal Q_EXIT_SIG {2U}
static constexpr QSignal Q_INIT_SIG {3U}
static constexpr QMState const * QM_STATE_NULL { nullptr }
static constexpr QActionHandler const Q_ACTION_NULL { nullptr }

Protected Member Functions

 QAsm () noexcept
 Constructor of the QP::QAsm base class.
QState tran (QStateHandler const target) noexcept
 Internal helper function to take a state transition in sublclasses of QP::QAsm.
QState tran_hist (QStateHandler const hist) noexcept
 Internal helper function to take a state transition to history in sublclasses of QP::QAsm.
QState super (QStateHandler const superstate) noexcept
 Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
QState qm_tran (void const *const tatbl) noexcept
 Internal helper function to take a state transition in QP::QMsm.
QState qm_tran_init (void const *const tatbl) noexcept
QState qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept
 Internal helper function to take a state transition to history in QP::QMsm.
QState qm_entry (QMState const *const s) noexcept
 Internal helper function to execute state entry actions in QP::QMsm.
QState qm_exit (QMState const *const s) noexcept
 Internal helper function to execute state exit actions in QP::QMsm.

Detailed Description

Abstract State Machine class (state machine interface).

Forward Traceability

  • DVR_QP_PCLP_1801: Base class has a destructor that is not public virtual; public override or protected non-virtual

Definition at line 167 of file qp.hpp.

Constructor & Destructor Documentation

◆ ~QAsm()

virtual QP::QAsm::~QAsm ( )
inlinevirtualnoexcept

Virtual destructor of the QP::QAsm abstract base class.

Details

Note
This virtual destructor is not provided by default and is provided only when the macro Q_XTOR is defined. This is because the presence of virtual destructor(s) seems to pull in the delete operator from the C++ library. This, in turn, might be problematic for deeply embedded systems that work without the heap and any other libraries.

Forward Traceability

Definition at line 209 of file qp.hpp.

◆ QAsm()

QP::QAsm::QAsm ( )
explicitprotectednoexcept

Constructor of the QP::QAsm base class.

Details
The constructor initializes the QAsm::vptr and clears the internal attributes. The constructor is "protected" because it is only intended to be invoked from the subclasses of the abstract base class QP::QAsm.

Forward Traceability

Definition at line 75 of file qf_act.cpp.

Member Function Documentation

◆ Q_HANDLED()

constexpr QState QP::QAsm::Q_HANDLED ( )
inlinestaticconstexpr

Definition at line 195 of file qp.hpp.

◆ Q_UNHANDLED()

constexpr QState QP::QAsm::Q_UNHANDLED ( )
inlinestaticconstexpr

Definition at line 197 of file qp.hpp.

◆ QM_HANDLED()

constexpr QState QP::QAsm::QM_HANDLED ( )
inlinestaticconstexpr

Definition at line 199 of file qp.hpp.

◆ QM_UNHANDLED()

constexpr QState QP::QAsm::QM_UNHANDLED ( )
inlinestaticconstexpr

Definition at line 201 of file qp.hpp.

◆ QM_SUPER()

constexpr QState QP::QAsm::QM_SUPER ( )
inlinestaticconstexpr

Definition at line 203 of file qp.hpp.

◆ init() [1/2]

virtual void QP::QAsm::init ( void const *const e,
std::uint_fast8_t const qsId )
pure virtual

Virtual function to take the top-most initial transition in the state machine.

Details
Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).

Parameters
[in]epointer to an initialization parameter (might be nullptr)
[in]qsIdQS-id of this state machine (for QS local filter)

Implemented in QP::QActive, QP::QActiveDummy, QP::QHsm, QP::QHsmDummy, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

◆ init() [2/2]

void QP::QAsm::init ( std::uint_fast8_t const qsId)
virtual

Virtual function to take the top-most initial transition in the state machine (overloaded).

Details
Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.

Parameters
[in]qsIdQS-id of this state machine (for QS local filter)

Reimplemented in QP::QActive, QP::QHsm, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

Definition at line 86 of file qf_act.cpp.

◆ dispatch()

virtual void QP::QAsm::dispatch ( QEvt const *const e,
std::uint_fast8_t const qsId )
pure virtual

Virtual function to dispatch an event to the state machine.

Details
Synchronously dispatches an event for processing to a state machine (must be overridden in the subclasses). The processing of an event represents one run-to-completion (RTC) step.

Parameters
[in]epointer to the event to be dispatched to the MSM
[in]qsIdQS-id of this state machine (for QS local filter)

Implemented in QP::QActive, QP::QActiveDummy, QP::QHsm, QP::QHsmDummy, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

◆ isIn()

virtual bool QP::QAsm::isIn ( QP::QStateHandler const state)
pure virtual

Virtual function to check whether the state machine is in a given state.

Details
Tests if a given state is part of the current active state configuration. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of the state.

Parameters
[in]statepointer to the state-handler function to be checked
Returns
'true' if the state machine "is in" the state and 'false' otherwise
Attention
This function should be called only when the state machine is in a "stable state configuration". Among others, this means that the state machine cannot call it in the middle of its own transition.

Backward Traceability

  • SRS_QP_SM_25: All State Machine Implementation Strategies provided by the QP/C++ Framework might supply a method for checking if a state machine is in a given state.

Implemented in QP::QActive, QP::QHsm, QP::QHsmDummy, QP::QMActive, and QP::QMsm.

◆ getStateHandler()

virtual QStateHandler QP::QAsm::getStateHandler ( ) const
pure virtualnoexcept

Virtual method for getting the current state handler.

Details
This virtual call applies to all subclasses of QP::QAsm, such as: QP::QHsm, QP::QMsm, QP::QActive, and QP::QMActive.

Returns
the current state-handler of the type QP::QStateHandler (pointer to function)
Note
This function can be called in any context (including from a critical section) and also not necessarily in the "stable state configuration". When called during a state transition in the state machine, it returns the source state.

Backward Traceability

  • SRS_QP_SM_26: All State Machine Implementation Strategies provided by the QP/C++ Framework might supply a method for obtaining the current state.

Usage
The following example illustrates how to obtain the current state handler of an Active Object:

QStateHandler handler = myAO->getStateHandler();
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:138

Implemented in QP::QActive, QP::QActiveDummy, QP::QHsm, QP::QHsmDummy, QP::QMActive, and QP::QMsm.

◆ state()

QStateHandler QP::QAsm::state ( ) const
inlinenoexcept

Definition at line 223 of file qp.hpp.

◆ stateObj()

QMState const * QP::QAsm::stateObj ( ) const
inlinenoexcept

Definition at line 226 of file qp.hpp.

◆ top()

QState QP::QAsm::top ( void *const me,
QEvt const *const e )
staticnoexcept

Top state handler that ignores all events.

Definition at line 80 of file qf_act.cpp.

◆ tran()

QState QP::QAsm::tran ( QStateHandler const target)
inlineprotectednoexcept

Internal helper function to take a state transition in sublclasses of QP::QAsm.

Definition at line 235 of file qp.hpp.

◆ tran_hist()

QState QP::QAsm::tran_hist ( QStateHandler const hist)
inlineprotectednoexcept

Internal helper function to take a state transition to history in sublclasses of QP::QAsm.

Definition at line 240 of file qp.hpp.

◆ super()

QState QP::QAsm::super ( QStateHandler const superstate)
inlineprotectednoexcept

Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.

Definition at line 245 of file qp.hpp.

◆ qm_tran()

QState QP::QAsm::qm_tran ( void const *const tatbl)
inlineprotectednoexcept

Internal helper function to take a state transition in QP::QMsm.

Definition at line 250 of file qp.hpp.

◆ qm_tran_init()

QState QP::QAsm::qm_tran_init ( void const *const tatbl)
inlineprotectednoexcept

Definition at line 255 of file qp.hpp.

◆ qm_tran_hist()

QState QP::QAsm::qm_tran_hist ( QMState const *const hist,
void const *const tatbl )
inlineprotectednoexcept

Internal helper function to take a state transition to history in QP::QMsm.

Definition at line 260 of file qp.hpp.

◆ qm_entry()

QState QP::QAsm::qm_entry ( QMState const *const s)
inlineprotectednoexcept

Internal helper function to execute state entry actions in QP::QMsm.

Definition at line 270 of file qp.hpp.

◆ qm_exit()

QState QP::QAsm::qm_exit ( QMState const *const s)
inlineprotectednoexcept

Internal helper function to execute state exit actions in QP::QMsm.

Definition at line 284 of file qp.hpp.

Member Data Documentation

◆ m_state

QAsmAttr QP::QAsm::m_state

Current state (pointer to the current state-handler function).

Definition at line 169 of file qp.hpp.

◆ m_temp

QAsmAttr QP::QAsm::m_temp

Temporary storage for target/act-table etc.

Details
The m_temp data member is used for passing information from the QP/C++ Application to the "event processor" of QP. The m_temp member is also used as the Duplicate Inverse Storage of the state attribute in between transitions (part of QP Functional Safety (FuSa) Subsystem).

Definition at line 170 of file qp.hpp.

◆ Q_RET_SUPER

QState QP::QAsm::Q_RET_SUPER {0U}
staticconstexpr

Definition at line 174 of file qp.hpp.

◆ Q_RET_UNHANDLED

QState QP::QAsm::Q_RET_UNHANDLED {1U}
staticconstexpr

Definition at line 175 of file qp.hpp.

◆ Q_RET_HANDLED

QState QP::QAsm::Q_RET_HANDLED {2U}
staticconstexpr

Definition at line 176 of file qp.hpp.

◆ Q_RET_TRAN

QState QP::QAsm::Q_RET_TRAN {3U}
staticconstexpr

Definition at line 177 of file qp.hpp.

◆ Q_RET_TRAN_HIST

QState QP::QAsm::Q_RET_TRAN_HIST {4U}
staticconstexpr

Definition at line 178 of file qp.hpp.

◆ Q_RET_IGNORED

QState QP::QAsm::Q_RET_IGNORED {5U}
staticconstexpr

Definition at line 181 of file qp.hpp.

◆ Q_RET_ENTRY

QState QP::QAsm::Q_RET_ENTRY {6U}
staticconstexpr

Definition at line 184 of file qp.hpp.

◆ Q_RET_EXIT

QState QP::QAsm::Q_RET_EXIT {7U}
staticconstexpr

Definition at line 185 of file qp.hpp.

◆ Q_RET_TRAN_INIT

QState QP::QAsm::Q_RET_TRAN_INIT {8U}
staticconstexpr

Definition at line 186 of file qp.hpp.

◆ Q_EMPTY_SIG

QSignal QP::QAsm::Q_EMPTY_SIG {0U}
staticconstexpr

Definition at line 190 of file qp.hpp.

◆ Q_ENTRY_SIG

QSignal QP::QAsm::Q_ENTRY_SIG {1U}
staticconstexpr

Definition at line 191 of file qp.hpp.

◆ Q_EXIT_SIG

QSignal QP::QAsm::Q_EXIT_SIG {2U}
staticconstexpr

Definition at line 192 of file qp.hpp.

◆ Q_INIT_SIG

QSignal QP::QAsm::Q_INIT_SIG {3U}
staticconstexpr

Definition at line 193 of file qp.hpp.

◆ QM_STATE_NULL

QMState const* QP::QAsm::QM_STATE_NULL { nullptr }
staticconstexpr

Definition at line 205 of file qp.hpp.

◆ Q_ACTION_NULL

QActionHandler const QP::QAsm::Q_ACTION_NULL { nullptr }
staticconstexpr

Definition at line 206 of file qp.hpp.


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