File indexing completed on 2025-01-05 03:54:13
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2017-06-28 0007 * Description : Similarity 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 * SPDX-FileCopyrightText: 2017 by Swati Lodha <swatilodha27 at gmail dot com> 0012 * SPDX-FileCopyrightText: 2018 by Mario Frank <mario dot frank at uni minus potsdam dot de> 0013 * 0014 * SPDX-License-Identifier: GPL-2.0-or-later 0015 * 0016 * ============================================================ */ 0017 0018 #ifndef DIGIKAM_SIMILARITY_DB_ACCESS_H 0019 #define DIGIKAM_SIMILARITY_DB_ACCESS_H 0020 0021 // Local includes 0022 0023 #include "digikam_export.h" 0024 #include "dbengineparameters.h" 0025 0026 namespace Digikam 0027 { 0028 0029 class DbEngineErrorHandler; 0030 class InitializationObserver; 0031 class SimilarityDb; 0032 class SimilarityDbAccessStaticPriv; 0033 class SimilarityDbBackend; 0034 0035 class DIGIKAM_DATABASE_EXPORT SimilarityDbAccess 0036 { 0037 public: 0038 0039 /** This class is written in analogy to CoreDbAccess 0040 * (some features stripped off). 0041 * For documentation, see coredbaccess.h 0042 */ 0043 explicit SimilarityDbAccess(); 0044 ~SimilarityDbAccess(); 0045 0046 SimilarityDb* db() const; 0047 SimilarityDbBackend* backend() const; 0048 QString lastError() const; 0049 0050 /** 0051 * Set the "last error" message. This method is not for public use. 0052 */ 0053 void setLastError(const QString& error); 0054 0055 /** 0056 * This static method returns the current db parameters. 0057 * @return the current db parameters. 0058 */ 0059 static DbEngineParameters parameters(); 0060 0061 public: 0062 0063 /** 0064 * This static method initialises the error handler for the similarity db. 0065 * @param errorhandler The error handler. 0066 */ 0067 static void initDbEngineErrorHandler(DbEngineErrorHandler* const errorhandler); 0068 0069 /** 0070 * This static method sets the database parameters that are needed to initialise the db connection. 0071 * @param parameters The db parameters. 0072 */ 0073 static void setParameters(const DbEngineParameters& parameters); 0074 0075 /** 0076 * This static method checks if the similarity db is ready for use. 0077 * @param observer the observer. 0078 * @return true, if the database is ready for use. 0079 */ 0080 static bool checkReadyForUse(InitializationObserver* const observer); 0081 0082 /** 0083 * This static method returns if the similarity db is initialised. 0084 * @return true, if the similarityDb is initialised. 0085 */ 0086 static bool isInitialized(); 0087 0088 /** 0089 * This static method removes the connection to the similarity database. 0090 */ 0091 static void cleanUpDatabase(); 0092 0093 private: 0094 0095 /** 0096 * Constructs the db access without checking the connectivity to the database itself. 0097 */ 0098 explicit SimilarityDbAccess(bool); 0099 0100 static SimilarityDbAccessStaticPriv* d; 0101 }; 0102 0103 } // namespace Digikam 0104 0105 #endif // DIGIKAM_SIMILARITY_DB_ACCESS_H