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 : 2010-10-12 0007 * Description : Convenience object for grouping face database operations 0008 * 0009 * SPDX-FileCopyrightText: 2010 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_FACE_DB_OPERATION_GROUP_H 0016 #define DIGIKAM_FACE_DB_OPERATION_GROUP_H 0017 0018 namespace Digikam 0019 { 0020 0021 class FaceDbAccess; 0022 0023 /** 0024 * When you intend to execute a number of write operations to the database, 0025 * group them while holding a FaceDbOperationGroup. 0026 * For some database systems (SQLite), keeping a transaction across write operations 0027 * occurring in short time results in enormous speedup (800x). 0028 * For system that do not need this optimization, this class is a no-op. 0029 */ 0030 class FaceDbOperationGroup 0031 { 0032 public: 0033 0034 /** 0035 * Retrieve a FaceDbAccess object each time when constructing and destructing. 0036 */ 0037 FaceDbOperationGroup(); 0038 0039 /** 0040 * Use an existing FaceDbAccess object, which must live as long as this object exists. 0041 */ 0042 explicit FaceDbOperationGroup(FaceDbAccess* const dbAccess); 0043 0044 ~FaceDbOperationGroup(); 0045 0046 /** 0047 * This will - if a transaction is held - commit the transaction and acquire a new one. 0048 * This may improve concurrent access. 0049 */ 0050 void lift(); 0051 0052 void setMaximumTime(int msecs); 0053 0054 /** 0055 * Resets to 0 the time used by allowLift() 0056 */ 0057 void resetTime(); 0058 0059 /** 0060 * Allows to lift(). The transaction will be lifted if the time set by setMaximumTime() 0061 * has expired. 0062 */ 0063 void allowLift(); 0064 0065 private: 0066 0067 // Disable 0068 FaceDbOperationGroup(const FaceDbOperationGroup&) = delete; 0069 FaceDbOperationGroup& operator=(const FaceDbOperationGroup&) = delete; 0070 0071 private: 0072 0073 class Private; 0074 Private* const d; 0075 }; 0076 0077 } // namespace Digikam 0078 0079 #endif // DIGIKAM_FACE_DB_OPERATION_GROUP_H