TileMatrix< T, N > Class Template Reference

A simple matrix that stores one value per N*N square of the map. More...

#include <tilematrix_type.hpp>

Public Member Functions

const TileAreaGetArea () const
 Get the total covered area.
void Add (TileIndex tile)
 Extend the coverage area to include a tile.
T * Get (TileIndex tile)
 Get the value associated to a tile index.
FORCEINLINE T & operator[] (TileIndex tile)
 Array access operator, see Get.

Static Public Member Functions

static TileArea GetAreaForTile (TileIndex tile, uint extend=0)
 Get the area of the matrix square that contains a specific tile.

Static Public Attributes

static const uint GRID = N

Private Member Functions

void AllocateStorage (TileIndex tile)

Private Attributes

TileArea area
 Area covered by the matrix.
T * data
 Pointer to data array.

Friends

struct SaveLoadGetTileMatrixDesc ()
void RealSave_TOWN (struct Town *t)
void Load_TOWN ()

Detailed Description

template<typename T, uint N>
class TileMatrix< T, N >

A simple matrix that stores one value per N*N square of the map.

Storage is only allocated for the part of the map that has values assigned.

Note:
No constructor is called for newly allocated values, you have to do this yourself if needed.
Template Parameters:
T The type of the stored items.
N Grid size.

Definition at line 29 of file tilematrix_type.hpp.


Member Function Documentation

template<typename T, uint N>
void TileMatrix< T, N >::Add ( TileIndex  tile  )  [inline]

Extend the coverage area to include a tile.

Parameters:
tile The tile to include.

Definition at line 119 of file tilematrix_type.hpp.

Referenced by TileMatrix< uint32, 4 >::Get().

template<typename T, uint N>
T* TileMatrix< T, N >::Get ( TileIndex  tile  )  [inline]

Get the value associated to a tile index.

Parameters:
tile The tile to get the value for.
Returns:
Pointer to the value.

Definition at line 131 of file tilematrix_type.hpp.

Referenced by TileMatrix< uint32, 4 >::operator[]().

template<typename T, uint N>
const TileArea& TileMatrix< T, N >::GetArea (  )  const [inline]

Get the total covered area.

Returns:
The area covered by the matrix.

Definition at line 84 of file tilematrix_type.hpp.

Referenced by Town::GetTileForDestination(), UpdateTownCargos(), and UpdateTownCargoTotal().

template<typename T, uint N>
static TileArea TileMatrix< T, N >::GetAreaForTile ( TileIndex  tile,
uint  extend = 0 
) [inline, static]

Get the area of the matrix square that contains a specific tile.

Parameters:
The tile to get the map area for.
extend Extend the area by this many squares on all sides.
Returns:
Tile area containing the tile.

Definition at line 95 of file tilematrix_type.hpp.

template<typename T, uint N>
FORCEINLINE T& TileMatrix< T, N >::operator[] ( TileIndex  tile  )  [inline]

Array access operator, see Get.

Definition at line 143 of file tilematrix_type.hpp.


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

Generated on Mon May 9 05:20:38 2011 for OpenTTD by  doxygen 1.6.1