Line |
Branch |
Exec |
Source |
1 |
|
|
// SPDX-FileCopyrightText: 2023 Carl Zeiss Microscopy GmbH |
2 |
|
|
// |
3 |
|
|
// SPDX-License-Identifier: MIT |
4 |
|
|
|
5 |
|
|
#pragma once |
6 |
|
|
|
7 |
|
|
namespace imgdoc2 |
8 |
|
|
{ |
9 |
|
|
/// \brief Interface for controlling database transactions. |
10 |
|
|
/// |
11 |
|
|
/// A transaction is started with calling into BeginTransaction. All write/modify-operations after this |
12 |
|
|
/// call are then part of the transaction. The transaction is then completed by calling CommitTransaction, |
13 |
|
|
/// or dismissed by calling into RollbackTransaction. |
14 |
|
|
/// Note that nested transactions are not supported. |
15 |
|
|
class IDatabaseTransaction |
16 |
|
|
{ |
17 |
|
|
public: |
18 |
|
|
/// Begins a transaction. Nested transactions are not allowed, calling BeginTransaction multiple times |
19 |
|
|
/// (i.e. without ending the transaction) results in an exception. |
20 |
|
|
virtual void BeginTransaction() = 0; |
21 |
|
|
|
22 |
|
|
/// Commits a pending transaction. |
23 |
|
|
virtual void CommitTransaction() = 0; |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
/// Rolls back a pending transaction. |
27 |
|
|
virtual void RollbackTransaction() = 0; |
28 |
|
264 |
virtual ~IDatabaseTransaction() = default; |
29 |
|
|
public: |
30 |
|
|
// no copy and no move (-> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-copy-move-or-destructor-function-define-or-delete-them-all ) |
31 |
|
132 |
IDatabaseTransaction() = default; |
32 |
|
|
IDatabaseTransaction(const IDatabaseTransaction&) = delete; // copy constructor |
33 |
|
|
IDatabaseTransaction& operator=(const IDatabaseTransaction&) = delete; // copy assignment |
34 |
|
|
IDatabaseTransaction(IDatabaseTransaction&&) = delete; // move constructor |
35 |
|
|
IDatabaseTransaction& operator=(IDatabaseTransaction&&) = delete; // move assignment |
36 |
|
|
}; |
37 |
|
|
} |
38 |
|
|
|