libosmscout  1.1.1
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Friends | List of all members
osmscout::DBThread Class Reference

#include <libosmscout-client-qt/include/osmscout/DBThread.h>

Inheritance diagram for osmscout::DBThread:
Inheritance graph
[legend]
Collaboration diagram for osmscout::DBThread:
Collaboration graph
[legend]

Public Types

using SynchronousDBJob = std::function< void(const std::list< DBInstanceRef > &)>
 

Public Slots

void ToggleDaylight ()
 
void onMapDPIChange (double dpi)
 
void SetStyleFlag (const QString &key, bool value)
 
void ReloadStyle (const QString &suffix="")
 
void LoadStyle (QString stylesheetFilename, std::unordered_map< std::string, bool > stylesheetFlags, const QString &suffix="")
 
void Initialize ()
 
void onDatabaseListChanged (QList< QDir > databaseDirectories)
 
void FlushCaches (qint64 idleMs)
 

Signals

void initialisationFinished (const DatabaseLoadedResponse &response)
 
void stylesheetFilenameChanged ()
 
void databaseLoadFinished (osmscout::GeoBox boundingBox)
 
void styleErrorsChanged ()
 

Public Member Functions

 DBThread (QThread *backgroundThread, QString basemapLookupDirectory, QString iconDirectory, SettingsRef settings, MapManagerRef mapManager, const std::vector< std::string > &customPoiTypes)
 
 ~DBThread () override
 
bool isInitialized ()
 
const DatabaseLoadedResponse loadedResponse () const
 
DatabaseCoverage databaseCoverage (const osmscout::Magnification &magnification, const osmscout::GeoBox &bbox)
 
double GetMapDpi () const
 
double GetPhysicalDpi () const
 
QString GetStylesheetFilename () const
 
const QList< StyleError > & GetStyleErrors () const
 
const QMap< QString, bool > GetStyleFlags () const
 
void RunJob (DBJob *job)
 
void RunSynchronousJob (SynchronousDBJob job)
 

Protected Member Functions

bool isInitializedInternal ()
 

Protected Attributes

QThread * backgroundThread
 
MapManagerRef mapManager
 
QString basemapLookupDirectory
 
SettingsRef settings
 
double mapDpi
 
double physicalDpi
 
QReadWriteLock lock
 
osmscout::BasemapDatabaseParameter basemapDatabaseParameter
 
osmscout::BasemapDatabaseRef basemapDatabase
 
osmscout::DatabaseParameter databaseParameter
 
std::list< DBInstanceRefdatabases
 
QString iconDirectory
 
std::unordered_map< std::string, bool > stylesheetFlags
 
bool daylight
 
bool renderError
 
QList< StyleErrorstyleErrors
 
std::vector< std::string > customPoiTypes
 

Properties

QString stylesheetFilename
 

Friends

class OSMScoutQt
 

Detailed Description

Central object that manage database instances (DBInstance), its map styles (there is one global map style now) and provides simple thread-safe, asynchronous api for accessing it.

DBThread is de facto singleton, that is created and accessible by OSMScoutQt.

List of databases is protected by read-write lock. There may be multiple readers at one time. DBThread warrants that none database will be closed or modified (except thread-safe caches) when read lock is hodl. Databases may be accessed via

See also
RunJob or
RunSynchronousJob methods.

Member Typedef Documentation

◆ SynchronousDBJob

using osmscout::DBThread::SynchronousDBJob = std::function<void (const std::list<DBInstanceRef> &)>

Constructor & Destructor Documentation

◆ DBThread()

osmscout::DBThread::DBThread ( QThread *  backgroundThread,
QString  basemapLookupDirectory,
QString  iconDirectory,
SettingsRef  settings,
MapManagerRef  mapManager,
const std::vector< std::string > &  customPoiTypes 
)

◆ ~DBThread()

osmscout::DBThread::~DBThread ( )
override

Member Function Documentation

◆ databaseCoverage()

DatabaseCoverage osmscout::DBThread::databaseCoverage ( const osmscout::Magnification &  magnification,
const osmscout::GeoBox &  bbox 
)

Test if some bounding box is covered by databases - fully, partially or not covered. Database bounding box combined with water-index is used.

Parameters
magnification
bbox
Returns
DatabaseCoverage enum: Outside, Covered, Intersects

◆ databaseLoadFinished

void osmscout::DBThread::databaseLoadFinished ( osmscout::GeoBox  boundingBox)
signal

◆ FlushCaches

void osmscout::DBThread::FlushCaches ( qint64  idleMs)
slot

Flush all caches for database that was not used in recent idleMs

