1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2017-06-28 7 * Description : Similarity database access wrapper. 8 * 9 * Copyright (C) 2007-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 10 * Copyright (C) 2010-2017 by Gilles Caulier <caulier dot gilles at gmail dot com> 11 * Copyright (C) 2017 by Swati Lodha <swatilodha27 at gmail dot com> 12 * Copyright (C) 2018 by Mario Frank <mario dot frank at uni minus potsdam dot de> 13 * 14 * This program is free software; you can redistribute it 15 * and/or modify it under the terms of the GNU General 16 * Public License as published by the Free Software Foundation; 17 * either version 2, or (at your option) 18 * any later version. 19 * 20 * This program is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * ============================================================ */ 26 27 #ifndef DIGIKAM_SIMILARITY_DB_ACCESS_H 28 #define DIGIKAM_SIMILARITY_DB_ACCESS_H 29 30 // Local includes 31 32 #include "digikam_export.h" 33 #include "dbengineparameters.h" 34 35 namespace Digikam 36 { 37 38 class DbEngineErrorHandler; 39 class InitializationObserver; 40 class SimilarityDb; 41 class SimilarityDbAccessStaticPriv; 42 class SimilarityDbBackend; 43 44 class DIGIKAM_DATABASE_EXPORT SimilarityDbAccess 45 { 46 public: 47 48 /** This class is written in analogy to CoreDbAccess 49 * (some features stripped off). 50 * For documentation, see coredbaccess.h 51 */ 52 explicit SimilarityDbAccess(); 53 ~SimilarityDbAccess(); 54 55 SimilarityDb* db() const; 56 SimilarityDbBackend* backend() const; 57 QString lastError() const; 58 59 /** 60 * Set the "last error" message. This method is not for public use. 61 */ 62 void setLastError(const QString& error); 63 64 /** 65 * This static method returns the current db parameters. 66 * @return the current db parameters. 67 */ 68 static DbEngineParameters parameters(); 69 70 public: 71 72 /** 73 * This static method initialises the error handler for the similarity db. 74 * @param errorhandler The error handler. 75 */ 76 static void initDbEngineErrorHandler(DbEngineErrorHandler* const errorhandler); 77 78 /** 79 * This static method sets the database parameters that are needed to initialise the db connection. 80 * @param parameters The db parameters. 81 */ 82 static void setParameters(const DbEngineParameters& parameters); 83 84 /** 85 * This static method checks if the similarity db is ready for use. 86 * @param observer the observer. 87 * @return true, if the database is ready for use. 88 */ 89 static bool checkReadyForUse(InitializationObserver* const observer); 90 91 /** 92 * This static method returns if the similarity db is initialised. 93 * @return true, if the similarityDb is initialised. 94 */ 95 static bool isInitialized(); 96 97 /** 98 * This static method removes the connection to the similarity database. 99 */ 100 static void cleanUpDatabase(); 101 102 private: 103 104 /** 105 * Constructs the db access without checking the connectivity to the database itself. 106 */ 107 explicit SimilarityDbAccess(bool); 108 109 static SimilarityDbAccessStaticPriv* d; 110 }; 111 112 } // namespace Digikam 113 114 #endif // DIGIKAM_SIMILARITY_DB_ACCESS_H 115