Mercurial > hg > orthanc-databases
annotate Framework/SQLite/SQLiteTransaction.h @ 283:e7678a7b10bb
back to mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Apr 2021 10:02:00 +0200 |
parents | 35598014f140 |
children | 16aac0287485 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
193
3236894320d6
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
186
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 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 #if ORTHANC_ENABLE_SQLITE != 1 | |
25 # error SQLite support must be enabled to use this file | |
26 #endif | |
27 | |
28 #include "../Common/ITransaction.h" | |
29 #include "SQLiteDatabase.h" | |
30 | |
152 | 31 #include <SQLite/Transaction.h> |
0 | 32 |
33 namespace OrthancDatabases | |
34 { | |
35 class SQLiteTransaction : public ITransaction | |
36 { | |
37 private: | |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
38 SQLiteDatabase& database_; |
0 | 39 Orthanc::SQLite::Transaction transaction_; |
40 | |
41 public: | |
186 | 42 explicit SQLiteTransaction(SQLiteDatabase& database); |
0 | 43 |
186 | 44 virtual bool IsImplicit() const ORTHANC_OVERRIDE |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
45 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
46 return false; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
47 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
48 |
186 | 49 virtual void Rollback() ORTHANC_OVERRIDE |
0 | 50 { |
51 transaction_.Rollback(); | |
52 } | |
53 | |
186 | 54 virtual void Commit() ORTHANC_OVERRIDE |
0 | 55 { |
56 transaction_.Commit(); | |
57 } | |
58 | |
59 virtual IResult* Execute(IPrecompiledStatement& statement, | |
186 | 60 const Dictionary& parameters) ORTHANC_OVERRIDE; |
0 | 61 |
62 virtual void ExecuteWithoutResult(IPrecompiledStatement& statement, | |
186 | 63 const Dictionary& parameters) ORTHANC_OVERRIDE; |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
64 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
65 virtual bool DoesTableExist(const std::string& name) ORTHANC_OVERRIDE |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
66 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
67 return database_.GetObject().DoesTableExist(name.c_str()); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
68 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
69 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
70 virtual bool DoesTriggerExist(const std::string& name) ORTHANC_OVERRIDE |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
71 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
72 return false; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
73 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
74 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
75 virtual void ExecuteMultiLines(const std::string& query) ORTHANC_OVERRIDE |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
76 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
77 database_.GetObject().Execute(query); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
78 } |
0 | 79 }; |
80 } |