AStarSearchManager< UserState > Class Template Reference

The AStarSearchManager is responsible for organizing a collection of AStarSearch's. More...

#include <AStarSearchManager.h>

List of all members.

Public Member Functions

 AStarSearchManager ()
 ~AStarSearchManager ()
AStarSearch< UserState > * createSearch (string name, UserState *startState, UserState *goalState)
void destroySearch (string name)
void destroyAllSearchs ()
bool isSearchSolved (string name)
bool isSearchUnsolvable (string name)
void advanceSearch (string searchName, int numSteps=1)
void advanceAllSearchs (int numSteps=1)
const WaypointList< UserState > * getSolutionPath (string name)
AStarSearch< UserState > * getSearch (string name)

Private Types

typedef map< string, AStarSearch<
UserState > * > 
SearchMap

Private Member Functions

void _advanceSearch (AStarSearch< UserState > *search, int numSteps)

Private Attributes

SearchMap mSearchList


Detailed Description

template<typename UserState>
class AStarSearchManager< UserState >

The AStarSearchManager is responsible for organizing a collection of AStarSearch's.

The manager is also responsible for updating each of the searches incrementally. This will allow searches to be spread across multiple frames to reduce the load. Partially solutions will be available from each search during any given frame.

Definition at line 27 of file AStarSearchManager.h.


Member Typedef Documentation

template<typename UserState>
typedef map< string, AStarSearch<UserState>* > AStarSearchManager< UserState >::SearchMap [private]

Definition at line 32 of file AStarSearchManager.h.


Constructor & Destructor Documentation

template<typename UserState>
AStarSearchManager< UserState >::AStarSearchManager (  )  [inline]

Definition at line 39 of file AStarSearchManager.h.

00040         {
00041                 mSearchList.clear ();
00042         }

template<typename UserState>
AStarSearchManager< UserState >::~AStarSearchManager (  )  [inline]

Definition at line 44 of file AStarSearchManager.h.

00045         {
00046                 destroyAllSearchs ();
00047         }


Member Function Documentation

template<typename UserState>
void AStarSearchManager< UserState >::_advanceSearch ( AStarSearch< UserState > *  search,
int  numSteps 
) [inline, private]

Definition at line 145 of file AStarSearchManager.h.

Referenced by AStarSearchManager< ASR::Level::LevelNode >::advanceAllSearchs(), and AStarSearchManager< ASR::Level::LevelNode >::advanceSearch().

00146         {
00147                 for ( int i = 0; i < numSteps; i++ )
00148                 {
00149                         // Only advance the solution if it is possible
00150                         // (either no path is possible or we found it)
00151                         if ( search->isRunnable() )
00152                                 search->advanceSearch ();
00153                         else
00154                                 break;
00155                 }
00156         }

template<typename UserState>
void AStarSearchManager< UserState >::advanceAllSearchs ( int  numSteps = 1  )  [inline]

Definition at line 113 of file AStarSearchManager.h.

00114         {
00115                 SearchMap::iterator iter = mSearchList.begin ();
00116 
00117                 while ( iter != mSearchList.end() )
00118                 {
00119                         _advanceSearch ( (*iter).second, numSteps );
00120                         iter++;
00121                 }
00122         }

template<typename UserState>
void AStarSearchManager< UserState >::advanceSearch ( string  searchName,
int  numSteps = 1 
) [inline]

Definition at line 106 of file AStarSearchManager.h.

00107         {
00108                 _advanceSearch ( _getSearch(searchName), numSteps );
00109         }

template<typename UserState>
AStarSearch<UserState>* AStarSearchManager< UserState >::createSearch ( string  name,
UserState *  startState,
UserState *  goalState 
) [inline]

Definition at line 52 of file AStarSearchManager.h.

00053         {
00054                 SearchMap::iterator iter = mSearchList.find ( name );
00055                 if ( iter != mSearchList.end() )
00056                         throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Search already exists", "AStarSearchManager::createSearch" );
00057 
00058                 AStarSearch<UserState>* newSearch = new AStarSearch<UserState> ();
00059                 newSearch->setStartState( startState, goalState );
00060                 mSearchList[name] = newSearch;
00061 
00062                 return newSearch;
00063         }

template<typename UserState>
void AStarSearchManager< UserState >::destroyAllSearchs (  )  [inline]

Definition at line 79 of file AStarSearchManager.h.

Referenced by AStarSearchManager< ASR::Level::LevelNode >::~AStarSearchManager().

00080         {
00081                 SearchMap::iterator iter = mSearchList.begin ();
00082                 while ( iter != mSearchList.end() )
00083                 {
00084                         delete (*iter).second;
00085                         iter++;
00086                 }
00087                 mSearchList.clear ();
00088         }

template<typename UserState>
void AStarSearchManager< UserState >::destroySearch ( string  name  )  [inline]

Definition at line 67 of file AStarSearchManager.h.

00068         {
00069                 SearchMap::iterator iter = mSearchList.find ( name );
00070                 if ( iter == mSearchList.end() )
00071                         throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Search doesn't exists", "AStarSearchManager::destroySearch" );
00072 
00073                 delete (*iter).second;
00074                 mSearchList.erase ( iter );
00075         }

template<typename UserState>
AStarSearch<UserState>* AStarSearchManager< UserState >::getSearch ( string  name  )  [inline]

Definition at line 132 of file AStarSearchManager.h.

00133         {
00134                 SearchMap::iterator iter = mSearchList.find ( name );
00135                 if ( iter == mSearchList.end() )
00136                         throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Search not found", "AStarSearchManager::getSearch" );
00137 
00138                 return (*iter).second;
00139         }

template<typename UserState>
const WaypointList<UserState>* AStarSearchManager< UserState >::getSolutionPath ( string  name  )  [inline]

Definition at line 126 of file AStarSearchManager.h.

00127         {
00128                 return _getSearch(name)->getSolutionPath();
00129         }

template<typename UserState>
bool AStarSearchManager< UserState >::isSearchSolved ( string  name  )  [inline]

Definition at line 92 of file AStarSearchManager.h.

00093         {
00094                 return ( _getSearch(name)->getSearchState() == AStarSearch<UserState>::SS_PATH_FOUND );
00095         }

template<typename UserState>
bool AStarSearchManager< UserState >::isSearchUnsolvable ( string  name  )  [inline]

Definition at line 99 of file AStarSearchManager.h.

00100         {
00101                 return ( _getSearch(name)->getSearchState() == AStarSearch<UserState>::SS_PATH_NOT_FOUND );
00102         }


Member Data Documentation

template<typename UserState>
SearchMap AStarSearchManager< UserState >::mSearchList [private]

Definition at line 33 of file AStarSearchManager.h.

Referenced by AStarSearchManager< ASR::Level::LevelNode >::advanceAllSearchs(), AStarSearchManager< ASR::Level::LevelNode >::AStarSearchManager(), AStarSearchManager< ASR::Level::LevelNode >::createSearch(), AStarSearchManager< ASR::Level::LevelNode >::destroyAllSearchs(), AStarSearchManager< ASR::Level::LevelNode >::destroySearch(), and AStarSearchManager< ASR::Level::LevelNode >::getSearch().


The documentation for this class was generated from the following file:
Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7