Mercurial > hg > orthanc
annotate OrthancServer/Resources/Graveyard/DatabasePluginSample/Database.h @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
1671 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1671 | 4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1671 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
4050 | 26 #include "OrthancCppDatabasePlugin.h" |
1671 | 27 |
4050 | 28 #include "../../../../OrthancFramework/Sources/SQLite/Connection.h" |
29 #include "../../../../OrthancFramework/Sources/SQLite/Transaction.h" | |
30 #include "../../../Plugins/Engine/PluginsEnumerations.h" | |
31 #include "DatabaseWrapperBase.h" | |
1671 | 32 |
33 #include <memory> | |
34 | |
35 class Database : public OrthancPlugins::IDatabaseBackend | |
36 { | |
37 private: | |
38 class SignalRemainingAncestor; | |
39 | |
40 std::string path_; | |
41 Orthanc::SQLite::Connection db_; | |
42 Orthanc::DatabaseWrapperBase base_; | |
43 SignalRemainingAncestor* signalRemainingAncestor_; | |
44 | |
45 std::auto_ptr<Orthanc::SQLite::Transaction> transaction_; | |
46 | |
47 public: | |
48 Database(const std::string& path); | |
49 | |
50 virtual void Open(); | |
51 | |
52 virtual void Close(); | |
53 | |
54 virtual void AddAttachment(int64_t id, | |
55 const OrthancPluginAttachment& attachment); | |
56 | |
57 virtual void AttachChild(int64_t parent, | |
58 int64_t child) | |
59 { | |
60 base_.AttachChild(parent, child); | |
61 } | |
62 | |
63 virtual void ClearChanges() | |
64 { | |
65 db_.Execute("DELETE FROM Changes"); | |
66 } | |
67 | |
68 virtual void ClearExportedResources() | |
69 { | |
70 db_.Execute("DELETE FROM ExportedResources"); | |
71 } | |
72 | |
73 virtual int64_t CreateResource(const char* publicId, | |
74 OrthancPluginResourceType type) | |
75 { | |
76 return base_.CreateResource(publicId, Orthanc::Plugins::Convert(type)); | |
77 } | |
78 | |
79 virtual void DeleteAttachment(int64_t id, | |
80 int32_t attachment) | |
81 { | |
82 base_.DeleteAttachment(id, static_cast<Orthanc::FileContentType>(attachment)); | |
83 } | |
84 | |
85 virtual void DeleteMetadata(int64_t id, | |
86 int32_t metadataType) | |
87 { | |
88 base_.DeleteMetadata(id, static_cast<Orthanc::MetadataType>(metadataType)); | |
89 } | |
90 | |
91 virtual void DeleteResource(int64_t id); | |
92 | |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
93 virtual void GetAllInternalIds(std::list<int64_t>& target, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
94 OrthancPluginResourceType resourceType) |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
95 { |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
96 base_.GetAllInternalIds(target, Orthanc::Plugins::Convert(resourceType)); |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
97 } |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
98 |
1671 | 99 virtual void GetAllPublicIds(std::list<std::string>& target, |
100 OrthancPluginResourceType resourceType) | |
101 { | |
102 base_.GetAllPublicIds(target, Orthanc::Plugins::Convert(resourceType)); | |
103 } | |
104 | |
105 virtual void GetAllPublicIds(std::list<std::string>& target, | |
106 OrthancPluginResourceType resourceType, | |
107 uint64_t since, | |
108 uint64_t limit) | |
109 { | |
110 base_.GetAllPublicIds(target, Orthanc::Plugins::Convert(resourceType), since, limit); | |
111 } | |
112 | |
113 virtual void GetChanges(bool& done /*out*/, | |
114 int64_t since, | |
115 uint32_t maxResults); | |
116 | |
117 virtual void GetChildrenInternalId(std::list<int64_t>& target /*out*/, | |
118 int64_t id) | |
119 { | |
120 base_.GetChildrenInternalId(target, id); | |
121 } | |
122 | |
123 virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/, | |
124 int64_t id) | |
125 { | |
126 base_.GetChildrenPublicId(target, id); | |
127 } | |
128 | |
129 virtual void GetExportedResources(bool& done /*out*/, | |
130 int64_t since, | |
131 uint32_t maxResults); | |
132 | |
133 virtual void GetLastChange(); | |
134 | |
135 virtual void GetLastExportedResource(); | |
136 | |
137 virtual void GetMainDicomTags(int64_t id); | |
138 | |
139 virtual std::string GetPublicId(int64_t resourceId); | |
140 | |
141 virtual uint64_t GetResourceCount(OrthancPluginResourceType resourceType) | |
142 { | |
143 return base_.GetResourceCount(Orthanc::Plugins::Convert(resourceType)); | |
144 } | |
145 | |
146 virtual OrthancPluginResourceType GetResourceType(int64_t resourceId); | |
147 | |
148 virtual uint64_t GetTotalCompressedSize() | |
149 { | |
150 return base_.GetTotalCompressedSize(); | |
151 } | |
152 | |
153 virtual uint64_t GetTotalUncompressedSize() | |
154 { | |
155 return base_.GetTotalUncompressedSize(); | |
156 } | |
157 | |
158 virtual bool IsExistingResource(int64_t internalId) | |
159 { | |
160 return base_.IsExistingResource(internalId); | |
161 } | |
162 | |
163 virtual bool IsProtectedPatient(int64_t internalId) | |
164 { | |
165 return base_.IsProtectedPatient(internalId); | |
166 } | |
167 | |
168 virtual void ListAvailableMetadata(std::list<int32_t>& target /*out*/, | |
169 int64_t id); | |
170 | |
171 virtual void ListAvailableAttachments(std::list<int32_t>& target /*out*/, | |
172 int64_t id); | |
173 | |
174 virtual void LogChange(const OrthancPluginChange& change); | |
175 | |
176 virtual void LogExportedResource(const OrthancPluginExportedResource& resource); | |
177 | |
178 virtual bool LookupAttachment(int64_t id, | |
179 int32_t contentType); | |
180 | |
181 virtual bool LookupGlobalProperty(std::string& target /*out*/, | |
182 int32_t property) | |
183 { | |
184 return base_.LookupGlobalProperty(target, static_cast<Orthanc::GlobalProperty>(property)); | |
185 } | |
186 | |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
187 virtual void LookupIdentifier(std::list<int64_t>& target /*out*/, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
188 OrthancPluginResourceType level, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
189 uint16_t group, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
190 uint16_t element, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
191 OrthancPluginIdentifierConstraint constraint, |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
192 const char* value) |
1671 | 193 { |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
194 base_.LookupIdentifier(target, Orthanc::Plugins::Convert(level), |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
195 Orthanc::DicomTag(group, element), |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1728
diff
changeset
|
196 Orthanc::Plugins::Convert(constraint), value); |
1671 | 197 } |
198 | |
199 virtual bool LookupMetadata(std::string& target /*out*/, | |
200 int64_t id, | |
201 int32_t metadataType) | |
202 { | |
203 return base_.LookupMetadata(target, id, static_cast<Orthanc::MetadataType>(metadataType)); | |
204 } | |
205 | |
206 virtual bool LookupParent(int64_t& parentId /*out*/, | |
207 int64_t resourceId); | |
208 | |
209 virtual bool LookupResource(int64_t& id /*out*/, | |
210 OrthancPluginResourceType& type /*out*/, | |
211 const char* publicId); | |
212 | |
213 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/) | |
214 { | |
215 return base_.SelectPatientToRecycle(internalId); | |
216 } | |
217 | |
218 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/, | |
219 int64_t patientIdToAvoid) | |
220 { | |
221 return base_.SelectPatientToRecycle(internalId, patientIdToAvoid); | |
222 } | |
223 | |
224 | |
225 virtual void SetGlobalProperty(int32_t property, | |
226 const char* value) | |
227 { | |
228 base_.SetGlobalProperty(static_cast<Orthanc::GlobalProperty>(property), value); | |
229 } | |
230 | |
231 virtual void SetMainDicomTag(int64_t id, | |
232 uint16_t group, | |
233 uint16_t element, | |
234 const char* value) | |
235 { | |
236 base_.SetMainDicomTag(id, Orthanc::DicomTag(group, element), value); | |
237 } | |
238 | |
239 virtual void SetIdentifierTag(int64_t id, | |
240 uint16_t group, | |
241 uint16_t element, | |
242 const char* value) | |
243 { | |
1714 | 244 base_.SetIdentifierTag(id, Orthanc::DicomTag(group, element), value); |
1671 | 245 } |
246 | |
247 virtual void SetMetadata(int64_t id, | |
248 int32_t metadataType, | |
249 const char* value) | |
250 { | |
251 base_.SetMetadata(id, static_cast<Orthanc::MetadataType>(metadataType), value); | |
252 } | |
253 | |
254 virtual void SetProtectedPatient(int64_t internalId, | |
255 bool isProtected) | |
256 { | |
257 base_.SetProtectedPatient(internalId, isProtected); | |
258 } | |
259 | |
260 virtual void StartTransaction(); | |
261 | |
262 virtual void RollbackTransaction(); | |
263 | |
264 virtual void CommitTransaction(); | |
265 | |
266 virtual uint32_t GetDatabaseVersion(); | |
267 | |
268 virtual void UpgradeDatabase(uint32_t targetVersion, | |
269 OrthancPluginStorageArea* storageArea); | |
270 | |
271 virtual void ClearMainDicomTags(int64_t internalId) | |
272 { | |
273 base_.ClearMainDicomTags(internalId); | |
274 } | |
275 }; |