SourceForge Project Site
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FSM::CFiniteStateMachine Class Reference

#include <FiniteStateMachine.h>

List of all members.

Public Methods

 CFiniteStateMachine ()
 ~CFiniteStateMachine ()
CFSMState * AddState (const char *stateName, const char *className="State")
CFSMState * GetState (const char *stateName) const
bool DeleteState (CFSMState *state)
bool DeleteState (const char *stateName)
State_Map::const_iterator GetStatesBegin () const
 Use (*iterator) to get the pointer to the state. More...

State_Map::const_iterator GetStatesEnd () const
CFSMTransition * AddTransition (const char *fromStateName, const char *onEvent="ANY", const char *className="SimpleTransition")
CFSMTransition * AddSimpleTransition (const char *fromStateName, const char *toStateName, const char *onEvent="ANY")
bool DeleteTransition (const char *fromState, int index)
 Delete the specified transition. More...

CFSMCondition * AddCondition (const char *stateName, int transition, const char *className="TestVariable")
 Create a new condition of the given class and add it to a transition. More...

CFSMAction * AddEnterAction (const char *stateName, const char *className)
 Create a new action to a state, that is executed each time the state is entered. More...

CFSMAction * AddLeaveAction (const char *stateName, const char *className)
 Create a new action to a state, that is executed each time the state is leaved. More...

CFSMAction * AddAction (const char *stateName, int transition, const char *className)
 Create a new action of the given class and add it to a transition. More...

bool AddVariable (const char *varName, const int initValue=0)
bool DeleteVariable (const char *varName)
bool SetVariable (const char *varName, const int value)
bool GetVariable (const char *varName, int &value) const
Var_Map::const_iterator GetVarsBegin () const
Var_Map::const_iterator GetVarsEnd () const
bool SetInitialState (const char *stateName)
const char * GetInitialState () const
bool Start (const char *stateName=0)
void Stop ()
bool ProcessEvent (const char *Event, void *a=NULL, void *b=NULL, bool *consumed=NULL)
CFSMState * GetCurrentState () const
bool Clear ()
bool SwitchToState (CFSMState *newState)
 Set a new state. More...

bool PushState (CFSMState *newState)
 Set a new state and push it onto the stack. More...

bool PopState ()
 Pop a state from the stack and switch to it. More...

void Register (const char *className, FSMObjectCreateMethod create)
CFSMObject * Create (const char *className)
 create an object of certain class. More...


Protected Methods

bool LoadClass (const char *className)

Private Methods

void RegisterBaseTypes ()

Private Attributes

FSMObjectCreate_Map FSMObjectCreationMethods
State_Map m_States
Var_Map m_Variables
CFSMState * m_CurrentState
string m_InitialState
bool m_Running


Constructor & Destructor Documentation

FSM::CFiniteStateMachine::CFiniteStateMachine (    ) 
 

Definition at line 51 of file FiniteStateMachine.cpp.

FSM::CFiniteStateMachine::~CFiniteStateMachine (    ) 
 

Definition at line 62 of file FiniteStateMachine.cpp.


Member Function Documentation

CFSMAction * FSM::CFiniteStateMachine::AddAction (  const char *    stateName,
int    index,
const char *    className
) 
 

Create a new action of the given class and add it to a transition.

Parameters:
stateName  the state id.
transition  the transition number of the state. First transition has the number 0.
className  the class name of the action.
Returns:
new created action or NULL if failed.

Definition at line 343 of file FiniteStateMachine.cpp.

References GetState(), and iRethrow.

CFSMCondition * FSM::CFiniteStateMachine::AddCondition (  const char *    stateName,
int    index,
const char *    className = "TestVariable"
) 
 

Create a new condition of the given class and add it to a transition.

Parameters:
stateName  the state id.
transition  the transition number of the state. First transition has the number 0.
className  the class name of the condition.
Returns:
new created condition or NULL if failed.

Definition at line 281 of file FiniteStateMachine.cpp.

References iRethrow.

CFSMAction * FSM::CFiniteStateMachine::AddEnterAction (  const char *    stateName,
const char *    className
) 
 

Create a new action to a state, that is executed each time the state is entered.

Definition at line 309 of file FiniteStateMachine.cpp.

References iRethrow.

