annotate Framework/Plugins/StorageBackend.h @ 329:b5fb8b77ce4d

initial commit of ODBC framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Aug 2021 20:08:53 +0200
parents 567761f0c1ea
children 16aac0287485
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../Common/DatabaseManager.h"
194
a51ce147dbe0 refactoring using new class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
25
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include <orthanc/OrthancCDatabasePlugin.h>
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
28 #include <boost/thread/mutex.hpp>
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
29
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancDatabases
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class StorageBackend : public boost::noncopyable
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 public:
219
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
36 class IFileContentVisitor : public boost::noncopyable
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
37 {
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
38 public:
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
39 virtual ~IFileContentVisitor()
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
40 {
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
41 }
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
42
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
43 virtual void Assign(const std::string& content) = 0;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
44
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
45 virtual bool IsSuccess() const = 0;
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
46 };
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
47
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
48 class IAccessor : public boost::noncopyable
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
49 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
50 public:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
51 virtual ~IAccessor()
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
52 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
53 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
54
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
55 virtual void Create(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
56 const void* content,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
57 size_t size,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
58 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
59
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
60 virtual void ReadWhole(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
61 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
62 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
63
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
64 virtual void ReadRange(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
65 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
66 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
67 uint64_t start,
246
483af3f35a4b turning ResultFileValue into a base class, and implement its primitives for PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
68 size_t length) = 0;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
69
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
70 virtual void Remove(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
71 OrthancPluginContentType type) = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
72 };
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
73
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
74 /**
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
75 * This class is similar to
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
76 * "Orthanc::StatelessDatabaseOperations": It handles retries of
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
77 * transactions in the case of collision between multiple
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
78 * readers/writers.
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
79 **/
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
80 class IDatabaseOperation : public boost::noncopyable
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
81 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
82 public:
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
83 virtual ~IDatabaseOperation()
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
84 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
85 }
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
86
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
87 virtual void Execute(IAccessor& accessor) = 0;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
88 };
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
89
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
90 class ReadWholeOperation;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
91
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
92 private:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
93 class StringVisitor;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
94
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
95 boost::mutex mutex_;
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
96 DatabaseManager manager_;
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
97 unsigned int maxRetries_;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
98
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
99 protected:
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
100 class AccessorBase : public IAccessor
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
101 {
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
102 private:
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
103 boost::mutex::scoped_lock lock_;
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
104 DatabaseManager& manager_;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
105
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
106 public:
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
107 explicit AccessorBase(StorageBackend& backend) :
231
0a9b48d19643 removed mutex out of DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
108 lock_(backend.mutex_),
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
109 manager_(backend.manager_)
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
110 {
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
111 }
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
112
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
113 DatabaseManager& GetManager() const
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
114 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
115 return manager_;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
116 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
117
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
118 virtual void Create(const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
119 const void* content,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
120 size_t size,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
121 OrthancPluginContentType type) ORTHANC_OVERRIDE;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
122
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
123 virtual void ReadWhole(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
124 const std::string& uuid,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
125 OrthancPluginContentType type) ORTHANC_OVERRIDE;
230
675f8322eb7c refactored StorageBackend by introducing an accessor class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
126
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
127 virtual void ReadRange(IFileContentVisitor& visitor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
128 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
129 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
130 uint64_t start,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
131 size_t length) ORTHANC_OVERRIDE;
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
132
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
133 virtual void Remove(const std::string& uuid,
252
33fa478c119a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
134 OrthancPluginContentType type) ORTHANC_OVERRIDE;
219
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
135 };
dd6cfc250747 removed useless class StorageAreaBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
136
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
137 virtual bool HasReadRange() const = 0;
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
138
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
139 public:
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
140 StorageBackend(IDatabaseFactory* factory /* takes ownership */,
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
141 unsigned int maxRetries);
255
d663d9e44f8d reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 252
diff changeset
142
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 virtual ~StorageBackend()
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
146
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
147 virtual IAccessor* CreateAccessor()
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
148 {
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
149 return new AccessorBase(*this);
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
150 }
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
151
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 static void Register(OrthancPluginContext* context,
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 StorageBackend* backend); // Takes ownership
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 static void Finalize();
242
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
156
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
157 // For unit tests
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
158 static void ReadWholeToString(std::string& target,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
159 IAccessor& accessor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
160 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
161 OrthancPluginContentType type);
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
162
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
163 // For unit tests
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
164 static void ReadRangeToString(std::string& target,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
165 IAccessor& accessor,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
166 const std::string& uuid,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
167 OrthancPluginContentType type,
b97a537f4613 MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
168 uint64_t start,
246
483af3f35a4b turning ResultFileValue into a base class, and implement its primitives for PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
169 size_t length);
269
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
170
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
171 unsigned int GetMaxRetries() const
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
172 {
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
173 return maxRetries_;
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
174 }
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
175
567761f0c1ea fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
176 void Execute(IDatabaseOperation& operation);
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 };
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }