digiKam
Digikam::CoreDbAccess Class Reference

Public Types

enum  ApplicationStatus { MainApplication , DatabaseSlave }
 

Public Member Functions

CoreDbBackendbackend () const
 
 CoreDbAccess ()
 
CoreDBdb () const
 
QString lastError ()
 
void setLastError (const QString &error)
 
 ~CoreDbAccess ()
 

Static Public Member Functions

static bool checkReadyForUse (InitializationObserver *const observer=nullptr)
 
static void cleanUpDatabase ()
 
static CoreDbWatchdatabaseWatch ()
 
static void initDbEngineErrorHandler (DbEngineErrorHandler *const errorhandler)
 
static DbEngineParameters parameters ()
 
static void setParameters (const DbEngineParameters &parameters)
 
static void setParameters (const DbEngineParameters &parameters, ApplicationStatus status)
 

Friends

class CoreDbAccessUnlock
 

Detailed Description

The CoreDbAccess provides access to the database: Create an instance of this class on the stack to retrieve a pointer to the database. While you hold an instance of CoreDbAccess, the database access is locked for other threads, but not for other processes. This is due to the fact that while databases allow concurrent access (of course), their client libs may not be thread-safe.

When initializing your application, you need to call two methods:

  • in a not-yet-multithreaded context, you need to call setParameters
  • to make sure that the database is available and the schema is properly initialized, call checkReadyForUse()

Member Enumeration Documentation

◆ ApplicationStatus

Enumerator
MainApplication 
DatabaseSlave 

Constructor & Destructor Documentation

◆ CoreDbAccess()

Digikam::CoreDbAccess::CoreDbAccess ( )
explicit

Create a CoreDbAccess object for the default database. Note that when initializing your app, setParameters need to be called (in a not-yet-multithreaded context) for this to work. If the database is not yet opened, it will be opened. The schema will not be checked, use checkReadyForUse() for a full opening process including schema update and error messages.

References Digikam::CollectionManager::instance(), and Digikam::CollectionManager::refresh().

◆ ~CoreDbAccess()

Digikam::CoreDbAccess::~CoreDbAccess ( )

Member Function Documentation

◆ backend()

◆ checkReadyForUse()

bool Digikam::CoreDbAccess::checkReadyForUse ( InitializationObserver *const  observer = nullptr)
static

◆ cleanUpDatabase()

void Digikam::CoreDbAccess::cleanUpDatabase ( )
static

Clean up the database access. When this function has been called, the access can be restored by calling setParameters. Construction a database access object otherwise after calling this method will crash.

References Digikam::ItemInfoStatic::destroy().

◆ databaseWatch()

◆ db()

CoreDB * Digikam::CoreDbAccess::db ( ) const

Retrieve a pointer to the album database

