A shared storage to store tiles of the same kind. More...
#include <TileStorage.h>
Classes | |
class | Slot |
A slot managed by a TileStorage. More... | |
Public Member Functions | |
TileStorage (int tileSize, int capacity) | |
Creates a new TileStorage. | |
virtual | ~TileStorage () |
Deletes this TileStorage. | |
Slot * | newSlot () |
Returns a free slot in the pool of slots managed by this TileStorage. | |
void | deleteSlot (Slot *t) |
Notifies this storage that the given slot is free. | |
int | getTileSize () |
Returns the size of each tile. | |
int | getCapacity () |
Returns the total number of slots managed by this TileStorage. | |
int | getFreeSlots () |
Returns the number of slots in this TileStorage that are currently unused. | |
Protected Member Functions | |
TileStorage () | |
Creates a new uninitialized TileStorage. | |
void | init (int tileSize, int capacity) |
Initializes this TileStorage. | |
Protected Attributes | |
int | tileSize |
The size of each tile. | |
int | capacity |
The total number of slots managed by this TileStorage. | |
list< Slot * > | freeSlots |
The currently free slots. |
A shared storage to store tiles of the same kind.
This abstract class defines the behavior of tile storages but does not provide any storage itself. The slots managed by a tile storage can be used to store any tile identified by its (level,tx,ty) coordinates. This means that a TileStorage::Slot can store the data of some tile at some moment, and then be reused to store the data of tile some time later. The mapping between tiles and TileStorage::Slot is not managed by the TileStorage itself, but by a TileCache. A TileStorage just keeps track of which slots in the pool are currently associated with a tile (i.e., store the data of a tile), and which are not. The first ones are called allocated slots, the others free slots.
proland::TileStorage::TileStorage | ( | int | tileSize, | |
int | capacity | |||
) |
Creates a new TileStorage.
tileSize | the size of each tile. For tiles made of raster data, this size is the tile width in pixels (the tile height is supposed equal to the tile width). | |
capacity | the number of slots allocated and managed by this tile storage. This capacity is fixed and cannot change with time. |
virtual proland::TileStorage::~TileStorage | ( | ) | [virtual] |
Deletes this TileStorage.
This deletes the data associated with all the slots managed by this tile storage.
proland::TileStorage::TileStorage | ( | ) | [protected] |
Creates a new uninitialized TileStorage.
void proland::TileStorage::deleteSlot | ( | Slot * | t | ) |
Notifies this storage that the given slot is free.
The given slot can then be allocated to store a new tile, i.e., it can be returned by a subsequent call to newSlot.
t | a slot that is no longer in use. |
int proland::TileStorage::getCapacity | ( | ) |
Returns the total number of slots managed by this TileStorage.
This includes both unused and used tiles.
int proland::TileStorage::getFreeSlots | ( | ) |
Returns the number of slots in this TileStorage that are currently unused.
int proland::TileStorage::getTileSize | ( | ) |
Returns the size of each tile.
For tiles made of raster data, this size is the tile width in pixels (the tile height is supposed equal to the tile width).
void proland::TileStorage::init | ( | int | tileSize, | |
int | capacity | |||
) | [protected] |
Initializes this TileStorage.
tileSize | the size of each tile. For tiles made of raster data, this size is the tile width in pixels (the tile height is supposed equal to the tile width). | |
capacity | the number of slots allocated and managed by this tile storage. This capacity is fixed and cannot change with time. |
Slot* proland::TileStorage::newSlot | ( | ) |
Returns a free slot in the pool of slots managed by this TileStorage.
int proland::TileStorage::capacity [protected] |
The total number of slots managed by this TileStorage.
This includes both unused and used tiles.
list<Slot*> proland::TileStorage::freeSlots [protected] |
The currently free slots.
int proland::TileStorage::tileSize [protected] |
The size of each tile.
For tiles made of raster data, this size is the tile width in pixels (the tile height is supposed equal to the tile width).