IS3D::Fsa Class Reference

#include <Fsa.H>

List of all members.

Public Member Functions

 Fsa (const std::string &name)
virtual ~Fsa ()
bool addState (const std::string &stateName)
 Adds a state to the fsa.
bool addArc (const std::string &arcName, const int &fromState, const int &toState, const Array< std::string > &triggers)
bool addArc (const std::string &arcName, const std::string &fromState, const std::string &toState, const Array< std::string > &triggers)
template<class T>
void addStateEnterCallback (std::string stateName, T *thisPtr, void(T::*method)(EventRef))
template<class T>
void addStateExitCallback (std::string stateName, T *thisPtr, void(T::*method)(EventRef))
template<class T>
void addArcCallback (std::string arcName, T *thisPtr, void(T::*method)(EventRef))
void print ()
void setDebug (bool b)
std::string getCurrentState ()
void processEvent (EventRef event)
bool jumpToState (const std::string &toState)
std::string getName ()

Static Public Member Functions

static FsaRef fromQFSMFile (const std::string &filename)

Protected Member Functions

std::string stateName (int i)
int getIndexOfState (std::string stateName)
bool checkTriggerMatch (EventRef event, const std::string &triggerName)
void storeArcCallback (std::string arcName, EventCallbackFunctor *f)

Protected Attributes

Array< FsaState_states
std::string _name
int _curState
bool _debug


Constructor & Destructor Documentation

IS3D::Fsa::Fsa ( const std::string &  name  ) 

Constructs a new Fsa object with no states or arcs. Use the addState and addArc methods to design the Fsa.

virtual IS3D::Fsa::~Fsa (  )  [virtual]


Member Function Documentation

static FsaRef IS3D::Fsa::fromQFSMFile ( const std::string &  filename  )  [static]

Reads in a .fsm file created by the qfsm FSA drawing program freely available on sourceforge. Assumes that arc names are specified in the Input field of each Transition arc and that trigger events are in a space separated list entered into the arc's description field. State names are extracted from the state name field as you would expect.

bool IS3D::Fsa::addState ( const std::string &  stateName  ) 

Adds a state to the fsa.

bool IS3D::Fsa::addArc ( const std::string &  arcName,
const int &  fromState,
const int &  toState,
const Array< std::string > &  triggers 
)

Adds an arc connecting two states together to the fsa. If fromState and toState are the same, then no StateEnter/StateExit callbacks will be called when the arc is triggered and the Fsa's currentState will remain unchanged. Triggers is an array of event names that should trigger a transition on this arc.

bool IS3D::Fsa::addArc ( const std::string &  arcName,
const std::string &  fromState,
const std::string &  toState,
const Array< std::string > &  triggers 
)

Adds an arc connecting two states together to the fsa. If fromState and toState are the same, then no StateEnter/StateExit callbacks will be called when the arc is triggered and the Fsa's currentState will remain unchanged. Triggers is an array of event names that should trigger a transition on this arc.

template<class T>
void IS3D::Fsa::addStateEnterCallback ( std::string  stateName,
T *  thisPtr,
void(T::*)(EventRef method 
) [inline]

Specify a method to call whenever the state stateName is entered as a result of a transition along an arc in the Fsa. thisPtr must be a pointer to a class and method must be a method of that class that takes a single argument of type EventRef. Callbacks are called in this order: StateExit, Arc, then StateEnter.

References _states, and getIndexOfState().

template<class T>
void IS3D::Fsa::addStateExitCallback ( std::string  stateName,
T *  thisPtr,
void(T::*)(EventRef method 
) [inline]

Specify a method to call whenever the state stateName is exited as a result of a transition along an arc in the Fsa. thisPtr must be a pointer to a class and method must be a method of that class that takes a single argument of type EventRef. Callbacks are called in this order: StateExit, Arc, then StateEnter.

References _states, and getIndexOfState().

template<class T>
void IS3D::Fsa::addArcCallback ( std::string  arcName,
T *  thisPtr,
void(T::*)(EventRef method 
) [inline]

Specify a method to call whenever the arc is traversed in the Fsa. thisPtr must be a pointer to a class and method must be a method of that class that takes a single argument of type EventRef. Callbacks are called in this order: StateExit, Arc, then StateEnter.

References storeArcCallback().

void IS3D::Fsa::print (  ) 

void IS3D::Fsa::setDebug ( bool  b  )  [inline]

References _debug.

std::string IS3D::Fsa::getCurrentState (  )  [inline]

References _curState, and _states.

void IS3D::Fsa::processEvent ( EventRef  event  ) 

bool IS3D::Fsa::jumpToState ( const std::string &  toState  ) 

Use this with care, this causes the Fsa to jump directly to the named state. If the state belongs to this Fsa, the jump works and we return true, otherwise false is returned. This overrides the normal FSA behavior!!! Since you're not following one of the FSA's Arcs, no Arc callbacks are made. If toState is different than the FSA's current state then StateExit and StateEnter callbacks are called.

std::string IS3D::Fsa::getName (  )  [inline]

References _name.

Referenced by getIndexOfState().

std::string IS3D::Fsa::stateName ( int  i  )  [protected]

int IS3D::Fsa::getIndexOfState ( std::string  stateName  )  [inline, protected]

References _states, and getName().

Referenced by addStateEnterCallback(), and addStateExitCallback().

bool IS3D::Fsa::checkTriggerMatch ( EventRef  event,
const std::string &  triggerName 
) [protected]

void IS3D::Fsa::storeArcCallback ( std::string  arcName,
EventCallbackFunctor f 
) [protected]

Referenced by addArcCallback().


Member Data Documentation

Array<FsaState> IS3D::Fsa::_states [protected]

std::string IS3D::Fsa::_name [protected]

Referenced by getName().

int IS3D::Fsa::_curState [protected]

Referenced by getCurrentState().

bool IS3D::Fsa::_debug [protected]

Referenced by setDebug().


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

Generated on Wed Jan 26 06:31:20 2011 for IS3D by  doxygen 1.5.6