Mercurial > fife-parpg
comparison engine/core/pathfinder/search.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
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 modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program 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 * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_PATHFINDER_SEARCH | |
23 #define FIFE_PATHFINDER_SEARCH | |
24 | |
25 // Standard C++ library includes | |
26 #include <vector> | |
27 | |
28 // 3rd party library includes | |
29 | |
30 // FIFE includes | |
31 // These includes are split up in two parts, separated by one empty line | |
32 // First block: files included from the FIFE root src directory | |
33 // Second block: files included from the same folder | |
34 #include "model/structures/location.h" | |
35 | |
36 namespace FIFE { | |
37 | |
38 class SearchSpace; | |
39 | |
40 /** A base class that all searches must derive from. | |
41 * | |
42 */ | |
43 class Search { | |
44 public: | |
45 typedef std::list<Location> Path; | |
46 /** An enumeration of the different status the search can be in. | |
47 * | |
48 */ | |
49 enum SearchStatus { | |
50 search_status_failed, | |
51 search_status_complete, | |
52 search_status_incomplete | |
53 }; | |
54 /** Constructor. | |
55 * | |
56 * @param session_id The id in the pather that references this session. | |
57 * @param from The location where the search should be started from. | |
58 * @param to The location where the search should finish. | |
59 * @param pather A pointer to the pather controlling this session. | |
60 */ | |
61 Search(const int session_id, const Location& from, const Location& to, SearchSpace* searchspace) | |
62 : m_to(to), m_from(from), m_sessionId(session_id), m_searchspace(searchspace), | |
63 m_status(search_status_incomplete) { | |
64 } | |
65 | |
66 /** Destructor. | |
67 * | |
68 */ | |
69 virtual ~Search() {} | |
70 | |
71 /** Retrieves the session id. | |
72 * | |
73 * @return The searches session id in the pather. | |
74 */ | |
75 int getSessionId() const { | |
76 return m_sessionId; | |
77 } | |
78 | |
79 /** Retrieves the pather. | |
80 * | |
81 * @return A pointer to the abstract pather which | |
82 */ | |
83 SearchSpace* getSearchSpace() const { | |
84 return m_searchspace; | |
85 } | |
86 | |
87 /** A small function which returns the current status of the search. | |
88 * | |
89 * @return An integer value representing the status, which is enumerated by this class. | |
90 */ | |
91 int getSearchStatus() const { | |
92 return m_status; | |
93 } | |
94 | |
95 | |
96 /** Updates the search and returns the next part of the path or the entire path if the | |
97 * algorithm is offline. | |
98 * | |
99 * @return A vector of Location objects representing the path. | |
100 */ | |
101 virtual void updateSearch() = 0; | |
102 | |
103 /** Calculates a path generated by a search. | |
104 * | |
105 * Creates a path and returns it. | |
106 */ | |
107 virtual Path calcPath() = 0; | |
108 protected: | |
109 | |
110 /** Sets the current status of the search. | |
111 * | |
112 * @param status The status to set. | |
113 */ | |
114 void setSearchStatus(const SearchStatus status) { | |
115 m_status = status; | |
116 } | |
117 | |
118 //A location object representing where the search started. | |
119 Location m_to; | |
120 | |
121 //A location object representing where the search ended. | |
122 Location m_from; | |
123 | |
124 //An integer containing the session id for this search. | |
125 int m_sessionId; | |
126 | |
127 //A pointer to the pather that owns this search. | |
128 SearchSpace* m_searchspace; | |
129 | |
130 //An enumeration of the searches current status. | |
131 SearchStatus m_status; | |
132 }; | |
133 | |
134 } | |
135 | |
136 #endif |