comparison Framework/Plugins/IDatabaseBackend.h @ 202:2def2df94f94

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Mar 2021 17:00:38 +0100
parents
children 2089d4071408
comparison
equal deleted inserted replaced
201:42990b2dd51b 202:2def2df94f94
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-2021 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
23 #pragma once
24
25 #include "IDatabaseBackendOutput.h"
26
27 #include <list>
28
29 namespace OrthancPlugins
30 {
31 class IDatabaseBackend : public boost::noncopyable
32 {
33 public:
34 virtual ~IDatabaseBackend()
35 {
36 }
37
38 virtual OrthancPluginContext* GetContext() = 0;
39
40 virtual void SetOutputFactory(IDatabaseBackendOutput::IFactory* factory) = 0;
41
42 virtual IDatabaseBackendOutput* CreateOutput() = 0;
43
44 virtual void Open() = 0;
45
46 virtual void Close() = 0;
47
48 virtual void AddAttachment(int64_t id,
49 const OrthancPluginAttachment& attachment) = 0;
50
51 virtual void AttachChild(int64_t parent,
52 int64_t child) = 0;
53
54 virtual void ClearChanges() = 0;
55
56 virtual void ClearExportedResources() = 0;
57
58 virtual int64_t CreateResource(const char* publicId,
59 OrthancPluginResourceType type) = 0;
60
61 virtual void DeleteAttachment(OrthancPlugins::IDatabaseBackendOutput& output,
62 int64_t id,
63 int32_t attachment) = 0;
64
65 virtual void DeleteMetadata(int64_t id,
66 int32_t metadataType) = 0;
67
68 virtual void DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output,
69 int64_t id) = 0;
70
71 virtual void GetAllInternalIds(std::list<int64_t>& target,
72 OrthancPluginResourceType resourceType) = 0;
73
74 virtual void GetAllPublicIds(std::list<std::string>& target,
75 OrthancPluginResourceType resourceType) = 0;
76
77 virtual void GetAllPublicIds(std::list<std::string>& target,
78 OrthancPluginResourceType resourceType,
79 uint64_t since,
80 uint64_t limit) = 0;
81
82 /* Use GetOutput().AnswerChange() */
83 virtual void GetChanges(OrthancPlugins::IDatabaseBackendOutput& output,
84 bool& done /*out*/,
85 int64_t since,
86 uint32_t maxResults) = 0;
87
88 virtual void GetChildrenInternalId(std::list<int64_t>& target /*out*/,
89 int64_t id) = 0;
90
91 virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/,
92 int64_t id) = 0;
93
94 /* Use GetOutput().AnswerExportedResource() */
95 virtual void GetExportedResources(OrthancPlugins::IDatabaseBackendOutput& output,
96 bool& done /*out*/,
97 int64_t since,
98 uint32_t maxResults) = 0;
99
100 /* Use GetOutput().AnswerChange() */
101 virtual void GetLastChange(OrthancPlugins::IDatabaseBackendOutput& output) = 0;
102
103 /* Use GetOutput().AnswerExportedResource() */
104 virtual void GetLastExportedResource(OrthancPlugins::IDatabaseBackendOutput& output) = 0;
105
106 /* Use GetOutput().AnswerDicomTag() */
107 virtual void GetMainDicomTags(OrthancPlugins::IDatabaseBackendOutput& output,
108 int64_t id) = 0;
109
110 virtual std::string GetPublicId(int64_t resourceId) = 0;
111
112 virtual uint64_t GetResourceCount(OrthancPluginResourceType resourceType) = 0;
113
114 virtual OrthancPluginResourceType GetResourceType(int64_t resourceId) = 0;
115
116 virtual uint64_t GetTotalCompressedSize() = 0;
117
118 virtual uint64_t GetTotalUncompressedSize() = 0;
119
120 virtual bool IsExistingResource(int64_t internalId) = 0;
121
122 virtual bool IsProtectedPatient(int64_t internalId) = 0;
123
124 virtual void ListAvailableMetadata(std::list<int32_t>& target /*out*/,
125 int64_t id) = 0;
126
127 virtual void ListAvailableAttachments(std::list<int32_t>& target /*out*/,
128 int64_t id) = 0;
129
130 virtual void LogChange(const OrthancPluginChange& change) = 0;
131
132 virtual void LogExportedResource(const OrthancPluginExportedResource& resource) = 0;
133
134 /* Use GetOutput().AnswerAttachment() */
135 virtual bool LookupAttachment(OrthancPlugins::IDatabaseBackendOutput& output,
136 int64_t id,
137 int32_t contentType) = 0;
138
139 virtual bool LookupGlobalProperty(std::string& target /*out*/,
140 int32_t property) = 0;
141
142 virtual void LookupIdentifier(std::list<int64_t>& target /*out*/,
143 OrthancPluginResourceType resourceType,
144 uint16_t group,
145 uint16_t element,
146 OrthancPluginIdentifierConstraint constraint,
147 const char* value) = 0;
148
149 virtual void LookupIdentifierRange(std::list<int64_t>& target /*out*/,
150 OrthancPluginResourceType resourceType,
151 uint16_t group,
152 uint16_t element,
153 const char* start,
154 const char* end) = 0;
155
156 virtual bool LookupMetadata(std::string& target /*out*/,
157 int64_t id,
158 int32_t metadataType) = 0;
159
160 virtual bool LookupParent(int64_t& parentId /*out*/,
161 int64_t resourceId) = 0;
162
163 virtual bool LookupResource(int64_t& id /*out*/,
164 OrthancPluginResourceType& type /*out*/,
165 const char* publicId) = 0;
166
167 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/) = 0;
168
169 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/,
170 int64_t patientIdToAvoid) = 0;
171
172 virtual void SetGlobalProperty(int32_t property,
173 const char* value) = 0;
174
175 virtual void SetMainDicomTag(int64_t id,
176 uint16_t group,
177 uint16_t element,
178 const char* value) = 0;
179
180 virtual void SetIdentifierTag(int64_t id,
181 uint16_t group,
182 uint16_t element,
183 const char* value) = 0;
184
185 virtual void SetMetadata(int64_t id,
186 int32_t metadataType,
187 const char* value) = 0;
188
189 virtual void SetProtectedPatient(int64_t internalId,
190 bool isProtected) = 0;
191
192 virtual void StartTransaction() = 0;
193
194 virtual void RollbackTransaction() = 0;
195
196 virtual void CommitTransaction() = 0;
197
198 virtual uint32_t GetDatabaseVersion() = 0;
199
200 /**
201 * Upgrade the database to the specified version of the database
202 * schema. The upgrade script is allowed to make calls to
203 * OrthancPluginReconstructMainDicomTags().
204 **/
205 virtual void UpgradeDatabase(uint32_t targetVersion,
206 OrthancPluginStorageArea* storageArea) = 0;
207
208 virtual void ClearMainDicomTags(int64_t internalId) = 0;
209
210 virtual bool HasCreateInstance() const = 0;
211
212 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
213 virtual void LookupResources(OrthancPlugins::IDatabaseBackendOutput& output,
214 const std::vector<Orthanc::DatabaseConstraint>& lookup,
215 OrthancPluginResourceType queryLevel,
216 uint32_t limit,
217 bool requestSomeInstance) = 0;
218 #endif
219
220 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
221 virtual void CreateInstance(OrthancPluginCreateInstanceResult& result,
222 const char* hashPatient,
223 const char* hashStudy,
224 const char* hashSeries,
225 const char* hashInstance) = 0;
226 #endif
227
228
229 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
230 virtual void SetResourcesContent(
231 uint32_t countIdentifierTags,
232 const OrthancPluginResourcesContentTags* identifierTags,
233 uint32_t countMainDicomTags,
234 const OrthancPluginResourcesContentTags* mainDicomTags,
235 uint32_t countMetadata,
236 const OrthancPluginResourcesContentMetadata* metadata) = 0;
237 #endif
238
239
240 virtual void GetChildrenMetadata(std::list<std::string>& target,
241 int64_t resourceId,
242 int32_t metadata) = 0;
243
244 virtual int64_t GetLastChangeIndex() = 0;
245
246 virtual void TagMostRecentPatient(int64_t patientId) = 0;
247
248 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
249 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
250 // NB: "parentPublicId" must be cleared if the resource has no parent
251 virtual bool LookupResourceAndParent(int64_t& id,
252 OrthancPluginResourceType& type,
253 std::string& parentPublicId,
254 const char* publicId) = 0;
255 # endif
256 #endif
257
258 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
259 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
260 virtual void GetAllMetadata(std::map<int32_t, std::string>& result,
261 int64_t id) = 0;
262 # endif
263 #endif
264 };
265 }