Akonadi

transaction.h
1/*
2 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QString>
10
11namespace Akonadi
12{
13namespace Server
14{
15class DataStore;
16
17/**
18 Helper class for DataStore transaction handling.
19 Works similar to QMutexLocker.
20 Supports command-local and session-global transactions.
21*/
23{
24public:
25 /**
26 Starts a new transaction. The transaction will automatically rolled back
27 on destruction if it hasn't been committed explicitly before.
28 If there is already a global transaction in progress, this one will be used
29 instead of creating a new one.
30 @param db The corresponding DataStore. You must not delete @p db during
31 the lifetime of a Transaction object.
32 @param name A name of the transaction. Used for debugging.
33 @param beginTransaction if false, the transaction won't be started, until begin is explicitly called. The default is to begin the transaction right away.
34 */
35 explicit Transaction(DataStore *db, const QString &name, bool beginTransaction = true);
36
37 /**
38 Rolls back the transaction if it hasn't been committed explicitly.
39 This also happens if a global transaction is used.
40 */
42
43 /**
44 Commits the transaction. Returns true on success.
45 If a global transaction is used, nothing happens, global transactions have
46 to be committed explicitly.
47 */
48 bool commit();
49
50 void begin();
51
52private:
53 Q_DISABLE_COPY(Transaction)
54 DataStore *mDb;
55 QString mName;
56 bool mCommitted;
57};
58
59} // namespace Server
60} // namespace Akonadi
This class handles all the database access.
Definition datastore.h:95
Helper class for DataStore transaction handling.
Definition transaction.h:23
~Transaction()
Rolls back the transaction if it hasn't been committed explicitly.
bool commit()
Commits the transaction.
Transaction(DataStore *db, const QString &name, bool beginTransaction=true)
Starts a new transaction.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:49:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.