![]() |
digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
|
The CoreDbAccess provides access to the database: Create an instance of this class on the stack to retrieve a pointer to the database. More...
Public Types | |
enum | ApplicationStatus { MainApplication , DatabaseSlave } |
Public Member Functions | |
CoreDbAccess () | |
Create a CoreDbAccess object for the default database. | |
CoreDbBackend * | backend () const |
Retrieve a pointer to the database backend. | |
CoreDB * | db () const |
Retrieve a pointer to the album database. | |
QString | lastError () |
Returns the error message for the last error that occurred, or a null QString of no error occurred. | |
void | setLastError (const QString &error) |
Set the "last error" message. | |
Static Public Member Functions | |
static bool | checkReadyForUse (InitializationObserver *const observer=nullptr) |
Method to one-time initialize a database when new parameters have been set: Make sure that the database is open, that the schema has properly been initialized. | |
static void | cleanUpDatabase () |
Clean up the database access. | |
static CoreDbWatch * | databaseWatch () |
Return the CoreDbWatch. | |
static void | initDbEngineErrorHandler (DbEngineErrorHandler *const errorhandler) |
Setup the errors handler instance. | |
static DbEngineParameters | parameters () |
Return the default parameters. | |
static void | setParameters (const DbEngineParameters ¶meters) |
Set the default parameters. | |
static void | setParameters (const DbEngineParameters ¶meters, ApplicationStatus status) |
Friends | |
class | CoreDbAccessUnlock |
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:
Digikam::CoreDbAccess::CoreDbAccess | ( | ) |
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.
|
static |
If the parameters were not changed, this method has no effect.
|
static |
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.
void Digikam::CoreDbAccess::setLastError | ( | const QString & | error | ) |
This method is not for public use.
|
static |
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.