QP/C 6.9.2
qep_msm.c File Reference

QMsm implementation More...

#include "qep_port.h"
#include "qassert.h"
#include "qs_port.h"
#include "qs_pkg.h"
Include dependency graph for qep_msm.c:

Go to the source code of this file.


#define QEP_ACT_PTR_INC_(act_)   (++(act_))
 Internal QEP macro to increment the given action table act_. More...


enum  { QMSM_MAX_ENTRY_DEPTH_ = 4 }
 internal QEP constants More...


void QMsm_ctor (QMsm *const me, QStateHandler initial)
QStateHandler QMsm_getStateHandler_ (QHsm *const me)
bool QMsm_isInState (QMsm const *const me, QMState const *const state)
QMState const * QMsm_childStateObj_ (QMsm const *const me, QMState const *const parent)


static struct QMState const l_msm_top_s

Detailed Description

QMsm implementation

Definition in file qep_msm.c.

Macro Definition Documentation


#define QEP_ACT_PTR_INC_ (   act_)    (++(act_))

Internal QEP macro to increment the given action table act_.

Incrementing a pointer violates the MISRA-C 2004 Rule 17.4(req), pointer arithmetic other than array indexing. Encapsulating this violation in a macro allows to selectively suppress this specific deviation.

Definition at line 74 of file qep_msm.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

internal QEP constants


maximum depth of entry levels in a MSM for transition to history.

Definition at line 54 of file qep_msm.c.

Function Documentation

◆ QMsm_ctor()

void QMsm_ctor ( QMsm *const  me,
QStateHandler  initial 
Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
[in,out]mepointer (see Object Orientation)
[in]initialthe top-most initial transition for the MSM.
Must be called only ONCE before QHSM_INIT().
QMsm inherits QHsm, so by the Object Orientation convention it should call the constructor of the superclass, i.e., QHsm_ctor(). However, this would pull in the QHsmVtable, which in turn will pull in the code for QHsm_init_() and QHsm_dispatch_() implemetations. To avoid this code size penalty, in case QHsm is not used in a given project, the QMsm_ctor() performs direct intitialization of the Vtable, which avoids pulling in the code for QMsm.
The following example illustrates how to invoke QMsm_ctor() in the "constructor" of a derived state machine:
void Calc_ctor(Calc * const me) {
/* superclass' ctor */
QMsm_ctor(&me->super, Q_STATE_CAST(&Calc_initial));
me->operand1 = 0.0;
me->operand2 = 0.0;
me->len = 0U;
me->opKey = 0U;
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
Definition: qep.h:228
void QMsm_ctor(QMsm *const me, QStateHandler initial)
Constructor of QMsm.
Definition: qep_msm.c:135

Definition at line 135 of file qep_msm.c.

◆ QMsm_getStateHandler_()

QStateHandler QMsm_getStateHandler_ ( QHsm *const  me)

Definition at line 419 of file qep_msm.c.

◆ QMsm_isInState()

bool QMsm_isInState ( QMsm const *const  me,
QMState const *const  state 
Tests if a state machine derived from QMsm is-in a given state.
For a MSM, to "be-in" a state means also to "be-in" a superstate of of the state.
[in]mepointer (see Object Orientation)
[in]statepointer to the QMState object that corresponds to the tested state.
'true' if the MSM "is in" the state and 'false' otherwise

Definition at line 642 of file qep_msm.c.

◆ QMsm_childStateObj_()

QMState const* QMsm_childStateObj_ ( QMsm const *const  me,
QMState const *const  parent 
Finds the child state of the given parent, such that this child state is an ancestor of the currently active state. The main purpose of this function is to support shallow history transitions in state machines derived from QMsm.
[in]mepointer (see Object Orientation)
[in]parentpointer to the state-handler object
the child of a given parent state, which is an ancestor of the currently active state. For the corner case when the currently active state is the given parent state, function returns the parent state.
See also
the child must be found

Definition at line 673 of file qep_msm.c.

Variable Documentation

◆ l_msm_top_s

struct QMState const l_msm_top_s
Initial value:
= {
(struct QMState *)0,
#define Q_ACTION_CAST(action_)
Perform cast to QActionHandler.
Definition: qep.h:237
State object for the QMsm class (QM State Machine).
Definition: qep.h:464

Definition at line 1 of file qep_msm.c.