Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPluginDatabase.h @ 1309:8f4487d8f79e db-changes
new files for custom database back-end
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Feb 2015 10:36:22 +0100 |
parents | |
children | 01be1432bda9 |
comparison
equal
deleted
inserted
replaced
1308:f7966e9950e4 | 1309:8f4487d8f79e |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #pragma once | |
34 | |
35 #include "../../OrthancServer/IDatabaseWrapper.h" | |
36 #include "../Include/OrthancCDatabasePlugin.h" | |
37 | |
38 namespace Orthanc | |
39 { | |
40 class OrthancPluginDatabase : public IDatabaseWrapper | |
41 { | |
42 private: | |
43 class Transaction; | |
44 | |
45 typedef std::pair<int64_t, ResourceType> AnswerResource; | |
46 | |
47 _OrthancPluginDatabaseAnswerType type_; | |
48 OrthancPluginDatabaseBackend backend_; | |
49 void* payload_; | |
50 IServerIndexListener* listener_; | |
51 | |
52 std::list<std::string> answerStrings_; | |
53 std::list<int32_t> answerInt32_; | |
54 std::list<int64_t> answerInt64_; | |
55 std::list<AnswerResource> answerResources_; | |
56 std::list<FileInfo> answerAttachments_; | |
57 | |
58 DicomMap* answerDicomMap_; | |
59 std::list<ServerIndexChange>* answerChanges_; | |
60 std::list<ExportedResource>* answerExportedResources_; | |
61 bool* answerDone_; | |
62 | |
63 OrthancPluginDatabaseContext* GetContext() | |
64 { | |
65 return reinterpret_cast<OrthancPluginDatabaseContext*>(this); | |
66 } | |
67 | |
68 void ResetAnswers(); | |
69 | |
70 void ForwardAnswers(std::list<int64_t>& target); | |
71 | |
72 void ForwardAnswers(std::list<std::string>& target); | |
73 | |
74 bool ForwardSingleAnswer(std::string& target); | |
75 | |
76 bool ForwardSingleAnswer(int64_t& target); | |
77 | |
78 public: | |
79 OrthancPluginDatabase(const OrthancPluginDatabaseBackend& backend, | |
80 void *payload) : | |
81 type_(_OrthancPluginDatabaseAnswerType_None), | |
82 backend_(backend), | |
83 payload_(payload), | |
84 listener_(NULL) | |
85 { | |
86 } | |
87 | |
88 virtual void AddAttachment(int64_t id, | |
89 const FileInfo& attachment); | |
90 | |
91 virtual void AttachChild(int64_t parent, | |
92 int64_t child); | |
93 | |
94 virtual void ClearChanges(); | |
95 | |
96 virtual void ClearExportedResources(); | |
97 | |
98 virtual int64_t CreateResource(const std::string& publicId, | |
99 ResourceType type); | |
100 | |
101 virtual void DeleteAttachment(int64_t id, | |
102 FileContentType attachment); | |
103 | |
104 virtual void DeleteMetadata(int64_t id, | |
105 MetadataType type); | |
106 | |
107 virtual void DeleteResource(int64_t id); | |
108 | |
109 virtual void FlushToDisk() | |
110 { | |
111 } | |
112 | |
113 virtual bool HasFlushToDisk() const | |
114 { | |
115 return false; | |
116 } | |
117 | |
118 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, | |
119 int64_t id); | |
120 | |
121 virtual void GetAllPublicIds(std::list<std::string>& target, | |
122 ResourceType resourceType); | |
123 | |
124 | |
125 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, | |
126 bool& done /*out*/, | |
127 int64_t since, | |
128 uint32_t maxResults); | |
129 | |
130 virtual void GetChildrenInternalId(std::list<int64_t>& target, | |
131 int64_t id); | |
132 | |
133 virtual void GetChildrenPublicId(std::list<std::string>& target, | |
134 int64_t id); | |
135 | |
136 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, | |
137 bool& done /*out*/, | |
138 int64_t since, | |
139 uint32_t maxResults); | |
140 | |
141 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/); | |
142 | |
143 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/); | |
144 | |
145 virtual void GetMainDicomTags(DicomMap& map, | |
146 int64_t id); | |
147 | |
148 virtual std::string GetPublicId(int64_t resourceId); | |
149 | |
150 virtual uint64_t GetResourceCount(ResourceType resourceType); | |
151 | |
152 virtual ResourceType GetResourceType(int64_t resourceId); | |
153 | |
154 virtual uint64_t GetTotalCompressedSize(); | |
155 | |
156 virtual uint64_t GetTotalUncompressedSize(); | |
157 | |
158 virtual bool IsExistingResource(int64_t internalId); | |
159 | |
160 virtual bool IsProtectedPatient(int64_t internalId); | |
161 | |
162 virtual void ListAvailableMetadata(std::list<MetadataType>& target, | |
163 int64_t id); | |
164 | |
165 virtual void ListAvailableAttachments(std::list<FileContentType>& target, | |
166 int64_t id); | |
167 | |
168 virtual void LogChange(int64_t internalId, | |
169 const ServerIndexChange& change); | |
170 | |
171 virtual void LogExportedResource(const ExportedResource& resource); | |
172 | |
173 virtual bool LookupAttachment(FileInfo& attachment, | |
174 int64_t id, | |
175 FileContentType contentType); | |
176 | |
177 virtual bool LookupGlobalProperty(std::string& target, | |
178 GlobalProperty property); | |
179 | |
180 virtual void LookupIdentifier(std::list<int64_t>& target, | |
181 const DicomTag& tag, | |
182 const std::string& value); | |
183 | |
184 virtual void LookupIdentifier(std::list<int64_t>& target, | |
185 const std::string& value); | |
186 | |
187 virtual bool LookupMetadata(std::string& target, | |
188 int64_t id, | |
189 MetadataType type); | |
190 | |
191 virtual bool LookupParent(int64_t& parentId, | |
192 int64_t resourceId); | |
193 | |
194 virtual bool LookupResource(int64_t& id, | |
195 ResourceType& type, | |
196 const std::string& publicId); | |
197 | |
198 virtual bool SelectPatientToRecycle(int64_t& internalId); | |
199 | |
200 virtual bool SelectPatientToRecycle(int64_t& internalId, | |
201 int64_t patientIdToAvoid); | |
202 | |
203 virtual void SetGlobalProperty(GlobalProperty property, | |
204 const std::string& value); | |
205 | |
206 virtual void SetMainDicomTag(int64_t id, | |
207 const DicomTag& tag, | |
208 const std::string& value); | |
209 | |
210 virtual void SetMetadata(int64_t id, | |
211 MetadataType type, | |
212 const std::string& value); | |
213 | |
214 virtual void SetProtectedPatient(int64_t internalId, | |
215 bool isProtected); | |
216 | |
217 virtual SQLite::ITransaction* StartTransaction(); | |
218 | |
219 virtual void SetListener(IServerIndexListener& listener) | |
220 { | |
221 listener_ = &listener; | |
222 } | |
223 | |
224 void AnswerReceived(const _OrthancPluginDatabaseAnswer& answer); | |
225 }; | |
226 } |