CFSMAction * FSM::CFiniteStateMachine::AddLeaveAction (  const char *    stateName,
const char *    className
) 
 

Create a new action to a state, that is executed each time the state is leaved.

Definition at line 326 of file FiniteStateMachine.cpp.

References GetState(), and iRethrow.

CFSMTransition * FSM::CFiniteStateMachine::AddSimpleTransition (  const char *    stateName,
const char *    toStateName,
const char *    onEvent = "ANY"
) 
 

Definition at line 180 of file FiniteStateMachine.cpp.

References GetState(), and iRethrow.

CFSMState * FSM::CFiniteStateMachine::AddState (  const char *    stateName,
const char *    className = "State"
) 
 

Definition at line 71 of file FiniteStateMachine.cpp.

References iThrow(), and WARNING.

CFSMTransition * FSM::CFiniteStateMachine::AddTransition (  const char *    stateName,
const char *    onEvent = "ANY",
const char *    className = "SimpleTransition"
) 
 

Definition at line 163 of file FiniteStateMachine.cpp.

References iRethrow.

bool FSM::CFiniteStateMachine::AddVariable (  const char *    varName,
const int    initValue = 0
) 
 

Todo:
strng values for variables

Definition at line 371 of file FiniteStateMachine.cpp.

References iThrow(), FSM::VM_VT, and WARNING.

bool FSM::CFiniteStateMachine::Clear (    ) 
 

Definition at line 534 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), m_InitialState, m_Running, m_States, and m_Variables.

CFSMObject * FSM::CFiniteStateMachine::Create (  const char *    className ) 
 

create an object of certain class.

Definition at line 663 of file FiniteStateMachine.cpp.

References FSM::FSMObjectCreateMethod, iRethrow, iThrow(), and WARNING.

bool FSM::CFiniteStateMachine::DeleteState (  const char *    stateName ) 
 

Definition at line 136 of file FiniteStateMachine.cpp.

References DeleteState(), GetState(), and iRethrow.

bool FSM::CFiniteStateMachine::DeleteState (  CFSMState *    state ) 
 

Definition at line 108 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), m_CurrentState, m_Running, and m_States.

Referenced by DeleteState().

bool FSM::CFiniteStateMachine::DeleteTransition (  const char *    fromState,
int    index
) 
 

Delete the specified transition.

NULL if not found or error.

Parameters:
fromState  the name of the state
index  index-th transition. index==0 -> first transition

Definition at line 244 of file FiniteStateMachine.cpp.

References CRITICAL, GetState(), iRethrow, and iThrow().

bool FSM::CFiniteStateMachine::DeleteVariable (  const char *    varName ) 
 

Definition at line 382 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), and m_Variables.

CFSMState * FSM::CFiniteStateMachine::GetCurrentState (    )  const
 

Definition at line 529 of file FiniteStateMachine.cpp.

References m_CurrentState.

const char * FSM::CFiniteStateMachine::GetInitialState (    )  const
 

Definition at line 453 of file FiniteStateMachine.cpp.

References m_InitialState.

CFSMState * FSM::CFiniteStateMachine::GetState (  const char *    stateName )  const
 

Definition at line 89 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), and m_States.

Referenced by AddAction(), AddLeaveAction(), AddSimpleTransition(), DeleteState(), DeleteTransition(), and Start().

State_Map::const_iterator FSM::CFiniteStateMachine::GetStatesBegin (    )  const
 

Use (*iterator) to get the pointer to the state.

Use ++iterator to get the next iterator.

Returns:
the begin-iterator of the states container

Definition at line 150 of file FiniteStateMachine.cpp.

References m_States.

State_Map::const_iterator FSM::CFiniteStateMachine::GetStatesEnd (    )  const
 

Returns:
the end-iterator of the states container

Definition at line 155 of file FiniteStateMachine.cpp.

References m_States.

bool FSM::CFiniteStateMachine::GetVariable (  const char *    varName,
int &    value
)  const
 

Todo:
string values for variables

Definition at line 412 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), and m_Variables.

Var_Map::const_iterator FSM::CFiniteStateMachine::GetVarsBegin (    )  const
 

Returns:
the begin-iterator of the variables container

Definition at line 426 of file FiniteStateMachine.cpp.

References m_Variables.

Var_Map::const_iterator FSM::CFiniteStateMachine::GetVarsEnd (    )  const
 

