Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CC_FSM.h

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // CC_FSM.h 00005 // 00006 // Version 1.0 00007 // Date 02.10.03 00008 // Author A. Pasetti (P&P Software) 00009 // 00010 // Change Record: 00011 00012 #ifndef CC_FSMH 00013 #define CC_FSMH 00014 00015 #include "../GeneralInclude/ForwardDeclarations.h" 00016 #include "../GeneralInclude/BasicTypes.h" 00017 #include "../Base/CC_RootObject.h" 00018 #include "FsmState.h" 00019 00096 class CC_FSM : public CC_RootObject { 00097 00098 private: 00099 TD_FsmStateIndex numberOfStates; 00100 bool allTransitionEnabled; // enable/disable all state transitions 00101 bool* transitionEnabled; // if transitionEnabled[i] is true, then 00102 // transitions into the i-th state are enabled. 00103 FsmState** pState; // state[i] is the pointer to the i-th state 00104 // of the FSM 00105 FsmState* pCurrentState; // currently active state of the FSM 00106 TD_FsmStateIndex currentState; // index of the currently active state 00107 00108 // If a state transition request was made, this variable stores the index 00109 // of the last target state to have been requested. If no state transition 00110 // was requested, this variable has a negative value. 00111 TD_FsmStateIndex requestedTargetState; 00112 00113 // This variable is an array. nextState[i] holds the index of the next 00114 // state associated to the i-th state. This array is loaded when a reset() 00115 // is performed. It is useful to speed up execution of an autonomous state 00116 // transition. 00117 TD_FsmStateIndex* pNextState; 00118 00119 protected: 00120 00159 void tryTransition(TD_FsmStateIndex targetState); 00160 00161 public: 00162 00168 CC_FSM(void); 00169 00213 void reset(void); 00214 00220 virtual bool isObjectConfigured(void); 00221 00235 void setNumberOfStates(TD_FsmStateIndex numberOfStates); 00236 00244 TD_FsmStateIndex getNumberOfStates(void) const; 00245 00258 void setState(TD_FsmStateIndex i, FsmState* state); 00259 00269 inline FsmState* getState(TD_FsmStateIndex i) const; 00270 00275 inline TD_FsmStateIndex getCurrentState(void) const; 00276 00284 void setTransitionEnableStatus(bool enabled); 00285 00297 void setTransitionEnableStatus(TD_FsmStateIndex toState, bool enabled); 00298 00304 inline bool isTransitionEnabled(void) const; 00305 00317 inline bool isTransitionEnabled(TD_FsmStateIndex toState) const; 00318 00333 void makeTransitionRequest(TD_FsmStateIndex targetState); 00334 00355 void activate(void); 00356 }; 00357 00358 #include "CC_FSM_inl.h" 00359 00360 #endif 00361 00362
Copyright 2003 P&P Software GmbH - All Rights Reserved