Referenced by Digikam::TaggingActionFactory::actions(), Digikam::ItemTagPair::addProperty(), Digikam::TagProperties::addProperty(), Digikam::ContextMenuHelper::addRemoveTagsMenu(), Digikam::ItemInfo::addTagPaths(), Digikam::ItemInfo::addToGroup(), Digikam::ItemPosition::apply(), Digikam::ItemComments::apply(), Digikam::SetupMime::applySettings(), Digikam::SetupCollections::applySettings(), Digikam::ItemTagPair::availablePairs(), Digikam::ItemQueryBuilder::buildField(), Digikam::ItemInfo::category(), Digikam::CollectionScanner::checkAlbum(), Digikam::CollectionScanner::checkDeleteRemoved(), checkReadyForUse(), Digikam::ItemInfo::clearGroup(), Digikam::ItemTagPair::clearProperties(), Digikam::ItemScanner::commitAddImage(), Digikam::ItemScanner::commitCopyImageAttributes(), Digikam::ItemScanner::commitImageHistory(), Digikam::ItemScanner::commitImageMetadata(), Digikam::ItemScanner::commitItemInformation(), Digikam::ItemScanner::commitItemPosition(), Digikam::ItemScanner::commitTags(), Digikam::ItemScanner::commitUpdateImage(), Digikam::ItemScanner::commitVideoMetadata(), Digikam::CollectionScanner::completeHistoryScanning(), Digikam::CollectionScanner::completeScan(), Digikam::CollectionScanner::completeScanCleanupPart(), Digikam::CollectionScanner::copyFileProperties(), Digikam::ItemScanner::copyFromSource(), Digikam::ItemInfo::copyItem(), Digikam::ItemCopyright::copyrightInfo(), Digikam::ItemCopyright::copyrightInfos(), Digikam::CollectionScanner::countItemsInFolder(), Digikam::SearchField::createField(), Digikam::AlbumManager::createPAlbum(), Digikam::AlbumManager::createSAlbum(), Digikam::TagsCache::createTag(), Digikam::AlbumManager::createTAlbum(), Digikam::CollectionScanner::databaseInitialScanDone(), Digikam::ItemInfo::dateTime(), Digikam::DBStatDlg::DBStatDlg(), Digikam::AlbumManager::deleteSAlbum(), Digikam::AlbumManager::deleteTAlbum(), Digikam::ItemInfo::dimensions(), Digikam::AbstractAlbumTreeView::doLoadState(), Digikam::ImageWindow::dropEvent(), Digikam::FacesDetector::FacesDetector(), Digikam::ItemInfo::fileSize(), Digikam::ItemScanner::fillCommonContainer(), Digikam::ItemScanner::fillVideoMetadataContainer(), Digikam::ItemInfo::format(), Digikam::ItemInfo::fromLocationAlbumAndName(), Digikam::ItemInfo::fromUniqueHash(), Digikam::ApplicationSettings::getAllFileFilter(), Digikam::ApplicationSettings::getAudioFileFilter(), Digikam::ItemInfo::getDatabaseFieldsRaw(), Digikam::ApplicationSettings::getImageFileFilter(), Digikam::ItemInfoCache::getImageGroupedCount(), Digikam::AlbumManager::getItemFromAlbum(), Digikam::ApplicationSettings::getMovieFileFilter(), Digikam::ApplicationSettings::getRawFileFilter(), Digikam::AlbumManager::getRecentlyAssignedTags(), Digikam::ItemInfo::groupImageId(), Digikam::ItemInfo::hasAncestorImages(), Digikam::ItemInfo::hasDerivedImages(), Digikam::ItemInfo::hasImageHistory(), Digikam::ItemInfo::historyImageId(), Digikam::ItemInfo::imageHistory(), Digikam::HaarIface::imagesFromAlbumsAndTags(), Digikam::CollectionScanner::incrementDeleteRemovedCompleteScanCount(), Digikam::ItemInfo::isRemoved(), Digikam::ItemInfo::isVisible(), Digikam::ItemScanner::ItemScanner(), Digikam::CollectionScanner::itemsWereRemoved(), Digikam::ItemLister::listPAlbum(), Digikam::ItemInfoList::loadGroupImageIds(), Digikam::CollectionScanner::loadNameFilters(), Digikam::ItemInfoList::loadTagIds(), Digikam::ItemInfo::manualOrder(), Digikam::CollectionScanner::markDatabaseAsScanned(), Digikam::ItemInfo::markDerivedFrom(), Digikam::AlbumManager::mergeTAlbum(), Digikam::ItemInfo::modDateTime(), Digikam::AlbumManager::moveTAlbum(), Digikam::ItemInfo::orientation(), Digikam::CollectionScanner::partialScan(), Digikam::ItemInfo::rating(), Digikam::ItemExtendedProperties::readFakeListProperty(), Digikam::ItemExtendedProperties::readProperty(), Digikam::SetupMime::readSettings(), Digikam::HaarIface::rebuildDuplicatesAlbums(), Digikam::HaarIface::Private::rebuildSignatureCache(), Digikam::CollectionManager::refreshLocation(), Digikam::ItemInfo::relationCloud(), Digikam::ItemPosition::remove(), Digikam::ItemInfo::removeAllTags(), Digikam::ItemPosition::removeAltitude(), Digikam::ItemInfo::removeFromGroup(), Digikam::ItemCopyright::removeLanguageProperty(), Digikam::CollectionManager::removeLocation(), Digikam::FaceUtils::removeNormalTag(), Digikam::ItemTagPair::removeProperties(), Digikam::TagProperties::removeProperties(), Digikam::ItemCopyright::removeProperties(), Digikam::ItemTagPair::removeProperty(), Digikam::TagProperties::removeProperty(), Digikam::ItemExtendedProperties::removeProperty(), Digikam::ItemInfo::removeTag(), Digikam::AlbumManager::renamePAlbum(), Digikam::AlbumManager::renameTAlbum(), Digikam::ItemCopyright::replaceFrom(), Digikam::CollectionScanner::resetDeleteRemovedSettings(), Digikam::ItemScanner::resolveHistoryImageId(), Digikam::ItemScanner::resolveImageHistory(), Digikam::AlbumsJob::run(), Digikam::DatesJob::run(), Digikam::GPSJob::run(), Digikam::TagsJob::run(), Digikam::ScanController::run(), Digikam::EmptyDTrashItemsJob::run(), Digikam::DatabaseTask::run(), Digikam::CollectionScanner::safelyRemoveAlbums(), Digikam::ItemGPS::saveChanges(), Digikam::CollectionScanner::scanAlbum(), Digikam::CollectionScanner::scanAlbumRoot(), Digikam::CollectionScanner::scanFile(), Digikam::ItemScanner::scanFile(), Digikam::CollectionScanner::scanForStaleAlbums(), Digikam::ItemScanner::scanFromIdenticalFile(), Digikam::ItemScanner::scanImageHistoryIfModified(), Digikam::CollectionScanner::scanNewFile(), Digikam::PAlbum::setCaption(), Digikam::PAlbum::setCategory(), Digikam::ItemCopyright::setCreator(), Digikam::AlbumManager::setDatabase(), Digikam::PAlbum::setDate(), Digikam::ItemInfo::setDateTime(), Digikam::CoreDbDownloadHistory::setDownloaded(), Digikam::ItemExtendedProperties::setFakeListProperty(), Digikam::ItemInfo::setItemHistory(), Digikam::ItemCopyright::setLanguageProperty(), Digikam::ItemInfo::setManualOrder(), Digikam::ItemInfo::setModDateTime(), Digikam::ItemInfo::setName(), Digikam::ItemInfo::setOrientation(), Digikam::ItemTagPair::setProperty(), Digikam::TagProperties::setProperty(), Digikam::ItemExtendedProperties::setProperty(), Digikam::ItemInfo::setRating(), Digikam::ItemCopyright::setSimpleProperty(), Digikam::ItemInfo::setTag(), Digikam::ItemInfo::setUuid(), Digikam::ItemInfo::setVisible(), Digikam::AlbumModificationHelper::slotAlbumDelete(), Digikam::TagModificationHelper::slotMultipleFaceTagDel(), Digikam::TagModificationHelper::slotMultipleTagDel(), Digikam::ItemIconView::slotRemoveTag(), Digikam::TagModificationHelper::slotTagDelete(), Digikam::ItemInfo::tagIds(), Digikam::ItemScanner::tagItemHistoryGraph(), Digikam::TagProperties::TagProperties(), Digikam::ItemInfo::uniqueHash(), Digikam::AlbumManager::updatePAlbumIcon(), Digikam::CollectionScanner::updateRemovedItemsTime(), Digikam::AlbumManager::updateSAlbum(), Digikam::AlbumManager::updateTAlbumIcon(), Digikam::CoreDbSchemaUpdater::updateUniqueHash(), and Digikam::ItemInfo::uuid().

