alaCarte Maps
Renderer for OpenStreetMap tiles
Cache Class Reference

#include <cache.hpp>

Public Types

typedef std::list< shared_ptr< Tile > > TileList
 A list that will store the last recently used tiles. More...
 
typedef std::pair< shared_ptr< Tile >, TileList::iterator > CacheElement
 An element stored in the cache. More...
 
typedef boost::unordered_map< TileIdentifier, CacheElementCacheOfOneStylesheet
 HashMap with TileIdentifier as key and shared_ptr to Tiles as value. More...
 
typedef boost::unordered_map< string, shared_ptr< CacheOfOneStylesheet > > CacheContainer
 HashMap with path to MapCSS as key and shared_ptr to CacheOfOneStylesheet as value. More...
 

Public Member Functions

 Cache (const shared_ptr< Configuration > &config)
 This file is part of alaCarte. More...
 
TESTABLE shared_ptr< TilegetTile (const shared_ptr< TileIdentifier > &tl)
 Gets a Tile where the image data can be stored. More...
 
TESTABLE shared_ptr< TilegetDefaultTile ()
 Get the default tile used for error and such. More...
 
TESTABLE void deleteTiles (const string path)
 Deletes all cached Tiles of the Stylesheet with the given path. More...
 

Private Member Functions

void readFile (const Tile::ImageType &image, const boost::filesystem::path &filename)
 
void writeFile (shared_ptr< Tile > tile, const boost::filesystem::path &filename)
 
const boost::filesystem::path getTilePath (const shared_ptr< TileIdentifier > &ti)
 

Private Attributes

shared_ptr< ConfigurationConfig
 
boost::mutex GlobalCacheLock
 
CacheContainer AllCaches
 
TileList RecentlyUsedList
 
shared_ptr< TileDefaultTile
 

Detailed Description

Definition at line 38 of file cache.hpp.

Member Typedef Documentation

typedef boost::unordered_map<string, shared_ptr<CacheOfOneStylesheet> > Cache::CacheContainer

HashMap with path to MapCSS as key and shared_ptr to CacheOfOneStylesheet as value.

Definition at line 60 of file cache.hpp.

typedef std::pair<shared_ptr<Tile>, TileList::iterator> Cache::CacheElement

An element stored in the cache.

Consists of shared_ptr to the Tile and an iterator pointing to the element in the least recently used list.

Definition at line 50 of file cache.hpp.

HashMap with TileIdentifier as key and shared_ptr to Tiles as value.

Definition at line 55 of file cache.hpp.

typedef std::list<shared_ptr<Tile> > Cache::TileList

A list that will store the last recently used tiles.

Definition at line 45 of file cache.hpp.

Constructor & Destructor Documentation

Cache::Cache ( const shared_ptr< Configuration > &  config)

This file is part of alaCarte.

alaCarte is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

alaCarte 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. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with alaCarte. If not, see http://www.gnu.org/licenses/.

Copyright alaCarte 2012-2013 Simon Dreher, Florian Jacob, Tobias Kahlert, Patrick Niklaus, Bernhard Scheirle, Lisa Winter Maintainer: Simon Dreher

Definition at line 36 of file cache.cpp.

Member Function Documentation

void Cache::deleteTiles ( const string  path)

Deletes all cached Tiles of the Stylesheet with the given path.

Parameters
pathThe path to the stylesheet.

Definition at line 204 of file cache.cpp.

shared_ptr< Tile > Cache::getDefaultTile ( )

Get the default tile used for error and such.

Returns
shared_ptr to the default Tile with loaded png (image can be null if file not found).

Definition at line 182 of file cache.cpp.

shared_ptr< Tile > Cache::getTile ( const shared_ptr< TileIdentifier > &  ti)

Gets a Tile where the image data can be stored.

If the Tile isn't cached a new Tile is returned.

Parameters
tiA shared pointer to the TileIdentifier of the Tile.

Definition at line 97 of file cache.cpp.

const boost::filesystem::path Cache::getTilePath ( const shared_ptr< TileIdentifier > &  ti)
private

Definition at line 80 of file cache.cpp.

void Cache::readFile ( const Tile::ImageType image,
const boost::filesystem::path &  filename 
)
private

Definition at line 44 of file cache.cpp.

void Cache::writeFile ( shared_ptr< Tile tile,
const boost::filesystem::path &  filename 
)
private

Definition at line 60 of file cache.cpp.

Member Data Documentation

CacheContainer Cache::AllCaches
private

Definition at line 72 of file cache.hpp.

shared_ptr<Configuration> Cache::Config
private

Definition at line 70 of file cache.hpp.

shared_ptr<Tile> Cache::DefaultTile
private

Definition at line 74 of file cache.hpp.

boost::mutex Cache::GlobalCacheLock
private

Definition at line 71 of file cache.hpp.

TileList Cache::RecentlyUsedList
private

Definition at line 73 of file cache.hpp.


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