OpenTTD Source 20241224-master-gf74b0cf984
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

 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.
 
virtual std::unique_ptr< TileIteratorClone () const =0
 Allocate a new iterator that is a copy of this one.
 
bool operator== (const TileIterator &rhs) const
 Equality comparison.
 
bool operator!= (const TileIterator &rhs) const
 Inequality comparison.
 
bool operator== (const TileIndex &rhs) const
 Equality comparison.
 
bool operator!= (const TileIndex &rhs) const
 Inequality 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 105 of file tilearea_type.h.

Constructor & Destructor Documentation

◆ TileIterator()

TileIterator::TileIterator ( TileIndex  tile = INVALID_TILE)
inlineprotected

Initialise the iterator starting at this tile.

Parameters
tileThe tile we start iterating from.

Definition at line 113 of file tilearea_type.h.

Member Function Documentation

◆ Clone()

virtual std::unique_ptr< TileIterator > TileIterator::Clone ( ) const
pure virtual

Allocate a new iterator that is a copy of this one.

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

◆ 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 291 of file tilearea.cpp.

Referenced by CmdBuildCanal(), CmdBuildObjectArea(), CmdClearArea(), CmdConvertRail(), CmdLevelLand(), 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 124 of file tilearea_type.h.

References tile.

◆ operator!=() [1/2]

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

Inequality comparison.

Definition at line 173 of file tilearea_type.h.

◆ operator!=() [2/2]

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

Inequality comparison.

Definition at line 158 of file tilearea_type.h.

References tile.

◆ 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 133 of file tilearea_type.h.

References tile.

◆ operator++()

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

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

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

◆ operator==() [1/2]

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

Equality comparison.

Definition at line 166 of file tilearea_type.h.

◆ operator==() [2/2]

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

Equality comparison.

Definition at line 151 of file tilearea_type.h.

References tile.

Field Documentation

◆ tile


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