Debian Codegraph @

engine/core/pathfinder/routepather/singlelayersearch.h

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the FIFE team *
3 * http://www.fifengine.net *
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_SINGLELAYERSEARCH
23 #define FIFE_PATHFINDER_SINGLELAYERSEARCH
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 #include "routepathersearch.h"
36
37 namespace FIFE {
38
39 class CellCache;
40 class Route;
41
42 /** SingleLayerSearch using A*
43 */
44 class SingleLayerSearch: public RoutePatherSearch {
45 public:
46 /** Constructor
47 *
48 * @param route A pointer to the route for which a path should be searched.
49 * @param sessionId A integer containing the session id for this search.
50 */
51 SingleLayerSearch(Route* route, const int32_t sessionId);
52
53 /** Destructor
54 */
55 ~SingleLayerSearch();
56
57 /** Updates the search.
58 *
59 * Each update checks all neighbors of the last checked coordinate and selects the most favorable.
60 */
61 void updateSearch();
62
63 /** Calculates final path.
64 *
65 * If the search is successful then a path is created.
66 */
67 void calcPath();
68
69 private:
70 //! A location object representing where the search started.
71 Location m_to;
72
73 //! A location object representing where the search ended.
74 Location m_from;
75
76 //! A pointer to the CellCache.
77 CellCache* m_cellCache;
78
79 //! The start coordinate as an int32_t.
80 int32_t m_startCoordInt;
81
82 //! The destination coordinate as an int32_t.
83 int32_t m_destCoordInt;
84
85 //! The next coordinate to check out.
86 int32_t m_next;
87
88 //! The shortest path tree.
89 std::vector<int32_t> m_spt;
90
91 //! The search frontier.
92 std::vector<int32_t> m_sf;
93
94 //! A table to hold the costs.
95 std::vector<double> m_gCosts;
96
97 //! Priority queue to hold nodes on the sf in order.
98 PriorityQueue<int32_t, double> m_sortedfrontier;
99 };
100 }
101 #endif