◆ GetMapDpi()

double osmscout::DBThread::GetMapDpi ( ) const

◆ GetPhysicalDpi()

double osmscout::DBThread::GetPhysicalDpi ( ) const

◆ GetStyleErrors()

const QList<StyleError>& osmscout::DBThread::GetStyleErrors ( ) const
inline

◆ GetStyleFlags()

const QMap<QString,bool> osmscout::DBThread::GetStyleFlags ( ) const

◆ GetStylesheetFilename()

QString osmscout::DBThread::GetStylesheetFilename ( ) const
inline

◆ initialisationFinished

void osmscout::DBThread::initialisationFinished ( const DatabaseLoadedResponse response)
signal

◆ Initialize

void osmscout::DBThread::Initialize ( )
slot

◆ isInitialized()

bool osmscout::DBThread::isInitialized ( )

◆ isInitializedInternal()

bool osmscout::DBThread::isInitializedInternal ( )
protected

◆ loadedResponse()

const DatabaseLoadedResponse osmscout::DBThread::loadedResponse ( ) const

◆ LoadStyle

void osmscout::DBThread::LoadStyle ( QString  stylesheetFilename,
std::unordered_map< std::string, bool >  stylesheetFlags,
const QString &  suffix = "" 
)
slot

◆ onDatabaseListChanged

void osmscout::DBThread::onDatabaseListChanged ( QList< QDir >  databaseDirectories)
slot

◆ onMapDPIChange

void osmscout::DBThread::onMapDPIChange ( double  dpi)
slot

◆ ReloadStyle

void osmscout::DBThread::ReloadStyle ( const QString &  suffix = "")
slot

◆ RunJob()

void osmscout::DBThread::RunJob ( DBJob job)

Submit asynchronous job that will retrieve list of initialized databases and pointer to QReadLocker. Job is responsible for releasing lock when its task is finished.

Parameters
job

◆ RunSynchronousJob()

void osmscout::DBThread::RunSynchronousJob ( SynchronousDBJob  job)

Submit synchronous job (simple lambda function) that will get access to list of initialized databases. Database read lock is hold until job is running. Lock is released automatically then. Database instances should not be accessed after it.

Example:

dbThread->RunSynchronousJob(
[&](const std::list<DBInstanceRef> &databases){
// read data from databases...
}
);
Parameters
job

◆ SetStyleFlag

void osmscout::DBThread::SetStyleFlag ( const QString &  key,
bool  value 
)
slot

◆ styleErrorsChanged

void osmscout::DBThread::styleErrorsChanged ( )
signal

◆ stylesheetFilenameChanged

void osmscout::DBThread::stylesheetFilenameChanged ( )
signal

◆ ToggleDaylight

void osmscout::DBThread::ToggleDaylight ( )
slot

Friends And Related Function Documentation

◆ OSMScoutQt

friend class OSMScoutQt
friend

Member Data Documentation

◆ backgroundThread

QThread* osmscout::DBThread::backgroundThread
protected

◆ basemapDatabase

osmscout::BasemapDatabaseRef osmscout::DBThread::basemapDatabase
protected

◆ basemapDatabaseParameter

osmscout::BasemapDatabaseParameter osmscout::DBThread::basemapDatabaseParameter
protected

◆ basemapLookupDirectory

QString osmscout::DBThread::basemapLookupDirectory
protected

◆ customPoiTypes

std::vector<std::string> osmscout::DBThread::customPoiTypes
protected

◆ databaseParameter

osmscout::DatabaseParameter osmscout::DBThread::databaseParameter
protected

◆ databases

std::list<DBInstanceRef> osmscout::DBThread::databases
protected

◆ daylight

bool osmscout::DBThread::daylight
protected

◆ iconDirectory

QString osmscout::DBThread::iconDirectory
protected

◆ lock

QReadWriteLock osmscout::DBThread::lock
mutableprotected

◆ mapDpi

double osmscout::DBThread::mapDpi
protected

◆ mapManager

MapManagerRef osmscout::DBThread::mapManager
protected

◆ physicalDpi

double osmscout::DBThread::physicalDpi
protected

◆ renderError

bool osmscout::DBThread::renderError
protected

◆ settings

SettingsRef osmscout::DBThread::settings
protected

◆ styleErrors

QList<StyleError> osmscout::DBThread::styleErrors
protected

◆ stylesheetFlags

std::unordered_map<std::string,bool> osmscout::DBThread::stylesheetFlags
protected

Property Documentation

◆ stylesheetFilename

QString osmscout::DBThread::stylesheetFilename
read

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