◆ initDbEngineErrorHandler()

void Digikam::CoreDbAccess::initDbEngineErrorHandler ( DbEngineErrorHandler *const  errorhandler)
static

Setup the errors handler instance.

Referenced by Digikam::AlbumManager::setDatabase().

◆ lastError()

QString Digikam::CoreDbAccess::lastError ( )

Returns the error message for the last error that occurred, or a null QString of no error occurred.

Referenced by Digikam::AlbumManager::setDatabase().

◆ parameters()

◆ setLastError()

void Digikam::CoreDbAccess::setLastError ( const QString &  error)

Set the "last error" message. This method is not for public use.

Referenced by checkReadyForUse().

◆ setParameters() [1/2]

void Digikam::CoreDbAccess::setParameters ( const DbEngineParameters parameters)
static

Set the default parameters. Call this function at least once in the starting phase of your application, when no other threads will yet access the database, to initialize DatabaseAcccess. After this initial call, it is thread-safe to call this function again. In a subsequent call, if the parameters are identical, nothing is done. If the parameters change, the current database will be closed. When parameters have been set or changed, the new one will be opened on-demand, i.e. when the first CoreDbAccess object is constructed.

References DatabaseSlave, and parameters().

Referenced by Digikam::AlbumManager::setDatabase().

◆ setParameters() [2/2]

Friends And Related Function Documentation

◆ CoreDbAccessUnlock

friend class CoreDbAccessUnlock
friend

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