Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE > Class Template Reference

Generic A * pathfinder with caching. More...

#include <pathfinderastargenericcached.h>

List of all members.

Classes

class  AddNeighborFunctor
 Functor passed to the IGetNeighbors functor. More...
class  IGetNeighbors
 Functor interface for getting the neighbor states of a given state. More...

Public Member Functions

const PathResult FindPath (const NODETYPE &start, const long startindex, const NODETYPE &goal, std::vector< NODETYPE > &finalpath, DESTCOST &destinationcost, GETNEIGHBORS &getneighbors)
 Finds a path between two states.
void InitializeStep (const NODETYPE &start, const long startindex, const NODETYPE &goal, DESTCOST &destcost, GETNEIGHBORS &getneighbors)
 Initializes the path finder for single stepping.
const PathResult Step ()
 Single steps the path finder.
void GetPath (std::vector< NODETYPE > &path)
 Gets the current path.
void ClearCache ()
 Clears the cache.
void ClearCacheIndex (const long index)
 Clears one cache element.


Detailed Description

template<class NODETYPE, class DESTCOST, class GETNEIGHBORS, class COSTTYPE = double>
class Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >

Generic A * pathfinder with caching.

This is a generic A * path finding class. The movement costs from state to state are cached to maximize performance. If state change costs can change frequently, you should use the non-cached version of this class.

In order to cache the state change costs, each state requires a unique index with a value >= 0.

Template Parameters:
NODETYPE Defines a state of the pathfinder, typically an x,y coordinate for tile based games
DESTCOST A functor implementing IDestinationCost
GETNEIGHBORS A functor implementing IGetNeighbors
COSTTYPE The cost type of moving from state to state, typically a float or double

Member Function Documentation

template<class NODETYPE , class DESTCOST , class GETNEIGHBORS , class COSTTYPE >
void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::ClearCacheIndex ( const long  index  )  [inline]

Clears one cache element.

Call this method when the cost of reaching a state has changed.

Parameters:
index The index of the state to clear

template<class NODETYPE , class DESTCOST , class GETNEIGHBORS , class COSTTYPE >
const PathResult Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::FindPath ( const NODETYPE &  start,
const long  startindex,
const NODETYPE &  goal,
std::vector< NODETYPE > &  finalpath,
DESTCOST &  destinationcost,
GETNEIGHBORS &  getneighbors 
) [inline]

Finds a path between two states.

This method will block until a path from the start to the goal is found or all reachable nodes have been checked without finding a path.

Parameters:
start The starting state
startindex The index of the starting state
goal The goal state
[out] finalpath A vector of states from the starting state to the goal state
destinationcost User supplied functor implementing IDestinationCost
getneighbors User supplied functor implementing IGetNeighbors
Returns:
PATH_FOUND or PATH_NOTFOUND

template<class NODETYPE , class DESTCOST , class GETNEIGHBORS , class COSTTYPE >
void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::GetPath ( std::vector< NODETYPE > &  path  )  [inline]

Gets the current path.

This is usually called to get a complete path after Step returns PATH_FOUND, but it may be called at any step of the path finding, wheter a complete path has been found or not.

Parameters:
[out] path A vector of states from the starting state to the current state

template<class NODETYPE , class DESTCOST , class GETNEIGHBORS , class COSTTYPE >
void Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::InitializeStep ( const NODETYPE &  start,
const long  startindex,
const NODETYPE &  goal,
DESTCOST &  destcost,
GETNEIGHBORS &  getneighbors 
) [inline]

Initializes the path finder for single stepping.

Parameters:
start The starting state
startindex The index of the starting state
goal The goal state
destcost User supplied functor IDestinationCost
getneighbors User supplied functor IGetNeighbors

template<class NODETYPE , class DESTCOST , class GETNEIGHBORS , class COSTTYPE >
const PathResult Pathfinder::AStarGenericCached< NODETYPE, DESTCOST, GETNEIGHBORS, COSTTYPE >::Step (  )  [inline]

Single steps the path finder.

Returns:
PATH_FOUND, PATH_NOTFOUND, or PATH_SEARCHING if the user should call Step again to continue searching


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

Generated on Mon Dec 29 19:08:11 2008 by  doxygen 1.5.7.1