19 #include "precompiled.h"
135 eval &= Condition( it->pContext );
151 CallbackList::const_iterator it =
m_Actions.begin();
158 result &= Action( it->pContext,
m_Event );
202 TransitionList::iterator itTransition =
m_Transitions.begin();
206 if ( !pCurrTransition )
continue;
208 delete pCurrTransition;
212 EventMap::iterator itEvent =
m_Events.begin();
213 for( ; itEvent !=
m_Events.end(); ++itEvent )
216 if ( !pCurrEvent )
continue;
251 EventMap::iterator it =
m_Events.find( eventType );
259 if ( !pEvent )
return NULL;
274 unsigned int eventType,
275 unsigned int nextState )
285 if ( !pEvent )
return NULL;
289 if ( !pNewTransition )
302 return pNewTransition;
311 unsigned int eventType,
312 unsigned int nextState,
317 if ( !pTransition )
return NULL;
332 unsigned int eventType )
const
345 if ( !pCurrTransition )
continue;
348 if ( !pCurrEvent )
continue;
352 pCurrEvent->
GetType() == eventType )
354 return pCurrTransition;
405 if ( !pTransition )
return false;
408 EventMap::iterator it =
m_Events.find( eventType );
423 if ( !pTransition->
RunActions() )
return false;
451 StateSet::const_iterator it =
m_States.find( state );
452 if ( it ==
m_States.end() )
return false;
463 EventMap::const_iterator it =
m_Events.find( eventType );
464 if ( it ==
m_Events.end() )
return false;
void RegisterCondition(void *pCondition, void *pContext)
void RegisterAction(void *pAction, void *pContext)
void Shutdown(void)
Clear event, action and condition lists and reset state machine.
Represents a signal in the state machine that a change has occurred.
void SetEvent(CFsmEvent *pEvent)
bool IsValidEvent(unsigned int eventType) const
void AddState(unsigned int state)
bool ApplyConditions(void) const
CFsmEvent * AddEvent(unsigned int eventType)
virtual void Setup(void)
Constructs the state machine.
CFsmTransition(unsigned int state)
unsigned int GetCurrState(void) const
CFsmTransition * GetTransition(unsigned int state, unsigned int eventType) const
#define FSM_INVALID_STATE
bool IsFirstTime(void) const
void SetNextState(unsigned int nextState)
bool RunActions(void) const
CallbackList m_Conditions
bool(* ACTION)(void *pContext, const CFsmEvent *pEvent)
unsigned int GetNextState(void) const
bool IsValidState(unsigned int state) const
bool Update(unsigned int eventType, void *pEventData)
void SetCurrState(unsigned int state)
CFsmEvent * GetEvent(void) const
TransitionList m_Transitions
void SetParamRef(void *pParam)
CFsmTransition * AddTransition(unsigned int state, unsigned int eventType, unsigned int nextState)
CFsmEvent(unsigned int type)
unsigned int m_FirstState
virtual bool IsDone(void) const
unsigned int GetType(void) const
void SetFirstState(unsigned int firstState)
unsigned int GetNextState(void) const
void SetNextState(unsigned int nextState)
bool(* CONDITION)(void *pContext)
An association of event, condition, action and next state.