#include <AStarSearchManager.h>
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 |
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.
typedef map< string, AStarSearch<UserState>* > AStarSearchManager< UserState >::SearchMap [private] |
Definition at line 32 of file AStarSearchManager.h.
AStarSearchManager< UserState >::AStarSearchManager | ( | ) | [inline] |
AStarSearchManager< UserState >::~AStarSearchManager | ( | ) | [inline] |
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 }
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 }
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 }
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 }
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 }
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 }
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 }
const WaypointList<UserState>* AStarSearchManager< UserState >::getSolutionPath | ( | string | name | ) | [inline] |
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 }
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 }
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().