Main   Class Hierarchy   Classes   Compound List   Files   Compound Members   File Members   Pages  

search.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 /** @file search.h
00003     Abstract search engine.
00004 
00005     $Id: search_8h-source.html,v 1.1.1.1 2003/08/07 19:41:39 emarkus Exp $
00006     $Source: /usr/cvsroot/www_pathfind/libpathfind/0.1.0/doc/search_8h-source.html,v $
00007 */
00008 //-----------------------------------------------------------------------------
00009 
00010 #ifndef PATHFIND_SEARCH_H
00011 #define PATHFIND_SEARCH_H
00012 
00013 #include <list>
00014 #include <queue>
00015 #include "environment.h"
00016 #include "statistics.h"
00017 
00018 //-----------------------------------------------------------------------------
00019 
00020 namespace PathFind
00021 {
00022     using namespace std;
00023 
00024     static const int NO_NODE = -1;
00025 
00026     /** Abstract search engine. */
00027     class Search
00028     {
00029     public:
00030         Search();
00031 
00032         virtual ~Search();
00033 
00034         /** Create a StatisticsCollection.
00035             Contains Statistics instances for all values tracked.
00036             Useful for keeping accumulated statistics by creating
00037             the collection and merging the statistics of a search
00038             as returned by getStatistics().
00039         */
00040         virtual StatisticsCollection createStatistics() = 0;
00041 
00042         /** Find a path.
00043             @return false, if search was aborted due to node limit.
00044         */
00045         virtual bool findPath(const Environment& env, int start,
00046                               int target) = 0;
00047 
00048         long long int getNodesLimit() const
00049         {
00050             return m_nodesLimit;
00051         }
00052 
00053         virtual const vector<int>& getPath() const = 0;
00054 
00055         /** Get a vector with char labels for each visited node.
00056             Space char means not visited, otherwise the char
00057             can have different values and meanings depending on
00058             the concrete search engine.
00059         */
00060         virtual const vector<char>& getVisitedNodes() const = 0;
00061 
00062         /** Get statistics of last search. */
00063         virtual const StatisticsCollection& getStatistics() const = 0;
00064 
00065         /** Set nodes limit for search engine.
00066             The default is -1 and means unlimited search.
00067             The nodes limit is a hint only, the search engine
00068             may ignore it.
00069             
00070         */
00071         void setNodesLimit(long long int nodesLimit)
00072         {
00073             m_nodesLimit = nodesLimit;
00074         }
00075 
00076 
00077     public:
00078         long long int m_nodesLimit;
00079     };
00080 }
00081 
00082 //-----------------------------------------------------------------------------
00083 
00084 #endif


Generated on Thu Aug 7 13:04:49 2003 by Doxygen1.3.1