Mercurial > hg > orthanc-databases
annotate SQLite/Plugins/IndexPlugin.cpp @ 208:696bc0c9fddb
fix build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Mar 2021 15:40:50 +0100 |
parents | d9ef3f16e6a2 |
children | 13a3863df7fa |
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:
157
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 #include "SQLiteIndex.h" | |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
23 #include "../../Framework/Plugins/PluginInitialization.h" |
0 | 24 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
25 #include <Compatibility.h> // For std::unique_ptr<> |
152 | 26 #include <Logging.h> |
0 | 27 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
28 static std::unique_ptr<OrthancDatabases::SQLiteIndex> backend_; |
0 | 29 |
30 | |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
31 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
32 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
33 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 10, 0) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
34 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
35 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
36 #define ORTHANC_PLUGINS_DATABASE_CATCH(context) \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
37 catch (::Orthanc::OrthancException& e) \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
38 { \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
39 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
40 } \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
41 catch (::std::runtime_error& e) \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
42 { \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
43 const std::string message = "Exception in database back-end: " + std::string(e.what()); \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
44 OrthancPluginLogError(context, message.c_str()); \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
45 return OrthancPluginErrorCode_DatabasePlugin; \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
46 } \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
47 catch (...) \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
48 { \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
49 OrthancPluginLogError(context, "Native exception"); \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
50 return OrthancPluginErrorCode_DatabasePlugin; \ |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
51 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
52 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
53 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
54 namespace OrthancDatabases |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
55 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
56 class Output : public IDatabaseBackendOutput |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
57 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
58 private: |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
59 struct Metadata |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
60 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
61 int32_t metadata; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
62 const char* value; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
63 }; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
64 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
65 _OrthancPluginDatabaseAnswerType answerType_; |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
66 std::list<std::string> stringsStore_; |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
67 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
68 std::vector<OrthancPluginAttachment> attachments_; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
69 std::vector<OrthancPluginChange> changes_; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
70 std::vector<OrthancPluginDicomTag> tags_; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
71 std::vector<OrthancPluginExportedResource> exported_; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
72 std::vector<OrthancPluginDatabaseEvent> events_; |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
73 std::vector<int32_t> integers32_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
74 std::vector<int64_t> integers64_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
75 std::vector<OrthancPluginMatchingResource> matches_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
76 std::vector<Metadata> metadata_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
77 std::vector<std::string> stringAnswers_; |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
78 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
79 const char* StoreString(const std::string& s) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
80 { |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
81 stringsStore_.push_back(s); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
82 return stringsStore_.back().c_str(); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
83 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
84 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
85 void SetupAnswerType(_OrthancPluginDatabaseAnswerType type) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
86 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
87 if (answerType_ == _OrthancPluginDatabaseAnswerType_None) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
88 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
89 answerType_ = type; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
90 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
91 else if (answerType_ != type) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
92 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
93 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
94 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
95 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
96 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
97 public: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
98 Output() : |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
99 answerType_(_OrthancPluginDatabaseAnswerType_None) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
100 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
101 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
102 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
103 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
104 void Clear() |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
105 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
106 answerType_ = _OrthancPluginDatabaseAnswerType_None; |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
107 stringsStore_.clear(); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
108 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
109 attachments_.clear(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
110 changes_.clear(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
111 tags_.clear(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
112 exported_.clear(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
113 events_.clear(); |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
114 integers32_.clear(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
115 integers64_.clear(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
116 matches_.clear(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
117 metadata_.clear(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
118 stringAnswers_.clear(); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
119 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
120 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
121 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
122 static OrthancPluginErrorCode ReadAnswersCount(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
123 uint32_t* target /* out */) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
124 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
125 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
126 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
127 size_t size; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
128 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
129 switch (that.answerType_) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
130 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
131 case _OrthancPluginDatabaseAnswerType_None: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
132 size = 0; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
133 break; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
134 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
135 case _OrthancPluginDatabaseAnswerType_Attachment: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
136 size = that.attachments_.size(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
137 break; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
138 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
139 case _OrthancPluginDatabaseAnswerType_Change: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
140 size = that.changes_.size(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
141 break; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
142 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
143 case _OrthancPluginDatabaseAnswerType_DicomTag: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
144 size = that.tags_.size(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
145 break; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
146 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
147 case _OrthancPluginDatabaseAnswerType_ExportedResource: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
148 size = that.exported_.size(); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
149 break; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
150 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
151 case _OrthancPluginDatabaseAnswerType_Int32: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
152 size = that.integers32_.size(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
153 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
154 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
155 case _OrthancPluginDatabaseAnswerType_Int64: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
156 size = that.integers64_.size(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
157 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
158 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
159 case _OrthancPluginDatabaseAnswerType_MatchingResource: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
160 size = that.matches_.size(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
161 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
162 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
163 case _OrthancPluginDatabaseAnswerType_Metadata: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
164 size = that.metadata_.size(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
165 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
166 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
167 case _OrthancPluginDatabaseAnswerType_String: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
168 size = that.stringAnswers_.size(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
169 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
170 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
171 default: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
172 return OrthancPluginErrorCode_InternalError; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
173 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
174 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
175 *target = static_cast<uint32_t>(size); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
176 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
177 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
178 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
179 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
180 static OrthancPluginErrorCode ReadAnswerAttachment(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
181 OrthancPluginAttachment* target /* out */, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
182 uint32_t index) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
183 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
184 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
185 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
186 if (index < that.attachments_.size()) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
187 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
188 *target = that.attachments_[index]; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
189 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
190 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
191 else |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
192 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
193 return OrthancPluginErrorCode_ParameterOutOfRange; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
194 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
195 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
196 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
197 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
198 static OrthancPluginErrorCode ReadAnswerChange(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
199 OrthancPluginChange* target /* out */, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
200 uint32_t index) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
201 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
202 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
203 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
204 if (index < that.changes_.size()) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
205 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
206 *target = that.changes_[index]; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
207 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
208 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
209 else |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
210 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
211 return OrthancPluginErrorCode_ParameterOutOfRange; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
212 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
213 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
214 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
215 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
216 static OrthancPluginErrorCode ReadAnswerDicomTag(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
217 uint16_t* group, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
218 uint16_t* element, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
219 const char** value, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
220 uint32_t index) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
221 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
222 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
223 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
224 if (index < that.tags_.size()) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
225 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
226 const OrthancPluginDicomTag& tag = that.tags_[index]; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
227 *group = tag.group; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
228 *element = tag.element; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
229 *value = tag.value; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
230 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
231 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
232 else |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
233 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
234 return OrthancPluginErrorCode_ParameterOutOfRange; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
235 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
236 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
237 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
238 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
239 static OrthancPluginErrorCode ReadAnswerExportedResource(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
240 OrthancPluginExportedResource* target /* out */, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
241 uint32_t index) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
242 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
243 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
244 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
245 if (index < that.exported_.size()) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
246 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
247 *target = that.exported_[index]; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
248 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
249 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
250 else |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
251 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
252 return OrthancPluginErrorCode_ParameterOutOfRange; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
253 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
254 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
255 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
256 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
257 static OrthancPluginErrorCode ReadAnswerInt32(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
258 int32_t* target, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
259 uint32_t index) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
260 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
261 const Output& that = *reinterpret_cast<const Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
262 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
263 if (index < that.integers32_.size()) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
264 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
265 *target = that.integers32_[index]; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
266 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
267 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
268 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
269 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
270 return OrthancPluginErrorCode_ParameterOutOfRange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
271 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
272 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
273 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
274 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
275 static OrthancPluginErrorCode ReadAnswerInt64(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
276 int64_t* target, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
277 uint32_t index) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
278 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
279 const Output& that = *reinterpret_cast<const Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
280 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
281 if (index < that.integers64_.size()) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
282 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
283 *target = that.integers64_[index]; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
284 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
285 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
286 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
287 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
288 return OrthancPluginErrorCode_ParameterOutOfRange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
289 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
290 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
291 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
292 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
293 static OrthancPluginErrorCode ReadAnswerMatchingResource(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
294 OrthancPluginMatchingResource* target, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
295 uint32_t index) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
296 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
297 const Output& that = *reinterpret_cast<const Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
298 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
299 if (index < that.matches_.size()) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
300 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
301 *target = that.matches_[index]; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
302 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
303 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
304 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
305 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
306 return OrthancPluginErrorCode_ParameterOutOfRange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
307 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
308 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
309 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
310 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
311 static OrthancPluginErrorCode ReadAnswerMetadata(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
312 int32_t* metadata, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
313 const char** value, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
314 uint32_t index) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
315 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
316 const Output& that = *reinterpret_cast<const Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
317 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
318 if (index < that.metadata_.size()) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
319 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
320 const Metadata& tmp = that.metadata_[index]; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
321 *metadata = tmp.metadata; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
322 *value = tmp.value; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
323 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
324 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
325 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
326 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
327 return OrthancPluginErrorCode_ParameterOutOfRange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
328 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
329 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
330 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
331 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
332 static OrthancPluginErrorCode ReadAnswerString(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
333 const char** target, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
334 uint32_t index) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
335 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
336 const Output& that = *reinterpret_cast<const Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
337 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
338 if (index < that.stringAnswers_.size()) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
339 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
340 *target = that.stringAnswers_[index].c_str(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
341 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
342 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
343 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
344 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
345 return OrthancPluginErrorCode_ParameterOutOfRange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
346 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
347 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
348 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
349 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
350 static OrthancPluginErrorCode ReadEventsCount(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
351 uint32_t* target /* out */) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
352 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
353 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
354 *target = static_cast<uint32_t>(that.events_.size()); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
355 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
356 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
357 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
358 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
359 static OrthancPluginErrorCode ReadEvent(OrthancPluginDatabaseTransaction* transaction, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
360 OrthancPluginDatabaseEvent* event /* out */, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
361 uint32_t index) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
362 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
363 const Output& that = *reinterpret_cast<const Output*>(transaction); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
364 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
365 if (index < that.events_.size()) |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
366 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
367 *event = that.events_[index]; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
368 return OrthancPluginErrorCode_Success; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
369 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
370 else |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
371 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
372 return OrthancPluginErrorCode_ParameterOutOfRange; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
373 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
374 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
375 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
376 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
377 virtual void SignalDeletedAttachment(const std::string& uuid, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
378 int32_t contentType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
379 uint64_t uncompressedSize, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
380 const std::string& uncompressedHash, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
381 int32_t compressionType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
382 uint64_t compressedSize, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
383 const std::string& compressedHash) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
384 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
385 OrthancPluginDatabaseEvent event; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
386 event.type = OrthancPluginDatabaseEventType_DeletedAttachment; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
387 event.content.attachment.uuid = StoreString(uuid); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
388 event.content.attachment.contentType = contentType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
389 event.content.attachment.uncompressedSize = uncompressedSize; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
390 event.content.attachment.uncompressedHash = StoreString(uncompressedHash); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
391 event.content.attachment.compressionType = compressionType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
392 event.content.attachment.compressedSize = compressedSize; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
393 event.content.attachment.compressedHash = StoreString(compressedHash); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
394 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
395 events_.push_back(event); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
396 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
397 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
398 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
399 virtual void SignalDeletedResource(const std::string& publicId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
400 OrthancPluginResourceType resourceType) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
401 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
402 OrthancPluginDatabaseEvent event; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
403 event.type = OrthancPluginDatabaseEventType_DeletedResource; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
404 event.content.resource.level = resourceType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
405 event.content.resource.publicId = StoreString(publicId); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
406 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
407 events_.push_back(event); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
408 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
409 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
410 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
411 virtual void SignalRemainingAncestor(const std::string& ancestorId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
412 OrthancPluginResourceType ancestorType) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
413 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
414 OrthancPluginDatabaseEvent event; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
415 event.type = OrthancPluginDatabaseEventType_RemainingAncestor; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
416 event.content.resource.level = ancestorType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
417 event.content.resource.publicId = StoreString(ancestorId); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
418 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
419 events_.push_back(event); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
420 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
421 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
422 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
423 virtual void AnswerAttachment(const std::string& uuid, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
424 int32_t contentType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
425 uint64_t uncompressedSize, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
426 const std::string& uncompressedHash, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
427 int32_t compressionType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
428 uint64_t compressedSize, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
429 const std::string& compressedHash) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
430 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
431 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Attachment); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
432 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
433 OrthancPluginAttachment attachment; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
434 attachment.uuid = StoreString(uuid); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
435 attachment.contentType = contentType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
436 attachment.uncompressedSize = uncompressedSize; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
437 attachment.uncompressedHash = StoreString(uncompressedHash); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
438 attachment.compressionType = compressionType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
439 attachment.compressedSize = compressedSize; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
440 attachment.compressedHash = StoreString(compressedHash); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
441 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
442 attachments_.push_back(attachment); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
443 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
444 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
445 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
446 virtual void AnswerChange(int64_t seq, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
447 int32_t changeType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
448 OrthancPluginResourceType resourceType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
449 const std::string& publicId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
450 const std::string& date) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
451 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
452 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Change); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
453 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
454 OrthancPluginChange change; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
455 change.seq = seq; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
456 change.changeType = changeType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
457 change.resourceType = resourceType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
458 change.publicId = StoreString(publicId); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
459 change.date = StoreString(date); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
460 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
461 changes_.push_back(change); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
462 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
463 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
464 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
465 virtual void AnswerDicomTag(uint16_t group, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
466 uint16_t element, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
467 const std::string& value) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
468 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
469 SetupAnswerType(_OrthancPluginDatabaseAnswerType_DicomTag); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
470 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
471 OrthancPluginDicomTag tag; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
472 tag.group = group; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
473 tag.element = element; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
474 tag.value = StoreString(value); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
475 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
476 tags_.push_back(tag); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
477 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
478 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
479 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
480 virtual void AnswerExportedResource(int64_t seq, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
481 OrthancPluginResourceType resourceType, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
482 const std::string& publicId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
483 const std::string& modality, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
484 const std::string& date, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
485 const std::string& patientId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
486 const std::string& studyInstanceUid, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
487 const std::string& seriesInstanceUid, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
488 const std::string& sopInstanceUid) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
489 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
490 SetupAnswerType(_OrthancPluginDatabaseAnswerType_ExportedResource); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
491 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
492 OrthancPluginExportedResource exported; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
493 exported.seq = seq; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
494 exported.resourceType = resourceType; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
495 exported.publicId = StoreString(publicId); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
496 exported.modality = StoreString(modality); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
497 exported.date = StoreString(date); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
498 exported.patientId = StoreString(patientId); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
499 exported.studyInstanceUid = StoreString(studyInstanceUid); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
500 exported.seriesInstanceUid = StoreString(seriesInstanceUid); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
501 exported.sopInstanceUid = StoreString(sopInstanceUid); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
502 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
503 exported_.push_back(exported); |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
504 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
505 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
506 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
507 virtual void AnswerMatchingResource(const std::string& resourceId) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
508 { |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
509 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
510 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
511 OrthancPluginMatchingResource match; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
512 match.resourceId = StoreString(resourceId); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
513 match.someInstanceId = NULL; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
514 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
515 matches_.push_back(match); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
516 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
517 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
518 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
519 virtual void AnswerMatchingResource(const std::string& resourceId, |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
520 const std::string& someInstanceId) ORTHANC_OVERRIDE |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
521 { |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
522 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
523 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
524 OrthancPluginMatchingResource match; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
525 match.resourceId = StoreString(resourceId); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
526 match.someInstanceId = StoreString(someInstanceId); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
527 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
528 matches_.push_back(match); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
529 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
530 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
531 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
532 void AnswerIntegers32(const std::list<int32_t>& values) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
533 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
534 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int32); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
535 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
536 integers32_.reserve(values.size()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
537 std::copy(std::begin(values), std::end(values), std::back_inserter(integers32_)); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
538 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
539 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
540 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
541 void AnswerIntegers64(const std::list<int64_t>& values) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
542 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
543 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
544 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
545 integers64_.reserve(values.size()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
546 std::copy(std::begin(values), std::end(values), std::back_inserter(integers64_)); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
547 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
548 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
549 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
550 void AnswerMetadata(int32_t metadata, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
551 const std::string& value) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
552 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
553 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Metadata); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
554 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
555 Metadata tmp; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
556 tmp.metadata = metadata; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
557 tmp.value = StoreString(value); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
558 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
559 metadata_.push_back(tmp); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
560 } |
208 | 561 |
562 | |
563 void AnswerStrings(const std::list<std::string>& values) | |
564 { | |
565 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String); | |
566 | |
567 stringAnswers_.reserve(values.size()); | |
568 std::copy(std::begin(values), std::end(values), std::back_inserter(stringAnswers_)); | |
569 } | |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
570 }; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
571 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
572 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
573 class Factory : public IDatabaseBackendOutput::IFactory |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
574 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
575 public: |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
576 Factory() |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
577 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
578 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
579 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
580 virtual IDatabaseBackendOutput* CreateOutput() |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
581 { |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
582 return new Output; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
583 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
584 }; |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
585 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
586 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
587 class Transaction : public boost::noncopyable |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
588 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
589 private: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
590 IDatabaseBackend& backend_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
591 std::unique_ptr<Output> output_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
592 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
593 public: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
594 Transaction(IDatabaseBackend& backend) : |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
595 backend_(backend), |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
596 output_(new Output) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
597 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
598 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
599 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
600 IDatabaseBackend& GetBackend() const |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
601 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
602 return backend_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
603 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
604 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
605 Output& GetOutput() const |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
606 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
607 return *output_; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
608 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
609 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
610 OrthancPluginContext* GetContext() const |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
611 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
612 return backend_.GetContext(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
613 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
614 }; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
615 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
616 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
617 static OrthancPluginErrorCode Open(void* database) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
618 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
619 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(database); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
620 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
621 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
622 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
623 backend->Open(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
624 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
625 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
626 ORTHANC_PLUGINS_DATABASE_CATCH(backend->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
627 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
628 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
629 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
630 static OrthancPluginErrorCode Close(void* database) |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
631 { |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
632 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(database); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
633 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
634 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
635 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
636 backend->Close(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
637 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
638 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
639 ORTHANC_PLUGINS_DATABASE_CATCH(backend->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
640 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
641 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
642 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
643 static OrthancPluginErrorCode DestructDatabase(void* database) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
644 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
645 // Nothing to delete, as this plugin uses a singleton to store backend |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
646 if (database == NULL) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
647 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
648 return OrthancPluginErrorCode_InternalError; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
649 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
650 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
651 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
652 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
653 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
654 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
655 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
656 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
657 static OrthancPluginErrorCode GetDatabaseVersion(void* database, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
658 uint32_t* version) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
659 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
660 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(database); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
661 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
662 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
663 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
664 *version = backend->GetDatabaseVersion(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
665 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
666 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
667 ORTHANC_PLUGINS_DATABASE_CATCH(backend->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
668 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
669 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
670 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
671 static OrthancPluginErrorCode UpgradeDatabase(void* database, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
672 OrthancPluginStorageArea* storageArea, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
673 uint32_t targetVersion) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
674 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
675 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(database); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
676 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
677 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
678 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
679 backend->UpgradeDatabase(targetVersion, storageArea); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
680 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
681 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
682 ORTHANC_PLUGINS_DATABASE_CATCH(backend->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
683 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
684 |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
685 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
686 static OrthancPluginErrorCode StartTransaction(void* database, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
687 OrthancPluginDatabaseTransaction** target /* out */, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
688 OrthancPluginDatabaseTransactionType type) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
689 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
690 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(database); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
691 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
692 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
693 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
694 std::unique_ptr<Transaction> transaction(new Transaction(*backend)); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
695 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
696 switch (type) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
697 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
698 case OrthancPluginDatabaseTransactionType_ReadOnly: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
699 backend->StartTransaction(TransactionType_ReadOnly); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
700 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
701 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
702 case OrthancPluginDatabaseTransactionType_ReadWrite: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
703 backend->StartTransaction(TransactionType_ReadWrite); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
704 break; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
705 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
706 default: |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
707 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
708 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
709 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
710 *target = reinterpret_cast<OrthancPluginDatabaseTransaction*>(transaction.release()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
711 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
712 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
713 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
714 ORTHANC_PLUGINS_DATABASE_CATCH(backend->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
715 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
716 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
717 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
718 static OrthancPluginErrorCode DestructTransaction(OrthancPluginDatabaseTransaction* transaction) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
719 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
720 if (transaction == NULL) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
721 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
722 return OrthancPluginErrorCode_NullPointer; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
723 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
724 else |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
725 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
726 delete reinterpret_cast<Output*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
727 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
728 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
729 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
730 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
731 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
732 static OrthancPluginErrorCode Rollback(OrthancPluginDatabaseTransaction* transaction) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
733 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
734 Transaction* t = reinterpret_cast<Transaction*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
735 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
736 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
737 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
738 t->GetBackend().RollbackTransaction(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
739 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
740 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
741 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
742 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
743 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
744 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
745 static OrthancPluginErrorCode Commit(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
746 int64_t fileSizeDelta /* TODO - not used? */) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
747 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
748 Transaction* t = reinterpret_cast<Transaction*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
749 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
750 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
751 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
752 t->GetBackend().CommitTransaction(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
753 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
754 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
755 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
756 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
757 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
758 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
759 static OrthancPluginErrorCode AddAttachment(OrthancPluginDatabaseTransaction* transaction, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
760 int64_t id, |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
761 const OrthancPluginAttachment* attachment) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
762 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
763 Transaction* t = reinterpret_cast<Transaction*>(transaction); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
764 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
765 try |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
766 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
767 t->GetOutput().Clear(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
768 t->GetBackend().AddAttachment(id, *attachment); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
769 return OrthancPluginErrorCode_Success; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
770 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
771 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
772 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
773 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
774 |
208 | 775 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction) |
776 { | |
777 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
778 | |
779 try | |
780 { | |
781 t->GetOutput().Clear(); | |
782 t->GetBackend().ClearChanges(); | |
783 return OrthancPluginErrorCode_Success; | |
784 } | |
785 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
786 } | |
787 | |
788 | |
789 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction) | |
790 { | |
791 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
792 | |
793 try | |
794 { | |
795 t->GetOutput().Clear(); | |
796 t->GetBackend().ClearExportedResources(); | |
797 return OrthancPluginErrorCode_Success; | |
798 } | |
799 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
800 } | |
801 | |
802 | |
803 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
804 int64_t resourceId) | |
805 { | |
806 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
807 | |
808 try | |
809 { | |
810 t->GetOutput().Clear(); | |
811 t->GetBackend().ClearMainDicomTags(resourceId); | |
812 return OrthancPluginErrorCode_Success; | |
813 } | |
814 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
815 } | |
816 | |
817 | |
818 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction, | |
819 OrthancPluginCreateInstanceResult* target /* out */, | |
820 const char* hashPatient, | |
821 const char* hashStudy, | |
822 const char* hashSeries, | |
823 const char* hashInstance) | |
824 { | |
825 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
826 | |
827 try | |
828 { | |
829 t->GetOutput().Clear(); | |
830 t->GetBackend().CreateInstance(*target, hashPatient, hashStudy, hashSeries, hashInstance); | |
831 return OrthancPluginErrorCode_Success; | |
832 } | |
833 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
834 } | |
835 | |
836 | |
837 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction, | |
838 int64_t id, | |
839 int32_t contentType) | |
840 { | |
841 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
842 | |
843 try | |
844 { | |
845 t->GetOutput().Clear(); | |
846 t->GetBackend().DeleteAttachment(t->GetOutput(), id, contentType); | |
847 return OrthancPluginErrorCode_Success; | |
848 } | |
849 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
850 } | |
851 | |
852 | |
853 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction, | |
854 int64_t id, | |
855 int32_t metadataType) | |
856 { | |
857 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
858 | |
859 try | |
860 { | |
861 t->GetOutput().Clear(); | |
862 t->GetBackend().DeleteMetadata(id, metadataType); | |
863 return OrthancPluginErrorCode_Success; | |
864 } | |
865 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
866 } | |
867 | |
868 | |
869 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction, | |
870 int64_t id) | |
871 { | |
872 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
873 | |
874 try | |
875 { | |
876 t->GetOutput().Clear(); | |
877 t->GetBackend().DeleteResource(t->GetOutput(), id); | |
878 return OrthancPluginErrorCode_Success; | |
879 } | |
880 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
881 } | |
882 | |
883 | |
884 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction, | |
885 int64_t id) | |
886 { | |
887 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
888 | |
889 try | |
890 { | |
891 t->GetOutput().Clear(); | |
892 | |
893 std::map<int32_t, std::string> values; | |
894 t->GetBackend().GetAllMetadata(values, id); | |
895 | |
896 for (std::map<int32_t, std::string>::const_iterator it = values.begin(); it != values.end(); ++it) | |
897 { | |
898 t->GetOutput().AnswerMetadata(it->first, it->second); | |
899 } | |
900 | |
901 return OrthancPluginErrorCode_Success; | |
902 } | |
903 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
904 } | |
905 | |
906 | |
907 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction, | |
908 OrthancPluginResourceType resourceType) | |
909 { | |
910 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
911 | |
912 try | |
913 { | |
914 t->GetOutput().Clear(); | |
915 | |
916 std::list<std::string> values; | |
917 t->GetBackend().GetAllPublicIds(values, resourceType); | |
918 t->GetOutput().AnswerStrings(values); | |
919 | |
920 return OrthancPluginErrorCode_Success; | |
921 } | |
922 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
923 } | |
924 | |
925 | |
926 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction, | |
927 OrthancPluginResourceType resourceType, | |
928 uint64_t since, | |
929 uint64_t limit) | |
930 { | |
931 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
932 | |
933 try | |
934 { | |
935 t->GetOutput().Clear(); | |
936 | |
937 std::list<std::string> values; | |
938 t->GetBackend().GetAllPublicIds(values, resourceType, since, limit); | |
939 t->GetOutput().AnswerStrings(values); | |
940 | |
941 return OrthancPluginErrorCode_Success; | |
942 } | |
943 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
944 } | |
945 | |
946 | |
947 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction, | |
948 uint8_t* targetDone /* out */, | |
949 int64_t since, | |
950 uint32_t maxResults) | |
951 { | |
952 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
953 | |
954 try | |
955 { | |
956 t->GetOutput().Clear(); | |
957 | |
958 bool done; | |
959 t->GetBackend().GetChanges(t->GetOutput(), done, since, maxResults); | |
960 *targetDone = (done ? 1 : 0); | |
961 | |
962 return OrthancPluginErrorCode_Success; | |
963 } | |
964 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
965 } | |
966 | |
967 | |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
968 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
969 static void RegisterV3(IDatabaseBackend& database) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
970 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
971 OrthancPluginDatabaseBackendV3 params; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
972 memset(¶ms, 0, sizeof(params)); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
973 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
974 params.readAnswersCount = Output::ReadAnswersCount; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
975 params.readAnswerAttachment = Output::ReadAnswerAttachment; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
976 params.readAnswerChange = Output::ReadAnswerChange; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
977 params.readAnswerDicomTag = Output::ReadAnswerDicomTag; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
978 params.readAnswerExportedResource = Output::ReadAnswerExportedResource; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
979 params.readAnswerInt32 = Output::ReadAnswerInt32; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
980 params.readAnswerInt64 = Output::ReadAnswerInt64; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
981 params.readAnswerMatchingResource = Output::ReadAnswerMatchingResource; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
982 params.readAnswerMetadata = Output::ReadAnswerMetadata; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
983 params.readAnswerString = Output::ReadAnswerString; |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
984 |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
985 params.readEventsCount = Output::ReadEventsCount; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
986 params.readEvent = Output::ReadEvent; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
987 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
988 params.open = Open; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
989 params.close = Close; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
990 params.destructDatabase = DestructDatabase; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
991 params.getDatabaseVersion = GetDatabaseVersion; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
992 params.upgradeDatabase = UpgradeDatabase; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
993 params.startTransaction = StartTransaction; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
994 params.destructTransaction = DestructTransaction; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
995 params.rollback = Rollback; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
996 params.commit = Commit; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
997 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
998 params.addAttachment = AddAttachment; |
208 | 999 params.clearChanges = ClearChanges; |
1000 params.clearExportedResources = ClearExportedResources; | |
1001 params.clearMainDicomTags = ClearMainDicomTags; | |
1002 params.createInstance = CreateInstance; | |
1003 params.deleteAttachment = DeleteAttachment; | |
1004 params.deleteMetadata = DeleteMetadata; | |
1005 params.deleteResource = DeleteResource; | |
1006 params.getAllMetadata = GetAllMetadata; | |
1007 params.getAllPublicIds = GetAllPublicIds; | |
1008 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1009 params.getChanges = GetChanges; | |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1010 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1011 OrthancPluginContext* context = database.GetContext(); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1012 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1013 if (OrthancPluginRegisterDatabaseBackendV3(context, ¶ms, sizeof(params), &database) != OrthancPluginErrorCode_Success) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1014 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1015 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend"); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1016 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1017 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1018 database.SetOutputFactory(new Factory); |
206
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1019 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1020 } |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1021 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1022 # endif |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1023 #endif |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1024 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1025 |
6dcf57074dd4
starting OrthancPluginDatabaseBackendV3 wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
1026 |
0 | 1027 extern "C" |
1028 { | |
1029 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
1030 { | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
1031 if (!OrthancDatabases::InitializePlugin(context, "SQLite", true)) |
0 | 1032 { |
1033 return -1; | |
1034 } | |
1035 | |
1036 #if 0 | |
62
eedd082355f9
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
1037 OrthancPlugins::OrthancConfiguration configuration; |
0 | 1038 |
1039 if (!configuration.IsSection("SQLite")) | |
1040 { | |
1041 LOG(WARNING) << "No available configuration for the SQLite index plugin"; | |
1042 return 0; | |
1043 } | |
1044 | |
1045 OrthancPlugins::OrthancConfiguration sqlite; | |
1046 configuration.GetSection(sqlite, "SQLite"); | |
1047 | |
1048 bool enable; | |
1049 if (!sqlite.LookupBooleanValue(enable, "EnableIndex") || | |
1050 !enable) | |
1051 { | |
1052 LOG(WARNING) << "The SQLite index is currently disabled, set \"EnableIndex\" " | |
1053 << "to \"true\" in the \"SQLite\" section of the configuration file of Orthanc"; | |
1054 return 0; | |
1055 } | |
1056 #endif | |
1057 | |
1058 try | |
1059 { | |
1060 /* Create the database back-end */ | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1061 backend_.reset(new OrthancDatabases::SQLiteIndex(context, "index.db")); // TODO parameter |
0 | 1062 |
1063 /* Register the SQLite index into Orthanc */ | |
207
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1064 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1065 bool hasLoadedV3 = false; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1066 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1067 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1068 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 10, 0) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1069 if (OrthancPluginCheckVersionAdvanced(context, 1, 10, 0) == 1) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1070 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1071 RegisterV3(*backend_); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1072 hasLoadedV3 = true; |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1073 } |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1074 # endif |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1075 #endif |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1076 |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1077 if (!hasLoadedV3) |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1078 { |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1079 OrthancDatabases::DatabaseBackendAdapterV2::Register(*backend_); |
d9ef3f16e6a2
wrapping transactions in API v3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
206
diff
changeset
|
1080 } |
0 | 1081 } |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1082 catch (Orthanc::OrthancException& e) |
0 | 1083 { |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1084 LOG(ERROR) << e.What(); |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1085 return -1; |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1086 } |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1087 catch (...) |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1088 { |
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1089 LOG(ERROR) << "Native exception while initializing the plugin"; |
0 | 1090 return -1; |
1091 } | |
1092 | |
1093 return 0; | |
1094 } | |
1095 | |
1096 | |
1097 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
1098 { | |
2
17bce6a07b2b
storage plugin skeletons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1099 LOG(WARNING) << "SQLite index is finalizing"; |
0 | 1100 backend_.reset(NULL); |
1101 } | |
1102 | |
1103 | |
1104 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
1105 { | |
1106 return "sqlite-index"; | |
1107 } | |
1108 | |
1109 | |
1110 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
1111 { | |
1112 return ORTHANC_PLUGIN_VERSION; | |
1113 } | |
1114 } |