FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
routepathersearch.h
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_PATHFINDER_ROUTEPATHERSEARCH
23 #define FIFE_PATHFINDER_ROUTEPATHERSEARCH
24 
25 // Standard C++ library includes
26 
27 // 3rd party library includes
28 
29 // FIFE includes
30 // These includes are split up in two parts, separated by one empty line
31 // First block: files included from the FIFE root src directory
32 // Second block: files included from the same folder
33 #include "util/structures/priorityqueue.h"
34 
35 namespace FIFE {
36 
37  class Map;
38  class SearchSpace;
39  class Heuristic;
40 
46  public:
47  RoutePatherSearch(const int32_t session_id, const Location& from, const Location& to, SearchSpace* searchSpace);
48 
49  typedef std::list<Location> Path;
53  enum SearchStatus {
54  search_status_failed,
55  search_status_complete,
56  search_status_incomplete
57  };
58 
59  virtual void updateSearch();
60 
61  virtual Path calcPath();
62 
67  int32_t getSessionId() const {
68  return m_sessionId;
69  }
70 
75  SearchSpace* getSearchSpace() const {
76  return m_searchspace;
77  }
78 
83  int32_t getSearchStatus() const {
84  return m_status;
85  }
86 
87  protected:
92  void setSearchStatus(const SearchStatus status) {
93  m_status = status;
94  }
95 
96  private:
97  //A location object representing where the search started.
98  Location m_to;
99 
100  //A location object representing where the search ended.
101  Location m_from;
102 
103  //An integer containing the session id for this search.
104  int32_t m_sessionId;
105 
106  //A pointer to the pather that owns this search.
107  SearchSpace* m_searchspace;
108 
109  //An enumeration of the searches current status.
110  SearchStatus m_status;
111 
112  //The start coordinate as an int32_t.
113  int32_t m_startCoordInt;
114 
115  //The destination coordinate as an int32_t.
116  int32_t m_destCoordInt;
117 
118  //The next coordinate to check out.
119  int32_t m_next;
120 
121  //The class to use to calculate the heuristic value.
122  Heuristic* m_heuristic;
123 
124  //The shortest path tree.
125  std::vector<int32_t> m_spt;
126 
127  //The search frontier.
128  std::vector<int32_t> m_sf;
129 
130  //A table to hold the costs.
131  std::vector<double> m_gCosts;
132 
133  //priority queue to hold nodes on the sf in order.
134  PriorityQueue<int32_t, double> m_sortedfrontier;
135  };
136 }
137 #endif
void setSearchStatus(const SearchStatus status)
int32_t getSearchStatus() const
int32_t getSessionId() const
SearchSpace * getSearchSpace() const