Returns:
the end-iterator of the variables container

Definition at line 431 of file FiniteStateMachine.cpp.

References m_Variables.

bool FSM::CFiniteStateMachine::LoadClass (  const char *    className )  [protected]
 

Definition at line 704 of file FiniteStateMachine.cpp.

References iHandleLastError, and FSM::InitClassF.

bool FSM::CFiniteStateMachine::PopState (    ) 
 

Pop a state from the stack and switch to it.

Todo:
not implemented yet

Definition at line 631 of file FiniteStateMachine.cpp.

References iRethrow, and SwitchToState().

bool FSM::CFiniteStateMachine::ProcessEvent (  const char *    Event,
void *    a = NULL,
void *    b = NULL,
bool *    consumed = NULL
) 
 

Definition at line 492 of file FiniteStateMachine.cpp.

References CRITICAL, iRethrow, iThrow(), and m_CurrentState.

Referenced by SwitchToState().

bool FSM::CFiniteStateMachine::PushState (  CFSMState *    newState ) 
 

Set a new state and push it onto the stack.

Todo:
not implemented yet

Definition at line 618 of file FiniteStateMachine.cpp.

References iRethrow, and SwitchToState().

void FSM::CFiniteStateMachine::Register (  const char *    className,
FSMObjectCreateMethod    create
) 
 

Definition at line 649 of file FiniteStateMachine.cpp.

References iThrow(), and WARNING.

Referenced by RegisterBaseTypes().

void FSM::CFiniteStateMachine::RegisterBaseTypes (    )  [private]
 

Definition at line 572 of file FiniteStateMachine.cpp.

References Register().

bool FSM::CFiniteStateMachine::SetInitialState (  const char *    stateName ) 
 

Definition at line 439 of file FiniteStateMachine.cpp.

References iThrow(), and WARNING.

bool FSM::CFiniteStateMachine::SetVariable (  const char *    varName,
const int    value
) 
 

Todo:
string values for variables

Definition at line 398 of file FiniteStateMachine.cpp.

References CRITICAL, iThrow(), and m_Variables.

bool FSM::CFiniteStateMachine::Start (  const char *    stateName = 0 ) 
 

Definition at line 458 of file FiniteStateMachine.cpp.

References CRITICAL, GetState(), iRethrow, iThrow(), m_CurrentState, m_InitialState, and m_Running.

void FSM::CFiniteStateMachine::Stop (    ) 
 

Definition at line 482 of file FiniteStateMachine.cpp.

References m_CurrentState, and m_Running.

bool FSM::CFiniteStateMachine::SwitchToState (  CFSMState *    newState ) 
 

Set a new state.

Definition at line 583 of file FiniteStateMachine.cpp.

References CRITICAL, iRethrow, iThrow(), m_CurrentState, and ProcessEvent().

Referenced by PopState(), and PushState().


Member Data Documentation

FSMObjectCreate_Map FSM::CFiniteStateMachine::FSMObjectCreationMethods [private]
 

Definition at line 262 of file FiniteStateMachine.h.

CFSMState* FSM::CFiniteStateMachine::m_CurrentState [private]
 

Definition at line 265 of file FiniteStateMachine.h.

Referenced by DeleteState(), GetCurrentState(), ProcessEvent(), Start(), Stop(), and SwitchToState().

string FSM::CFiniteStateMachine::m_InitialState [private]
 

Definition at line 266 of file FiniteStateMachine.h.

Referenced by Clear(), GetInitialState(), and Start().

bool FSM::CFiniteStateMachine::m_Running [private]
 

Definition at line 267 of file FiniteStateMachine.h.

Referenced by Clear(), DeleteState(), Start(), and Stop().

State_Map FSM::CFiniteStateMachine::m_States [private]
 

Definition at line 263 of file FiniteStateMachine.h.

Referenced by Clear(), DeleteState(), GetState(), GetStatesBegin(), and GetStatesEnd().

Var_Map FSM::CFiniteStateMachine::m_Variables [private]
 

Definition at line 264 of file FiniteStateMachine.h.

Referenced by Clear(), DeleteVariable(), GetVariable(), GetVarsBegin(), GetVarsEnd(), and SetVariable().


The documentation for this class was generated from the following files:
© 2002 by C-LAB
generated by doxygen