Debian Codegraph @

src/common/mapbase.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2015 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef MAPBASE_HPP
17 #define MAPBASE_HPP
18
19 #include "tracktilebase.hpp"
20 #include <vector>
21
22 //! Base class for the tile matrix used by TrackData.
23 class MapBase
24 {
25 public:
26 //! Constructor.
27 MapBase(size_t cols, size_t rows);
28
29 MapBase(const MapBase & other) = delete;
30
31 MapBase & operator=(const MapBase & other) = delete;
32
33 enum class InsertDirection
34 {
35 Before,
36 After
37 };
38
39 //! Destructor.
40 virtual ~MapBase();
41
42 //! Get column count
43 size_t cols() const;
44
45 //! Get row count
46 size_t rows() const;
47
48 //! Resize the map.
49 virtual void resize(size_t newCols, size_t newRows);
50
51 /*! Set given tile to given coordinates.
52 * Returns false if impossible coordinates. */
53 bool setTile(size_t x, size_t y, TrackTileBasePtr tile);
54
55 /*! Get tile at given coordinates.
56 * Returns nullptr if no tile set or impossible coordinates. */
57 TrackTileBasePtr getTile(size_t x, size_t y) const;
58
59 //! Insert column after given index.
60 virtual size_t insertColumn(size_t at, InsertDirection insertDirection);
61
62 //! Delete column at given index. Return deleted tiles.
63 virtual std::vector<TrackTileBasePtr> deleteColumn(size_t at);
64
65 //! Insert row after given index.
66 virtual size_t insertRow(size_t at, InsertDirection insertDirection);
67
68 //! Delete row at given index. Return deleted tiles.
69 virtual std::vector<TrackTileBasePtr> deleteRow(size_t at);
70
71 private:
72 size_t m_cols, m_rows;
73
74 typedef std::vector<TrackTileBasePtr> TrackTileRow;
75 typedef std::vector<TrackTileRow> TrackTileMap;
76 TrackTileMap m_map;
77 };
78
79 #endif // MAPBASE_HPP