OMNeT++ Simulation Library
6.0.3
|
16 #ifndef __OMNETPP_CFSM_H
17 #define __OMNETPP_CFSM_H
19 #include "cownedobject.h"
83 #define FSM_Switch(fsm) \
84 for (int __i=1, __savedstate; \
85 (__i<3 || (__i&1)==0 || (fsm).isInTransientState()) && \
86 (__i<2*FSM_MAXT || (throw cRuntimeError(E_INFLOOP,(fsm).getStateName()),0)); \
87 ((__i&1)==0 && __savedstate!=(fsm).getState() && \
88 (throw cRuntimeError(E_STATECHG,(fsm).getStateName()),0)), \
89 __savedstate=(fsm).getState(),++__i) \
90 switch (FSM_Print(fsm,__i&1),(((fsm).getState()*2)|(__i&1)))
111 #define FSM_Transient(state) (-(state))
121 #define FSM_Steady(state) (state)
132 #define FSM_Enter(state) (2*(state))
141 #define FSM_Exit(state) (2*(state)|1)
153 #define FSM_Goto(fsm,state) (fsm).setState(state,#state)
163 #define FSM_Print(fsm,exiting) \
164 (EV << "FSM " << (fsm).getName() \
165 << ((exiting) ? ": leaving state " : ": entering state ") \
166 << (fsm).getStateName() << endl)
170 #define FSM_Print(fsm,entering) ((void)0)
194 const char *stateName =
"INIT";
197 void copy(
const cFSM& other);
208 explicit cFSM(
const char *name=
nullptr);
235 virtual std::string str()
const override;
266 void setState(
int state,
const char *stateName=
nullptr) {this->state=state;this->stateName=stateName;}
int getState() const
Definition: cfsm.h:244
int isInTransientState() const
Definition: cfsm.h:254
const char * getStateName() const
Definition: cfsm.h:249
Store the state of an FSM. This class is used in conjunction with the FSM_Switch() and other FSM_ mac...
Definition: cfsm.h:184
cFSM(const cFSM &other)
Definition: cfsm.h:213
virtual cFSM * dup() const override
Definition: cfsm.h:229
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
void setState(int state, const char *stateName=nullptr)
Definition: cfsm.h:266
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition: cownedobject.h:105