#include <Fsa.H>
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 |
IS3D::Fsa::Fsa | ( | const std::string & | name | ) |
virtual IS3D::Fsa::~Fsa | ( | ) | [virtual] |
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.
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().
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().
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.
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] |
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().
Array<FsaState> IS3D::Fsa::_states [protected] |
Referenced by addStateEnterCallback(), addStateExitCallback(), getCurrentState(), and getIndexOfState().
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().