File indexing completed on 2025-03-09 03:54:59
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-05-29 0007 * Description : Face database access wrapper. 0008 * 0009 * SPDX-FileCopyrightText: 2007-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_FACE_DB_ACCESS_H 0017 #define DIGIKAM_FACE_DB_ACCESS_H 0018 0019 // Local includes 0020 0021 #include "digikam_export.h" 0022 #include "dbengineparameters.h" 0023 #include "collectionscannerobserver.h" 0024 0025 namespace Digikam 0026 { 0027 0028 class FaceDb; 0029 class FaceDbAccessStaticPriv; 0030 class FaceDbBackend; 0031 class DbEngineErrorHandler; 0032 0033 class DIGIKAM_GUI_EXPORT FaceDbAccess 0034 { 0035 public: 0036 0037 /** 0038 * This class is written in analogy to CoreDbAccess 0039 * (some features stripped off). 0040 * For documentation, see coredbaccess.h 0041 */ 0042 FaceDbAccess(); 0043 ~FaceDbAccess(); 0044 0045 FaceDb* db() const; 0046 FaceDbBackend* backend() const; 0047 QString lastError() const; 0048 0049 /** 0050 * Set the "last error" message. This method is not for public use. 0051 */ 0052 void setLastError(const QString& error); 0053 0054 static DbEngineParameters parameters(); 0055 0056 public: 0057 0058 static void initDbEngineErrorHandler(DbEngineErrorHandler* const errorhandler); 0059 static void setParameters(const DbEngineParameters& parameters); 0060 static bool checkReadyForUse(InitializationObserver* const observer); 0061 static bool isInitialized(); 0062 static void cleanUpDatabase(); 0063 0064 private: 0065 0066 explicit FaceDbAccess(bool); 0067 0068 // Disable 0069 FaceDbAccess(const FaceDbAccess&) = delete; 0070 FaceDbAccess& operator=(const FaceDbAccess&) = delete; 0071 0072 private: 0073 0074 friend class FaceDbAccessUnlock; 0075 static FaceDbAccessStaticPriv* d; 0076 }; 0077 0078 // ------------------------------------------------------------------------------------------ 0079 0080 class FaceDbAccessUnlock 0081 { 0082 public: 0083 0084 /** 0085 * Acquire an object of this class if you want to assure 0086 * that the FaceDbAccess is _not_ held during the lifetime of the object. 0087 * At creation, the lock is obtained shortly, then all locks are released. 0088 * At destruction, all locks are acquired again. 0089 * If you need to access any locked structures during lifetime, acquire a new 0090 * FaceDbAccess. 0091 */ 0092 FaceDbAccessUnlock(); 0093 explicit FaceDbAccessUnlock(FaceDbAccess* const access); 0094 ~FaceDbAccessUnlock(); 0095 0096 private: 0097 0098 int count; 0099 0100 private: 0101 0102 // Disable 0103 FaceDbAccessUnlock(const FaceDbAccessUnlock&) = delete; 0104 FaceDbAccessUnlock& operator=(const FaceDbAccessUnlock&) = delete; 0105 }; 0106 0107 } // namespace Digikam 0108 0109 #endif // DIGIKAM_FACE_DB_ACCESS_H