libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::TileCache Class Reference

Cache have to be locked by its mutex() while access. More...

#include <TileCache.h>

Inheritance diagram for osmscout::TileCache:

Signals

void tileRequested (uint32_t zoomLevel, uint32_t x, uint32_t y)

Public Member Functions

void cleanupCache (uint32_t maxRemove, const std::chrono::milliseconds &maximumLifetime)
void clearPendingRequests ()
 remove all pending requests TODO: in case of multiple map widgets, add some id to avoid removing requests of another widget
bool contains (uint32_t zoomLevel, uint32_t x, uint32_t y)
bool containsRequest (uint32_t zoomLevel, uint32_t x, uint32_t y)
TileCacheVal get (uint32_t zoomLevel, uint32_t x, uint32_t y)
size_t getEpoch () const
void incEpoch ()
bool invalidate (osmscout::GeoBox box=osmscout::GeoBox())
bool isRequestQueueEmpty () const
void mergeAndStartRequests (uint32_t zoomLevel, uint32_t xtile, uint32_t ytile, uint32_t &xFrom, uint32_t &xTo, uint32_t &yFrom, uint32_t &yTo, uint32_t maxWidth, uint32_t maxHeight)
void put (uint32_t zoomLevel, uint32_t x, uint32_t y, const QImage &image, size_t epoch=0)
bool reemitRequests ()
 trigger request signal for all pending requests
bool removeRequest (uint32_t zoomLevel, uint32_t x, uint32_t y)
 Remove pending request.
bool request (uint32_t zoomLevel, uint32_t x, uint32_t y)
 try to create new tile request.
bool startRequestProcess (uint32_t zoomLevel, uint32_t x, uint32_t y)
 TileCache (size_t cacheSize)
 ~TileCache () override=default

Detailed Description

Cache have to be locked by its mutex() while access.

It owns all inserted tiles and it is responsible for its release

Constructor & Destructor Documentation

◆ TileCache()

osmscout::TileCache::TileCache ( size_t cacheSize)
explicit

Referenced by tileRequested().

◆ ~TileCache()

Member Function Documentation

◆ cleanupCache()

void osmscout::TileCache::cleanupCache ( uint32_t maxRemove,
const std::chrono::milliseconds & maximumLifetime )

first, we will iterate over all entries and remove up to maxRemove tiles older than maximumLifetime, if no such entry found and size is bigger than cacheSize, remove oldest tile

Goal is to remove more items at once and minimise frequency of this expensive cleaning

References osmscout::TileCacheVal::lastAccess.

Referenced by osmscout::TiledMapOverlay::FlushCaches(), put(), osmscout::TiledMapOverlay::setEnabled(), and ~TileCache().

◆ clearPendingRequests()

void osmscout::TileCache::clearPendingRequests ( )

remove all pending requests TODO: in case of multiple map widgets, add some id to avoid removing requests of another widget

Referenced by osmscout::TiledMapOverlay::paint(), and ~TileCache().

◆ contains()

bool osmscout::TileCache::contains ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

Referenced by ~TileCache().

◆ containsRequest()

bool osmscout::TileCache::containsRequest ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

Referenced by ~TileCache().

◆ get()

TileCacheVal osmscout::TileCache::get ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

◆ getEpoch()

size_t osmscout::TileCache::getEpoch ( ) const
inline

◆ incEpoch()

void osmscout::TileCache::incEpoch ( )
inline

◆ invalidate()

◆ isRequestQueueEmpty()

bool osmscout::TileCache::isRequestQueueEmpty ( ) const

Referenced by ~TileCache().

◆ mergeAndStartRequests()

void osmscout::TileCache::mergeAndStartRequests ( uint32_t zoomLevel,
uint32_t xtile,
uint32_t ytile,
uint32_t & xFrom,
uint32_t & xTo,
uint32_t & yFrom,
uint32_t & yTo,
uint32_t maxWidth,
uint32_t maxHeight )

◆ put()

void osmscout::TileCache::put ( uint32_t zoomLevel,
uint32_t x,
uint32_t y,
const QImage & image,
size_t epoch = 0 )

References cleanupCache(), and removeRequest().

Referenced by ~TileCache().

◆ reemitRequests()

bool osmscout::TileCache::reemitRequests ( )

trigger request signal for all pending requests

References request(), and tileRequested().

Referenced by ~TileCache().

◆ removeRequest()

bool osmscout::TileCache::removeRequest ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

Remove pending request.

Parameters
zoomLevel
x
y
Returns
true if there was such request

Referenced by put(), and ~TileCache().

◆ request()

bool osmscout::TileCache::request ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

try to create new tile request.

If this request don't exists already, it emit signal tileRequested and return true. Otherwise false.

References tileRequested().

Referenced by reemitRequests(), and ~TileCache().

◆ startRequestProcess()

bool osmscout::TileCache::startRequestProcess ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )

References osmscout::RequestState::pending.

Referenced by ~TileCache().

◆ tileRequested

void osmscout::TileCache::tileRequested ( uint32_t zoomLevel,
uint32_t x,
uint32_t y )
signal

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