00001 //----------------------------------------------------------------------------- 00002 /** @file environment.h 00003 Search environment. 00004 00005 $Id: environment_8h-source.html,v 1.1.1.1 2003/08/07 19:41:38 emarkus Exp $ 00006 $Source: /usr/cvsroot/www_pathfind/libpathfind/0.1.0/doc/environment_8h-source.html,v $ 00007 */ 00008 //----------------------------------------------------------------------------- 00009 00010 #ifndef PATHFIND_ENVIRONMENT_H 00011 #define PATHFIND_ENVIRONMENT_H 00012 00013 #include <exception> 00014 #include <string> 00015 #include <vector> 00016 00017 //----------------------------------------------------------------------------- 00018 00019 namespace PathFind 00020 { 00021 using namespace std; 00022 00023 /** Interface to search environment. */ 00024 class Environment 00025 { 00026 public: 00027 /** Information about a successor of a node in the environment. */ 00028 class Successor 00029 { 00030 public: 00031 Successor(); 00032 00033 Successor(int target, int cost) 00034 : m_target(target), m_cost(cost) 00035 { } 00036 00037 int m_target; 00038 00039 int m_cost; 00040 }; 00041 00042 virtual ~Environment(); 00043 00044 virtual int getHeuristic(int start, int target) const = 0; 00045 00046 virtual int getMaxCost() const = 0; 00047 00048 virtual int getMinCost() const = 0; 00049 00050 virtual int getNumberNodes() const = 0; 00051 00052 /** Generate successor nodes for the search. 00053 @param nodeId Current node 00054 @param lastNodeId 00055 Can be used to prune nodes, 00056 (is set to NO_NODE in Search::checkPathExists). 00057 @param result Resulting successors. 00058 Passed in as a reference to avoid dynamic memory allocation. 00059 The vector will be cleared and filled with the successors. 00060 */ 00061 virtual void getSuccessors(int nodeId, int lastNodeId, 00062 vector<Successor>& result) const = 0; 00063 00064 virtual bool isValidNodeId(int nodeId) const = 0; 00065 }; 00066 } 00067 00068 #endif