Audacity 3.2.0
TransactionScope.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file TransactionScope.h
6
7 Paul Licameli split from DBConnection.h
8
9**********************************************************************/
10#ifndef __AUDACITY_TRANSACTION_SCOPE__
11#define __AUDACITY_TRANSACTION_SCOPE__
12
13#include "GlobalVariable.h"
14class AudacityProject;
15#include <functional>
16#include <memory>
17#include <wx/string.h>
18
20
22
27class TRANSACTIONS_API TransactionScope
28{
29public:
31 struct TRANSACTIONS_API Factory : GlobalHook<Factory,
32 std::unique_ptr<TransactionScopeImpl>(AudacityProject &)
33 > {};
34
36
40
43
45 bool Commit();
46
47private:
48 std::unique_ptr<TransactionScopeImpl> mpImpl;
50 wxString mName;
51};
52
54class TRANSACTIONS_API TransactionScopeImpl {
55public:
58 virtual bool TransactionStart(const wxString &name) = 0;
60 virtual bool TransactionCommit(const wxString &name) = 0;
62 virtual bool TransactionRollback(const wxString &name) = 0;
63};
64
65#endif
const TranslatableString name
Definition: Distortion.cpp:76
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Global function-valued variable, adding a convenient Call()
RAII for a database transaction, possibly nested.
std::unique_ptr< TransactionScopeImpl > mpImpl
Abstract base class for implementation of steps of TransactionScope.
virtual bool TransactionCommit(const wxString &name)=0
virtual bool TransactionRollback(const wxString &name)=0
virtual ~TransactionScopeImpl()
virtual bool TransactionStart(const wxString &name)=0
Type of function supplying implementation of steps.