Akonadi

transaction.cpp
1 /*
2  SPDX-FileCopyrightText: 2006 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "transaction.h"
8 #include "storage/datastore.h"
9 
10 using namespace Akonadi::Server;
11 
12 Transaction::Transaction(DataStore *db, const QString &name, bool beginTransaction)
13  : mDb(db)
14  , mName(name)
15  , mCommitted(false)
16 {
17  if (beginTransaction) {
18  mDb->beginTransaction(mName);
19  }
20 }
21 
23 {
24  if (!mCommitted) {
25  mDb->rollbackTransaction();
26  }
27 }
28 
30 {
31  mCommitted = true;
32  return mDb->commitTransaction();
33 }
34 
35 void Transaction::begin()
36 {
37  mDb->beginTransaction(mName);
38 }
This class handles all the database access.
Definition: datastore.h:94
~Transaction()
Rolls back the transaction if it hasn't been committed explicitly.
Definition: transaction.cpp:22
virtual bool beginTransaction(const QString &name)
Begins a transaction.
Definition: datastore.cpp:1350
virtual bool rollbackTransaction()
Reverts all changes within the current transaction.
Definition: datastore.cpp:1393
virtual bool commitTransaction()
Commits all changes within the current transaction and emits all collected notification signals.
Definition: datastore.cpp:1415
Transaction(DataStore *db, const QString &name, bool beginTransaction=true)
Starts a new transaction.
Definition: transaction.cpp:12
bool commit()
Commits the transaction.
Definition: transaction.cpp:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.