digiKam
coredbaccess.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-03-18
7  * Description : Core database access wrapper.
8  *
9  * Copyright (C) 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_CORE_DB_ACCESS_H
26 #define DIGIKAM_CORE_DB_ACCESS_H
27 
28 // Local includes
29 
30 #include "digikam_export.h"
31 #include "dbengineparameters.h"
32 
33 namespace Digikam
34 {
35 
36 class CoreDbBackend;
37 class CoreDB;
38 class CoreDbWatch;
39 class InitializationObserver;
40 class DbEngineErrorHandler;
41 class CoreDbAccessStaticPriv;
42 
55 class DIGIKAM_DATABASE_EXPORT CoreDbAccess
56 {
57 public:
58 
60  {
62  DatabaseSlave
63  };
64 
65 public:
66 
75  explicit CoreDbAccess();
76  ~CoreDbAccess();
77 
81  CoreDB* db() const;
82 
86  CoreDbBackend* backend() const;
87 
92  QString lastError();
93 
97  void setLastError(const QString& error);
98 
99 public:
100 
104  static DbEngineParameters parameters();
105 
116  static void setParameters(const DbEngineParameters& parameters);
117  static void setParameters(const DbEngineParameters& parameters, ApplicationStatus status);
118 
125  static bool checkReadyForUse(InitializationObserver* const observer = nullptr);
126 
132  static void cleanUpDatabase();
133 
137  static CoreDbWatch* databaseWatch();
138 
142  static void initDbEngineErrorHandler(DbEngineErrorHandler* const errorhandler);
143 
144 private:
145 
146  // Disable
147  explicit CoreDbAccess(bool);
148 
149  friend class CoreDbAccessUnlock;
150  static CoreDbAccessStaticPriv* d;
151 };
152 
153 // -----------------------------------------------------------------------------
154 
156 {
157 public:
158 
168  explicit CoreDbAccessUnlock(CoreDbAccess* const access);
170 
171 private:
172 
173  int count;
174 };
175 
176 } // namespace Digikam
177 
178 #endif // DIGIKAM_CORE_DB_ACCESS_H
Definition: coredb.h:57
Definition: coredbaccess.h:156
CoreDbAccessUnlock()
Definition: coredbaccess.cpp:384
~CoreDbAccessUnlock()
Definition: coredbaccess.cpp:431
Definition: coredbaccess.h:56
ApplicationStatus
Definition: coredbaccess.h:60
@ MainApplication
Definition: coredbaccess.h:61
Definition: coredbbackend.h:42
Definition: coredbwatch.h:44
Definition: dbengineerrorhandler.h:60
Definition: dbengineparameters.h:49
Definition: collectionscannerobserver.h:57
Definition: datefolderview.cpp:43