File indexing completed on 2025-01-05 03:54:00

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-03-23
0007  * Description : Core database convenience object for transactions.
0008  *
0009  * SPDX-FileCopyrightText: 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_CORE_DB_TRANSACTION_H
0016 #define DIGIKAM_CORE_DB_TRANSACTION_H
0017 
0018 // Local includes
0019 
0020 #include "digikam_export.h"
0021 
0022 namespace Digikam
0023 {
0024 
0025 class CoreDbAccess;
0026 
0027 /**
0028  * Convenience class: You can create a CoreDbTransaction object for a scope for which
0029  * you want to declare a database commit.
0030  * Equivalent to calling beginTransaction and commitTransaction on the album db.
0031  */
0032 class DIGIKAM_DATABASE_EXPORT CoreDbTransaction
0033 {
0034 public:
0035 
0036     /**
0037      * Retrieve a CoreDbAccess object each time when constructing and destructing.
0038      */
0039     CoreDbTransaction();
0040 
0041     /**
0042      * Use an existing CoreDbAccess object, which must live as long as this object exists.
0043      */
0044     explicit CoreDbTransaction(CoreDbAccess* const access);
0045     ~CoreDbTransaction();
0046 
0047 private:
0048 
0049     CoreDbAccess* m_access;
0050 };
0051 
0052 } // namespace Digikam
0053 
0054 #endif // DIGIKAM_CORE_DB_TRANSACTION_H