16 #ifndef __OMNETPP_CFSM_H 17 #define __OMNETPP_CFSM_H 19 #include "cownedobject.h" 81 #define FSM_Switch(fsm) \ 82 for (int __i=1, __savedstate; \ 83 (__i<3 || (__i&1)==0 || (fsm).isInTransientState()) && \ 84 (__i<2*FSM_MAXT || (throw cRuntimeError(E_INFLOOP,(fsm).getStateName()),0)); \ 85 ((__i&1)==0 && __savedstate!=(fsm).getState() && \ 86 (throw cRuntimeError(E_STATECHG,(fsm).getStateName()),0)), \ 87 __savedstate=(fsm).getState(),++__i) \ 88 switch (FSM_Print(fsm,__i&1),(((fsm).getState()*2)|(__i&1))) 109 #define FSM_Transient(state) (-(state)) 119 #define FSM_Steady(state) (state) 130 #define FSM_Enter(state) (2*(state)) 139 #define FSM_Exit(state) (2*(state)|1) 151 #define FSM_Goto(fsm,state) (fsm).setState(state,#state) 161 #define FSM_Print(fsm,exiting) \ 162 (EV << "FSM " << (fsm).getName() \ 163 << ((exiting) ? ": leaving state " : ": entering state ") \ 164 << (fsm).getStateName() << endl) 168 #define FSM_Print(fsm,entering) ((void)0) 192 const char *stateName;
195 void copy(
const cFSM& other);
204 explicit cFSM(
const char *name=
nullptr);
231 virtual std::string str()
const override;
238 virtual void parsimPack(
cCommBuffer *buffer)
const override;
245 virtual void parsimUnpack(
cCommBuffer *buffer)
override;
276 void setState(
int state,
const char *stateName=
nullptr) {this->state=state;this->stateName=stateName;}
virtual cFSM * dup() const override
Definition: cfsm.h:225
int getState() const
Definition: cfsm.h:254
const char * getStateName() const
Definition: cfsm.h:259
int isInTransientState() const
Definition: cfsm.h:264
Store the state of an FSM. This class is used in conjunction with the FSM_Switch() and other FSM_ mac...
Definition: cfsm.h:182
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:104
Definition: cabstracthistogram.h:21
void setState(int state, const char *stateName=nullptr)
Definition: cfsm.h:276
cFSM(const cFSM &other)
Definition: cfsm.h:209