dtAI::FSM Class Reference

A class which represents a Finite State Machine. More...

#include <fsm.h>

List of all members.

Public Types

typedef dtUtil::ObjectFactory
< std::string, NPCState
FactoryType
typedef dtCore::RefPtr< NPCStateStatePtr
typedef std::set< StatePtr,
RefPtrWithNameCompare
< StatePtr > > 
StateSet
typedef std::pair< const
NPCEvent *, StatePtr
EventStatePtrPair
typedef std::map
< EventStatePtrPair, StatePtr,
PairRefPtrWithNameCompare
< EventStatePtrPair > > 
TransitionMap

Public Member Functions

 FSM ()
 FSM (FactoryType *pFactory)
virtual ~FSM ()
virtual void Update (double dt)
NPCStateAddState (const NPCState::Type *state)
void AddTransition (const NPCEvent *eventType, const NPCState *from, const NPCState *to)
void AddTransition (const NPCEvent *eventType, const NPCState::Type *from, const NPCState::Type *to)
NPCStateGetCurrentState ()
NPCStateGetState (const NPCState::Type *pStateType)
void MakeCurrent (const NPCState::Type *state)
 Forces the given State to now be the 'current' State.
bool HandleEvent (const NPCEvent *pEvent)
 pass all events through this function

Protected Attributes

dtCore::RefPtr< NPCStatemCurrentState

Classes

struct  PairRefPtrWithNameCompare
 Compares a pair, but assumes the 2nd type is a referenced pointer. More...
struct  RefPtrWithNameCompare
 Compares 2 referenced pointer objects by pointer value and name. More...


Detailed Description

A class which represents a Finite State Machine.

Member Typedef Documentation

typedef dtUtil::ObjectFactory<std::string, NPCState> dtAI::FSM::FactoryType

typedef dtCore::RefPtr<NPCState> dtAI::FSM::StatePtr

typedef std::set< StatePtr, RefPtrWithNameCompare<StatePtr> > dtAI::FSM::StateSet

typedef std::pair< const NPCEvent*, StatePtr > dtAI::FSM::EventStatePtrPair

typedef std::map< EventStatePtrPair, StatePtr, PairRefPtrWithNameCompare<EventStatePtrPair> > dtAI::FSM::TransitionMap


Constructor & Destructor Documentation

dtAI::FSM::FSM (  ) 

dtAI::FSM::FSM ( FactoryType pFactory  ) 

dtAI::FSM::~FSM (  )  [virtual]


Member Function Documentation

void dtAI::FSM::Update ( double  dt  )  [virtual]

NPCState * dtAI::FSM::AddState ( const NPCState::Type state  ) 

void dtAI::FSM::AddTransition ( const NPCEvent eventType,
const NPCState from,
const NPCState to 
) [inline]

void dtAI::FSM::AddTransition ( const NPCEvent eventType,
const NPCState::Type from,
const NPCState::Type to 
)

NPCState * dtAI::FSM::GetCurrentState (  ) 

NPCState * dtAI::FSM::GetState ( const NPCState::Type pStateType  ) 

void dtAI::FSM::MakeCurrent ( const NPCState::Type pStateType  ) 

Forces the given State to now be the 'current' State.

bool dtAI::FSM::HandleEvent ( const NPCEvent pEvent  ) 

pass all events through this function

Returns:
whether or not the event caused a transition


Member Data Documentation

dtCore::RefPtr<NPCState> dtAI::FSM::mCurrentState [protected]


http://www.delta3d.org
2.0.0 generated 14 Feb 2008