OpenTTD Source: src/station_layout_type.h Source File

OpenTTD Source 15.3

station_layout_type.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef STATION_LAYOUT_TYPE_H
11#define STATION_LAYOUT_TYPE_H
12
13#include "newgrf_station.h"
14#include "station_map.h"
15
16 class RailStationTileLayout {
17private:
18 std::span<const StationGfx> layout{};
19 uint platforms;
20 uint length;
21public:
22 RailStationTileLayout(const StationSpec *spec, uint8_t platforms, uint8_t length);
23
24 class Iterator {
25 const RailStationTileLayout &stl;
26 uint position = 0;
27 public:
28 using value_type = StationGfx;
29 using difference_type = std::ptrdiff_t;
30 using iterator_category = std::forward_iterator_tag;
31 using pointer = void;
32 using reference = void;
33
34 Iterator(const RailStationTileLayout &stl) : stl(stl) {}
35
36 bool operator==(const Iterator &rhs) const { return this->position == rhs.position; }
37 bool operator==(const std::default_sentinel_t &) const { return this->position == this->stl.platforms * this->stl.length; }
38
39 StationGfx operator*() const;
40
41 Iterator &operator++()
42 {
43 ++this->position;
44 return *this;
45 }
46
47 Iterator operator++(int)
48 {
49 Iterator result = *this;
50 ++*this;
51 return result;
52 }
53 };
54
55 Iterator begin() const { return Iterator(*this); }
56 std::default_sentinel_t end() const { return std::default_sentinel_t(); }
57};
58
59#endif /* STATION_LAYOUT_TYPE_H */
RailStationTileLayout::Iterator
Definition station_layout_type.h:24
RailStationTileLayout::Iterator::position
uint position
Position within iterator.
Definition station_layout_type.h:26
RailStationTileLayout::Iterator::stl
const RailStationTileLayout & stl
Station tile layout being iterated.
Definition station_layout_type.h:25
RailStationTileLayout
Definition station_layout_type.h:16
RailStationTileLayout::length
uint length
Length of platforms.
Definition station_layout_type.h:20
RailStationTileLayout::platforms
uint platforms
Number of platforms.
Definition station_layout_type.h:19
RailStationTileLayout::layout
std::span< const StationGfx > layout
Predefined tile layout.
Definition station_layout_type.h:18
StationGfx
uint8_t StationGfx
Copy from station_map.h.
Definition newgrf_airport.h:23
newgrf_station.h
Header file for NewGRF stations.
station_map.h
Maps accessors for stations.
StationSpec
Station specification.
Definition newgrf_station.h:123