The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pathutils.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /** @file */
16 
17 #ifndef PATHUTILS_H_INCLUDED
18 #define PATHUTILS_H_INCLUDED
19 
20 #include "map/location.hpp"
21 
22 class gamemap;
23 
24 class xy_pred : public std::unary_function<map_location const&, bool>
25 {
26 public:
27  virtual bool operator()(map_location const&) const = 0;
28 protected:
29  virtual ~xy_pred() {}
30 };
31 
32 /**
33  * Function that will add to @a result all locations exactly @a radius tiles
34  * from @a center (or nothing if @a radius is not positive). @a result must be
35  * a std::vector of locations.
36  */
37 void get_tile_ring(const map_location& center, const int radius,
38  std::vector<map_location>& result);
39 
40 /**
41  * Function that will add to @a result all locations within @a radius tiles
42  * of @a center (excluding @a center itself). @a result must be a std::vector
43  * of locations.
44  */
45 void get_tiles_in_radius(const map_location& center, const int radius,
46  std::vector<map_location>& result);
47 
48 /**
49  * Function that will add to @a result all locations within @a radius tiles
50  * of @a center (including @a center itself). @a result must be a std::set
51  * of locations.
52  */
53 void get_tiles_radius(const map_location& center, size_t radius,
54  std::set<map_location>& result);
55 
56 /**
57  * Function that will add to @a result all elements of @a locs, plus all
58  * on-board locations that are within @a radius tiles of an element of locs.
59  * @a result must be a std::set of locations.
60  */
61 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
62  size_t radius, std::set<map_location>& result,
63  bool with_border=false);
64 
65 /**
66  * Function that will add to @a result all elements of @a locs, plus all
67  * on-board locations matching @a pred that are connected to elements of
68  * locs by a chain of at most @a radius tiles, each of which matches @a pred.
69  * @a result must be a std::set of locations.
70  */
71 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
72  size_t radius, std::set<map_location>& result,
73  bool with_border, const xy_pred &pred);
74 
75 #endif
76 
void get_tile_ring(const map_location &center, const int radius, std::vector< map_location > &result)
Function that will add to result all locations exactly radius tiles from center (or nothing if radius...
Definition: pathutils.cpp:32
GLuint64EXT * result
Definition: glew.h:10727
virtual bool operator()(map_location const &) const =0
Encapsulates the map of the game.
Definition: map.hpp:37
virtual ~xy_pred()
Definition: pathutils.hpp:29
void get_tiles_in_radius(const map_location &center, const int radius, std::vector< map_location > &result)
Function that will add to result all locations within radius tiles of center (excluding center itself...
Definition: pathutils.cpp:56
Encapsulates the map of the game.
Definition: location.hpp:38
void get_tiles_radius(const map_location &center, size_t radius, std::set< map_location > &result)
Function that will add to result all locations within radius tiles of center (including center itself...
Definition: pathutils.cpp:70