OpenTTD Source 20260911-master-gee2b2ac12a
TileIterator Class Referenceabstract

Base class for tile iterators. More...

#include <tilearea_type.h>

Inheritance diagram for TileIterator:
AirportTileTableIterator DiagonalTileIterator OrthogonalTileIterator AirportTileIterator BitmapTileIterator

Public Member Functions

virtual ~TileIterator ()=default
 Ensure the destructor of the sub classes are called as well.
 operator TileIndex () const
 Get the tile we are currently at.
TileIndex operator* () const
 Get the tile we are currently at.
virtual TileIteratoroperator++ ()=0
 Move ourselves to the next tile in the rectangle on the map.
bool operator== (const TileIterator &rhs) const
 Equality comparison.
bool operator== (const TileIndex &rhs) const
 Equality comparison.

Static Public Member Functions

static std::unique_ptr< TileIteratorCreate (TileIndex corner1, TileIndex corner2, bool diagonal)
 Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.

Protected Member Functions

 TileIterator (TileIndex tile=INVALID_TILE)
 Initialise the iterator starting at this tile.

Protected Attributes

TileIndex tile
 The current tile we are at.

Detailed Description

Base class for tile iterators.

Definition at line 122 of file tilearea_type.h.

Constructor & Destructor Documentation

◆ TileIterator()

Member Function Documentation

◆ Create()

std::unique_ptr< TileIterator > TileIterator::Create ( TileIndex corner1,
TileIndex corner2,
bool diagonal )
static

Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.

Parameters
corner1Tile from where to begin iterating.
corner2Tile where to end the iterating.
diagonalWhether to create a DiagonalTileIterator or OrthogonalTileIterator.
Returns
unique_ptr to the allocated TileIterator.

Definition at line 292 of file tilearea.cpp.

Referenced by CmdBuildCanal(), CmdBuildObjectArea(), CmdClearArea(), CmdConvertRail(), CmdConvertRoad(), CmdLevelLand(), CmdPlaceHouseArea(), and CmdPlantTree().

◆ operator TileIndex()

TileIterator::operator TileIndex ( ) const
inline

Get the tile we are currently at.

Returns
The tile we are at, or INVALID_TILE when we're done.

Definition at line 142 of file tilearea_type.h.

◆ operator*()

TileIndex TileIterator::operator* ( ) const
inline

Get the tile we are currently at.

Returns
The tile we are at, or INVALID_TILE when we're done.

Definition at line 151 of file tilearea_type.h.

◆ operator++()

virtual TileIterator & TileIterator::operator++ ( )
pure virtual

Move ourselves to the next tile in the rectangle on the map.

Returns
Reference to this iterator.

Implemented in AirportTileIterator, AirportTileTableIterator, BitmapTileIterator, DiagonalTileIterator, and OrthogonalTileIterator.

References TileIterator().

◆ operator==() [1/2]

bool TileIterator::operator== ( const TileIndex & rhs) const
inline

Equality comparison.

Parameters
rhsThe other iterator to compare to.
Returns
true iff the tile of both iterators is the same.

Definition at line 177 of file tilearea_type.h.

◆ operator==() [2/2]

bool TileIterator::operator== ( const TileIterator & rhs) const
inline

Equality comparison.

Parameters
rhsThe other iterator to compare to.
Returns
true iff the tile of both iterators is the same.

Definition at line 167 of file tilearea_type.h.

References tile, and TileIterator().

Field Documentation

◆ tile


The documentation for this class was generated from the following files: