Mercurial > hg > orthanc-databases
comparison Framework/Common/ImplicitTransaction.h @ 23:b2ff1cd2907a
handling of implicit transactions in DatabaseManager
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Jul 2018 10:44:17 +0200 |
parents | |
children | c0cb5d2cd696 |
comparison
equal
deleted
inserted
replaced
22:1e9bad493475 | 23:b2ff1cd2907a |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "ITransaction.h" | |
25 | |
26 namespace OrthancDatabases | |
27 { | |
28 class ImplicitTransaction : public ITransaction | |
29 { | |
30 private: | |
31 enum State | |
32 { | |
33 State_Ready, | |
34 State_Executed, | |
35 State_Committed | |
36 }; | |
37 | |
38 State state_; | |
39 bool readOnly_; | |
40 | |
41 void CheckStateForExecution(); | |
42 | |
43 protected: | |
44 virtual IResult* ExecuteInternal(IPrecompiledStatement& statement, | |
45 const Dictionary& parameters) = 0; | |
46 | |
47 virtual void ExecuteWithoutResultInternal(IPrecompiledStatement& statement, | |
48 const Dictionary& parameters) = 0; | |
49 | |
50 public: | |
51 ImplicitTransaction(); | |
52 | |
53 virtual ~ImplicitTransaction(); | |
54 | |
55 virtual bool IsImplicit() const | |
56 { | |
57 return true; | |
58 } | |
59 | |
60 virtual bool IsReadOnly() const | |
61 { | |
62 return readOnly_; | |
63 } | |
64 | |
65 virtual void Rollback(); | |
66 | |
67 virtual void Commit(); | |
68 | |
69 virtual IResult* Execute(IPrecompiledStatement& statement, | |
70 const Dictionary& parameters); | |
71 | |
72 virtual void ExecuteWithoutResult(IPrecompiledStatement& statement, | |
73 const Dictionary& parameters); | |
74 }; | |
75 } |