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-27
0007  * Description : Similarity database backend
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  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 // Local includes
0018 
0019 #include "similaritydbbackend.h"
0020 #include "dbenginebackend_p.h"
0021 #include "similaritydbschemaupdater.h"
0022 
0023 namespace Digikam
0024 {
0025 
0026 SimilarityDbBackend::SimilarityDbBackend(DbEngineLocking* const locking, const QString& backendName)
0027     : BdEngineBackend(backendName, locking, *new BdEngineBackendPrivate(this))
0028 {
0029 }
0030 
0031 SimilarityDbBackend::~SimilarityDbBackend()
0032 {
0033 }
0034 
0035 bool SimilarityDbBackend::initSchema(SimilarityDbSchemaUpdater* const updater)
0036 {
0037     Q_D(BdEngineBackend);
0038 
0039     if (d->status == OpenSchemaChecked)
0040     {
0041         return true;
0042     }
0043 
0044     if (d->status == Unavailable)
0045     {
0046         return false;
0047     }
0048 
0049     if (updater->update())
0050     {
0051         d->status = OpenSchemaChecked;
0052         return true;
0053     }
0054 
0055     return false;
0056 }
0057 
0058 } // namespace Digikam
0059 
0060 #include "moc_similaritydbbackend.cpp"