Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CFsm Class Reference

Manages states, events, actions and transitions between states. More...

#include <fsm.h>

Inheritance diagram for CFsm:
CNetClient CNetServerSession

Public Member Functions

 CFsm (void)
 
virtual ~CFsm (void)
 
virtual void Setup (void)
 Constructs the state machine. More...
 
void Shutdown (void)
 Clear event, action and condition lists and reset state machine. More...
 
void AddState (unsigned int state)
 
CFsmEventAddEvent (unsigned int eventType)
 
CFsmTransitionAddTransition (unsigned int state, unsigned int eventType, unsigned int nextState)
 
CFsmTransitionAddTransition (unsigned int state, unsigned int eventType, unsigned int nextState, void *pAction, void *pContext)
 
CFsmTransitionGetTransition (unsigned int state, unsigned int eventType) const
 
CFsmTransitionGetEventTransition (unsigned int eventType) const
 
void SetFirstState (unsigned int firstState)
 
void SetCurrState (unsigned int state)
 
unsigned int GetCurrState (void) const
 
void SetNextState (unsigned int nextState)
 
unsigned int GetNextState (void) const
 
const StateSetGetStates (void) const
 
const EventMapGetEvents (void) const
 
const TransitionListGetTransitions (void) const
 
bool Update (unsigned int eventType, void *pEventData)
 
bool IsValidState (unsigned int state) const
 
bool IsValidEvent (unsigned int eventType) const
 
virtual bool IsDone (void) const
 

Private Member Functions

 NONCOPYABLE (CFsm)
 
bool IsFirstTime (void) const
 

Private Attributes

bool m_Done
 
unsigned int m_FirstState
 
unsigned int m_CurrState
 
unsigned int m_NextState
 
StateSet m_States
 
EventMap m_Events
 
TransitionList m_Transitions
 

Detailed Description

Manages states, events, actions and transitions between states.

It provides an interface for advertising events and track the current state. The implementation is a Mealy state machine, so the system respond to events and execute some action.

A Mealy state machine has behaviour associated with state transitions; Mealy machines are event driven where an event triggers a state transition

Definition at line 117 of file fsm.h.

Constructor & Destructor Documentation

CFsm::CFsm ( void  )

Definition at line 169 of file fsm.cpp.

CFsm::~CFsm ( void  )
virtual

Definition at line 181 of file fsm.cpp.

Member Function Documentation

CFsmEvent * CFsm::AddEvent ( unsigned int  eventType)

Definition at line 246 of file fsm.cpp.

void CFsm::AddState ( unsigned int  state)

Definition at line 236 of file fsm.cpp.

CFsmTransition * CFsm::AddTransition ( unsigned int  state,
unsigned int  eventType,
unsigned int  nextState 
)

Definition at line 272 of file fsm.cpp.

CFsmTransition * CFsm::AddTransition ( unsigned int  state,
unsigned int  eventType,
unsigned int  nextState,
void *  pAction,
void *  pContext 
)

Definition at line 309 of file fsm.cpp.

unsigned int CFsm::GetCurrState ( void  ) const
inline

Definition at line 154 of file fsm.h.

const EventMap& CFsm::GetEvents ( void  ) const
inline

Definition at line 158 of file fsm.h.

CFsmTransition* CFsm::GetEventTransition ( unsigned int  eventType) const
unsigned int CFsm::GetNextState ( void  ) const
inline

Definition at line 156 of file fsm.h.

const StateSet& CFsm::GetStates ( void  ) const
inline

Definition at line 157 of file fsm.h.

CFsmTransition * CFsm::GetTransition ( unsigned int  state,
unsigned int  eventType 
) const

Definition at line 330 of file fsm.cpp.

const TransitionList& CFsm::GetTransitions ( void  ) const
inline

Definition at line 159 of file fsm.h.

bool CFsm::IsDone ( void  ) const
virtual

Definition at line 439 of file fsm.cpp.

bool CFsm::IsFirstTime ( void  ) const
private

Definition at line 384 of file fsm.cpp.

bool CFsm::IsValidEvent ( unsigned int  eventType) const

Definition at line 461 of file fsm.cpp.

bool CFsm::IsValidState ( unsigned int  state) const

Definition at line 449 of file fsm.cpp.

CFsm::NONCOPYABLE ( CFsm  )
private
void CFsm::SetCurrState ( unsigned int  state)

Definition at line 375 of file fsm.cpp.

void CFsm::SetFirstState ( unsigned int  firstState)

Definition at line 366 of file fsm.cpp.

void CFsm::SetNextState ( unsigned int  nextState)
inline

Definition at line 155 of file fsm.h.

void CFsm::Setup ( void  )
virtual

Constructs the state machine.

This method must be overriden so that connections are constructed for the particular state machine implemented

Definition at line 190 of file fsm.cpp.

void CFsm::Shutdown ( void  )

Clear event, action and condition lists and reset state machine.

Definition at line 199 of file fsm.cpp.

bool CFsm::Update ( unsigned int  eventType,
void *  pEventData 
)

Definition at line 393 of file fsm.cpp.

Member Data Documentation

unsigned int CFsm::m_CurrState
private

Definition at line 170 of file fsm.h.

bool CFsm::m_Done
private

Definition at line 168 of file fsm.h.

EventMap CFsm::m_Events
private

Definition at line 173 of file fsm.h.

unsigned int CFsm::m_FirstState
private

Definition at line 169 of file fsm.h.

unsigned int CFsm::m_NextState
private

Definition at line 171 of file fsm.h.

StateSet CFsm::m_States
private

Definition at line 172 of file fsm.h.

TransitionList CFsm::m_Transitions
private

Definition at line 174 of file fsm.h.


The documentation for this class was generated from the following files: