annotate Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2850:9f949922d603

fix
author am@osimis.io
date Mon, 01 Oct 2018 14:19:10 +0200
parents dd3914a44b87
children 859e880ac9a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2268
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
2850
am@osimis.io
parents: 2848
diff changeset
23 *
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "OrthancPluginCppWrapper.h"
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include <json/reader.h>
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
37 #include <json/writer.h>
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace OrthancPlugins
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
2062
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
42 void MemoryBuffer::Check(OrthancPluginErrorCode code)
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
43 {
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
44 if (code != OrthancPluginErrorCode_Success)
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
45 {
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
46 // Prevent using garbage information
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
47 buffer_.data = NULL;
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
48 buffer_.size = 0;
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
49 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code);
2062
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
50 }
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
51 }
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
52
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
53
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
54 bool MemoryBuffer::CheckHttp(OrthancPluginErrorCode code)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
55 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
56 if (code != OrthancPluginErrorCode_Success)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
57 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
58 // Prevent using garbage information
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
59 buffer_.data = NULL;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
60 buffer_.size = 0;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
61 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
62
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
63 if (code == OrthancPluginErrorCode_Success)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
64 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
65 return true;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
66 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
67 else if (code == OrthancPluginErrorCode_UnknownResource ||
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
68 code == OrthancPluginErrorCode_InexistentItem)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
69 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
70 return false;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
71 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
72 else
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
73 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
74 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code);
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
75 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
76 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
77
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
78
2850
am@osimis.io
parents: 2848
diff changeset
79 MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) :
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 context_(context)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 buffer_.data = NULL;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 buffer_.size = 0;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 void MemoryBuffer::Clear()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 if (buffer_.data != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 OrthancPluginFreeMemoryBuffer(context_, &buffer_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 buffer_.data = NULL;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 buffer_.size = 0;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 void MemoryBuffer::Assign(OrthancPluginMemoryBuffer& other)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 buffer_.data = other.data;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 buffer_.size = other.size;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 other.data = NULL;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 other.size = 0;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
2792
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
110 OrthancPluginMemoryBuffer MemoryBuffer::Release()
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
111 {
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
112 OrthancPluginMemoryBuffer result = buffer_;
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
113
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
114 buffer_.data = NULL;
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
115 buffer_.size = 0;
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
116
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
117 return result;
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
118 }
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
119
57e2d65d37ce OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
120
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 void MemoryBuffer::ToString(std::string& target) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 if (buffer_.size == 0)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 target.clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 target.assign(reinterpret_cast<const char*>(buffer_.data), buffer_.size);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 void MemoryBuffer::ToJson(Json::Value& target) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 if (buffer_.data == NULL ||
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 buffer_.size == 0)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
139 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 const char* tmp = reinterpret_cast<const char*>(buffer_.data);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 Json::Reader reader;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (!reader.parse(tmp, tmp + buffer_.size, target))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
148 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 bool MemoryBuffer::RestApiGet(const std::string& uri,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 bool applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 if (applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
160 return CheckHttp(OrthancPluginRestApiGetAfterPlugins(context_, &buffer_, uri.c_str()));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
164 return CheckHttp(OrthancPluginRestApiGet(context_, &buffer_, uri.c_str()));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 bool MemoryBuffer::RestApiPost(const std::string& uri,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 const char* body,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 size_t bodySize,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 bool applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 if (applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
178 return CheckHttp(OrthancPluginRestApiPostAfterPlugins(context_, &buffer_, uri.c_str(), body, bodySize));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
182 return CheckHttp(OrthancPluginRestApiPost(context_, &buffer_, uri.c_str(), body, bodySize));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 bool MemoryBuffer::RestApiPut(const std::string& uri,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 const char* body,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 size_t bodySize,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 bool applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 if (applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
196 return CheckHttp(OrthancPluginRestApiPutAfterPlugins(context_, &buffer_, uri.c_str(), body, bodySize));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 {
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
200 return CheckHttp(OrthancPluginRestApiPut(context_, &buffer_, uri.c_str(), body, bodySize));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
205 bool MemoryBuffer::RestApiPost(const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
206 const Json::Value& body,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
207 bool applyPlugins)
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
208 {
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
209 Json::FastWriter writer;
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
210 return RestApiPost(uri, writer.write(body), applyPlugins);
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
211 }
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
212
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
213
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
214 bool MemoryBuffer::RestApiPut(const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
215 const Json::Value& body,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
216 bool applyPlugins)
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
217 {
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
218 Json::FastWriter writer;
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
219 return RestApiPut(uri, writer.write(body), applyPlugins);
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
220 }
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
221
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
222
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
223 void MemoryBuffer::CreateDicom(const Json::Value& tags,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
224 OrthancPluginCreateDicomFlags flags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
225 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
226 Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
227
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
228 Json::FastWriter writer;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
229 std::string s = writer.write(tags);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
230
2062
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
231 Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags));
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
232 }
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
233
2850
am@osimis.io
parents: 2848
diff changeset
234 void MemoryBuffer::CreateDicom(const Json::Value& tags,
am@osimis.io
parents: 2848
diff changeset
235 const OrthancImage& pixelData,
am@osimis.io
parents: 2848
diff changeset
236 OrthancPluginCreateDicomFlags flags)
2848
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
237 {
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
238 Clear();
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
239
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
240 Json::FastWriter writer;
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
241 std::string s = writer.write(tags);
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
242
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
243 Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), pixelData.GetObject(), flags));
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
244 }
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
245
2062
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
246
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
247 void MemoryBuffer::ReadFile(const std::string& path)
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
248 {
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
249 Clear();
40ffd0e8676a generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
250 Check(OrthancPluginReadFile(context_, &buffer_, path.c_str()));
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
251 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
252
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2058
diff changeset
253
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
254 void MemoryBuffer::GetDicomQuery(const OrthancPluginWorklistQuery* query)
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
255 {
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
256 Clear();
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
257 Check(OrthancPluginWorklistGetDicomQuery(context_, &buffer_, query));
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
258 }
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
259
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
260
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
261 void OrthancString::Assign(char* str)
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
263 if (str == NULL)
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
264 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
265 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
266 }
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
267 else
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
268 {
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
269 Clear();
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
270 str_ = str;
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
271 }
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 void OrthancString::Clear()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 if (str_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 OrthancPluginFreeString(context_, str_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 str_ = NULL;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 void OrthancString::ToString(std::string& target) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 if (str_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 target.clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 target.assign(str_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 void OrthancString::ToJson(Json::Value& target) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 if (str_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 OrthancPluginLogError(context_, "Cannot convert an empty memory buffer to JSON");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
303 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 Json::Reader reader;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 if (!reader.parse(str_, target))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
310 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
313
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
314
2206
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
315 void MemoryBuffer::DicomToJson(Json::Value& target,
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
316 OrthancPluginDicomToJsonFormat format,
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
317 OrthancPluginDicomToJsonFlags flags,
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
318 uint32_t maxStringLength)
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
319 {
2206
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
320 OrthancString str(context_);
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
321 str.Assign(OrthancPluginDicomBufferToJson(context_, GetData(), GetSize(), format, flags, maxStringLength));
27106f7e3759 more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2205
diff changeset
322 str.ToJson(target);
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
323 }
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
324
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
325
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
326 bool MemoryBuffer::HttpGet(const std::string& url,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
327 const std::string& username,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
328 const std::string& password)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
329 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
330 Clear();
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
331 return CheckHttp(OrthancPluginHttpGet(context_, &buffer_, url.c_str(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
332 username.empty() ? NULL : username.c_str(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
333 password.empty() ? NULL : password.c_str()));
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
334 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
335
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
336
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
337 bool MemoryBuffer::HttpPost(const std::string& url,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
338 const std::string& body,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
339 const std::string& username,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
340 const std::string& password)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
341 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
342 Clear();
2267
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
343 return CheckHttp(OrthancPluginHttpPost(context_, &buffer_, url.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
344 body.c_str(), body.size(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
345 username.empty() ? NULL : username.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
346 password.empty() ? NULL : password.c_str()));
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
347 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
348
2850
am@osimis.io
parents: 2848
diff changeset
349
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
350 bool MemoryBuffer::HttpPut(const std::string& url,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
351 const std::string& body,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
352 const std::string& username,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
353 const std::string& password)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
354 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
355 Clear();
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
356 return CheckHttp(OrthancPluginHttpPut(context_, &buffer_, url.c_str(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
357 body.empty() ? NULL : body.c_str(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
358 body.size(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
359 username.empty() ? NULL : username.c_str(),
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
360 password.empty() ? NULL : password.c_str()));
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
361 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
362
2796
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
363
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
364 void MemoryBuffer::GetDicomInstance(const std::string& instanceId)
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
365 {
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
366 Clear();
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
367 Check(OrthancPluginGetDicomForInstance(context_, &buffer_, instanceId.c_str()));
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
368 }
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
369
4df3c64402ba MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2792
diff changeset
370
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
371 bool HttpDelete(OrthancPluginContext* context_,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
372 const std::string& url,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
373 const std::string& username,
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
374 const std::string& password)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
375 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
376 OrthancPluginErrorCode error = OrthancPluginHttpDelete
2850
am@osimis.io
parents: 2848
diff changeset
377 (context_, url.c_str(),
am@osimis.io
parents: 2848
diff changeset
378 username.empty() ? NULL : username.c_str(),
am@osimis.io
parents: 2848
diff changeset
379 password.empty() ? NULL : password.c_str());
am@osimis.io
parents: 2848
diff changeset
380
2264
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
381 if (error == OrthancPluginErrorCode_Success)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
382 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
383 return true;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
384 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
385 else if (error == OrthancPluginErrorCode_UnknownResource ||
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
386 error == OrthancPluginErrorCode_InexistentItem)
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
387 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
388 return false;
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
389 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
390 else
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
391 {
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
392 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error);
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
393 }
8e5e0de75839 primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2263
diff changeset
394 }
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
2850
am@osimis.io
parents: 2848
diff changeset
397 OrthancConfiguration::OrthancConfiguration(OrthancPluginContext* context) :
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 context_(context)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 {
2205
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
400 OrthancString str(context);
395522e46b2b refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2177
diff changeset
401 str.Assign(OrthancPluginGetConfiguration(context));
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 if (str.GetContent() == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 OrthancPluginLogError(context, "Cannot access the Orthanc configuration");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
406 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 str.ToJson(configuration_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 if (configuration_.type() != Json::objectValue)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 OrthancPluginLogError(context, "Unable to read the Orthanc configuration");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
414 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 OrthancPluginContext* OrthancConfiguration::GetContext() const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 if (context_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
423 ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 return context_;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 std::string OrthancConfiguration::GetPath(const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 if (path_.empty())
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 return key;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 return path_ + "." + key;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444
2167
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
445 bool OrthancConfiguration::IsSection(const std::string& key) const
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
446 {
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
447 assert(configuration_.type() == Json::objectValue);
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
448
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
449 return (configuration_.isMember(key) &&
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
450 configuration_[key].type() == Json::objectValue);
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
451 }
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
452
aa2915963531 "Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2112
diff changeset
453
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 void OrthancConfiguration::GetSection(OrthancConfiguration& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 assert(configuration_.type() == Json::objectValue);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 target.context_ = context_;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 target.path_ = GetPath(key);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 if (!configuration_.isMember(key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 target.configuration_ = Json::objectValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 if (configuration_[key].type() != Json::objectValue)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 if (context_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 std::string s = "The configuration section \"" + target.path_ + "\" is not an associative array as expected";
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 OrthancPluginLogError(context_, s.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
476 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 target.configuration_ = configuration_[key];
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 bool OrthancConfiguration::LookupStringValue(std::string& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 assert(configuration_.type() == Json::objectValue);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 if (!configuration_.isMember(key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 if (configuration_[key].type() != Json::stringValue)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 if (context_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a string as expected";
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 OrthancPluginLogError(context_, s.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
502 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 target = configuration_[key].asString();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 bool OrthancConfiguration::LookupIntegerValue(int& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 assert(configuration_.type() == Json::objectValue);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 if (!configuration_.isMember(key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 switch (configuration_[key].type())
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 {
2850
am@osimis.io
parents: 2848
diff changeset
522 case Json::intValue:
am@osimis.io
parents: 2848
diff changeset
523 target = configuration_[key].asInt();
am@osimis.io
parents: 2848
diff changeset
524 return true;
am@osimis.io
parents: 2848
diff changeset
525
am@osimis.io
parents: 2848
diff changeset
526 case Json::uintValue:
am@osimis.io
parents: 2848
diff changeset
527 target = configuration_[key].asUInt();
am@osimis.io
parents: 2848
diff changeset
528 return true;
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
2850
am@osimis.io
parents: 2848
diff changeset
530 default:
am@osimis.io
parents: 2848
diff changeset
531 if (context_ != NULL)
am@osimis.io
parents: 2848
diff changeset
532 {
am@osimis.io
parents: 2848
diff changeset
533 std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
am@osimis.io
parents: 2848
diff changeset
534 OrthancPluginLogError(context_, s.c_str());
am@osimis.io
parents: 2848
diff changeset
535 }
am@osimis.io
parents: 2848
diff changeset
536
am@osimis.io
parents: 2848
diff changeset
537 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 bool OrthancConfiguration::LookupUnsignedIntegerValue(unsigned int& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 int tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 if (!LookupIntegerValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 if (tmp < 0)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 if (context_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a positive integer as expected";
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 OrthancPluginLogError(context_, s.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
559 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 target = static_cast<unsigned int>(tmp);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 bool OrthancConfiguration::LookupBooleanValue(bool& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 assert(configuration_.type() == Json::objectValue);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 if (!configuration_.isMember(key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 if (configuration_[key].type() != Json::booleanValue)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 if (context_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a Boolean as expected";
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 OrthancPluginLogError(context_, s.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
587 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 target = configuration_[key].asBool();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 bool OrthancConfiguration::LookupFloatValue(float& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 const std::string& key) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 assert(configuration_.type() == Json::objectValue);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 if (!configuration_.isMember(key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 switch (configuration_[key].type())
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 {
2850
am@osimis.io
parents: 2848
diff changeset
607 case Json::realValue:
am@osimis.io
parents: 2848
diff changeset
608 target = configuration_[key].asFloat();
am@osimis.io
parents: 2848
diff changeset
609 return true;
am@osimis.io
parents: 2848
diff changeset
610
am@osimis.io
parents: 2848
diff changeset
611 case Json::intValue:
am@osimis.io
parents: 2848
diff changeset
612 target = static_cast<float>(configuration_[key].asInt());
am@osimis.io
parents: 2848
diff changeset
613 return true;
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614
2850
am@osimis.io
parents: 2848
diff changeset
615 case Json::uintValue:
am@osimis.io
parents: 2848
diff changeset
616 target = static_cast<float>(configuration_[key].asUInt());
am@osimis.io
parents: 2848
diff changeset
617 return true;
am@osimis.io
parents: 2848
diff changeset
618
am@osimis.io
parents: 2848
diff changeset
619 default:
am@osimis.io
parents: 2848
diff changeset
620 if (context_ != NULL)
am@osimis.io
parents: 2848
diff changeset
621 {
am@osimis.io
parents: 2848
diff changeset
622 std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
am@osimis.io
parents: 2848
diff changeset
623 OrthancPluginLogError(context_, s.c_str());
am@osimis.io
parents: 2848
diff changeset
624 }
am@osimis.io
parents: 2848
diff changeset
625
am@osimis.io
parents: 2848
diff changeset
626 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
630
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
631 bool OrthancConfiguration::LookupListOfStrings(std::list<std::string>& target,
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
632 const std::string& key,
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
633 bool allowSingleString) const
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
634 {
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
635 assert(configuration_.type() == Json::objectValue);
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
636
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
637 target.clear();
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
638
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
639 if (!configuration_.isMember(key))
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
640 {
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
641 return false;
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
642 }
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
643
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
644 switch (configuration_[key].type())
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
645 {
2850
am@osimis.io
parents: 2848
diff changeset
646 case Json::arrayValue:
am@osimis.io
parents: 2848
diff changeset
647 {
am@osimis.io
parents: 2848
diff changeset
648 bool ok = true;
am@osimis.io
parents: 2848
diff changeset
649
am@osimis.io
parents: 2848
diff changeset
650 for (Json::Value::ArrayIndex i = 0; ok && i < configuration_[key].size(); i++)
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
651 {
2850
am@osimis.io
parents: 2848
diff changeset
652 if (configuration_[key][i].type() == Json::stringValue)
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
653 {
2850
am@osimis.io
parents: 2848
diff changeset
654 target.push_back(configuration_[key][i].asString());
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
655 }
2850
am@osimis.io
parents: 2848
diff changeset
656 else
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
657 {
2850
am@osimis.io
parents: 2848
diff changeset
658 ok = false;
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
659 }
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
660 }
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
661
2850
am@osimis.io
parents: 2848
diff changeset
662 if (ok)
am@osimis.io
parents: 2848
diff changeset
663 {
am@osimis.io
parents: 2848
diff changeset
664 return true;
am@osimis.io
parents: 2848
diff changeset
665 }
am@osimis.io
parents: 2848
diff changeset
666
am@osimis.io
parents: 2848
diff changeset
667 break;
am@osimis.io
parents: 2848
diff changeset
668 }
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
669
2850
am@osimis.io
parents: 2848
diff changeset
670 case Json::stringValue:
am@osimis.io
parents: 2848
diff changeset
671 if (allowSingleString)
am@osimis.io
parents: 2848
diff changeset
672 {
am@osimis.io
parents: 2848
diff changeset
673 target.push_back(configuration_[key].asString());
am@osimis.io
parents: 2848
diff changeset
674 return true;
am@osimis.io
parents: 2848
diff changeset
675 }
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
676
2850
am@osimis.io
parents: 2848
diff changeset
677 break;
am@osimis.io
parents: 2848
diff changeset
678
am@osimis.io
parents: 2848
diff changeset
679 default:
am@osimis.io
parents: 2848
diff changeset
680 break;
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
681 }
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
682
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
683 if (context_ != NULL)
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
684 {
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
685 std::string s = ("The configuration option \"" + GetPath(key) +
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
686 "\" is not a list of strings as expected");
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
687 OrthancPluginLogError(context_, s.c_str());
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
688 }
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
689
2265
e46b0ee6c19d allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2264
diff changeset
690 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2263
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
691 }
b9775db0fd9b OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
692
2266
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
693
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
694 bool OrthancConfiguration::LookupSetOfStrings(std::set<std::string>& target,
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
695 const std::string& key,
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
696 bool allowSingleString) const
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
697 {
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
698 std::list<std::string> lst;
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
699
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
700 if (LookupListOfStrings(lst, key, allowSingleString))
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
701 {
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
702 target.clear();
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
703
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
704 for (std::list<std::string>::const_iterator
2850
am@osimis.io
parents: 2848
diff changeset
705 it = lst.begin(); it != lst.end(); ++it)
2266
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
706 {
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
707 target.insert(*it);
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
708 }
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
709
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
710 return true;
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
711 }
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
712 else
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
713 {
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
714 return false;
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
715 }
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
716 }
a344e47e9c9a OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2265
diff changeset
717
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 std::string OrthancConfiguration::GetStringValue(const std::string& key,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 const std::string& defaultValue) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 std::string tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 if (LookupStringValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 return tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 return defaultValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 int OrthancConfiguration::GetIntegerValue(const std::string& key,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 int defaultValue) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 int tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 if (LookupIntegerValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 return tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 return defaultValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 unsigned int OrthancConfiguration::GetUnsignedIntegerValue(const std::string& key,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 unsigned int defaultValue) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 unsigned int tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 if (LookupUnsignedIntegerValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 return tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 return defaultValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 bool OrthancConfiguration::GetBooleanValue(const std::string& key,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 bool defaultValue) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 bool tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 if (LookupBooleanValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 return tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 return defaultValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 float OrthancConfiguration::GetFloatValue(const std::string& key,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 float defaultValue) const
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 float tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 if (LookupFloatValue(tmp, key))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 return tmp;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 return defaultValue;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793
2803
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
794 void OrthancConfiguration::GetDictionary(std::map<std::string, std::string>& target,
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
795 const std::string& key) const
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
796 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
797 assert(configuration_.type() == Json::objectValue);
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
798
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
799 target.clear();
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
800
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
801 if (!configuration_.isMember(key))
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
802 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
803 return;
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
804 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
805
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
806 if (configuration_[key].type() != Json::objectValue)
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
807 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
808 if (context_ != NULL)
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
809 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
810 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a string as expected";
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
811 OrthancPluginLogError(context_, s.c_str());
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
812 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
813
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
814 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
815 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
816
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
817 Json::Value::Members members = configuration_[key].getMemberNames();
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
818
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
819 for (size_t i = 0; i < members.size(); i++)
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
820 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
821 const Json::Value& value = configuration_[key][members[i]];
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
822
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
823 if (value.type() == Json::stringValue)
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
824 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
825 target[members[i]] = value.asString();
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
826 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
827 else
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
828 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
829 if (context_ != NULL)
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
830 {
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
831 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a dictionary mapping strings to strings";
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
832 OrthancPluginLogError(context_, s.c_str());
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
833 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
834
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
835 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
836 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
837 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
838 }
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
839
579acc5e5412 OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2796
diff changeset
840
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 void OrthancImage::Clear()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 if (image_ != NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 OrthancPluginFreeImage(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 image_ = NULL;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 void OrthancImage::CheckImageAvailable()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 if (image_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 OrthancPluginLogError(context_, "Trying to access a NULL image");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
856 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860
2048
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
861 OrthancImage::OrthancImage(OrthancPluginContext* context) :
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 context_(context),
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 image_(NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 if (context == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
867 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871
2048
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
872 OrthancImage::OrthancImage(OrthancPluginContext* context,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
873 OrthancPluginImage* image) :
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 context_(context),
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 image_(image)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877 if (context == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
879 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
881 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883
2048
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
884 OrthancImage::OrthancImage(OrthancPluginContext* context,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
885 OrthancPluginPixelFormat format,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
886 uint32_t width,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2047
diff changeset
887 uint32_t height) :
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 context_(context)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 if (context == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
892 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 image_ = OrthancPluginCreateImage(context, format, width, height);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899
2848
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
900 OrthancImage::OrthancImage(OrthancPluginContext* context,
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
901 OrthancPluginPixelFormat format,
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
902 uint32_t width,
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
903 uint32_t height,
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
904 uint32_t pitch,
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
905 void* buffer) :
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
906 context_(context)
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
907 {
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
908 if (context == NULL)
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
909 {
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
910 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
911 }
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
912 else
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
913 {
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
914 image_ = OrthancPluginCreateImageAccessor(context, format, width, height, pitch, buffer);
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
915 }
dd3914a44b87 added accessors in C++ wrappers
am@osimis.io
parents: 2823
diff changeset
916 }
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 void OrthancImage::UncompressPngImage(const void* data,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 size_t size)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 image_ = OrthancPluginUncompressImage(context_, data, size, OrthancPluginImageFormat_Png);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 if (image_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 OrthancPluginLogError(context_, "Cannot uncompress a PNG image");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
926 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 void OrthancImage::UncompressJpegImage(const void* data,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932 size_t size)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 image_ = OrthancPluginUncompressImage(context_, data, size, OrthancPluginImageFormat_Jpeg);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 if (image_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 OrthancPluginLogError(context_, "Cannot uncompress a JPEG image");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
939 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 void OrthancImage::DecodeDicomImage(const void* data,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 size_t size,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 unsigned int frame)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 Clear();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949 image_ = OrthancPluginDecodeDicomImage(context_, data, size, frame);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 if (image_ == NULL)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 OrthancPluginLogError(context_, "Cannot uncompress a DICOM image");
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
953 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 OrthancPluginPixelFormat OrthancImage::GetPixelFormat()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 return OrthancPluginGetImagePixelFormat(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 unsigned int OrthancImage::GetWidth()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
967 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968 return OrthancPluginGetImageWidth(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972 unsigned int OrthancImage::GetHeight()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
973 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 return OrthancPluginGetImageHeight(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 unsigned int OrthancImage::GetPitch()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 return OrthancPluginGetImagePitch(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
984
2850
am@osimis.io
parents: 2848
diff changeset
985
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986 const void* OrthancImage::GetBuffer()
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 return OrthancPluginGetImageBuffer(context_, image_);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993 void OrthancImage::CompressPngImage(MemoryBuffer& target)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
997 OrthancPluginMemoryBuffer tmp;
2850
am@osimis.io
parents: 2848
diff changeset
998 OrthancPluginCompressPngImage(context_, &tmp, GetPixelFormat(),
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
999 GetWidth(), GetHeight(), GetPitch(), GetBuffer());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1000
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001 target.Assign(tmp);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005 void OrthancImage::CompressJpegImage(MemoryBuffer& target,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 uint8_t quality)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010 OrthancPluginMemoryBuffer tmp;
2850
am@osimis.io
parents: 2848
diff changeset
1011 OrthancPluginCompressJpegImage(context_, &tmp, GetPixelFormat(),
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1014 target.Assign(tmp);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 void OrthancImage::AnswerPngImage(OrthancPluginRestOutput* output)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 OrthancPluginCompressAndAnswerPngImage(context_, output, GetPixelFormat(),
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 GetWidth(), GetHeight(), GetPitch(), GetBuffer());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 void OrthancImage::AnswerJpegImage(OrthancPluginRestOutput* output,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 uint8_t quality)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029 CheckImageAvailable();
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 OrthancPluginCompressAndAnswerJpegImage(context_, output, GetPixelFormat(),
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034
2231
61e0564d03bb backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1035
61e0564d03bb backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1036 #if HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1037 FindMatcher::FindMatcher(OrthancPluginContext* context,
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1038 const OrthancPluginWorklistQuery* worklist) :
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1039 context_(context),
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1040 matcher_(NULL),
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1041 worklist_(worklist)
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1042 {
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1043 if (worklist_ == NULL)
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1044 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
1045 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1046 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1047 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1048
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1049
2215
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1050 void FindMatcher::SetupDicom(OrthancPluginContext* context,
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1051 const void* query,
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1052 uint32_t size)
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1053 {
2215
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1054 context_ = context;
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1055 worklist_ = NULL;
028214a95194 refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2213
diff changeset
1056
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1057 matcher_ = OrthancPluginCreateFindMatcher(context_, query, size);
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1058 if (matcher_ == NULL)
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1059 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
1060 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1061 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1062 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1063
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1064
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1065 FindMatcher::~FindMatcher()
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1066 {
2850
am@osimis.io
parents: 2848
diff changeset
1067 // The "worklist_" field
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1068
2212
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1069 if (matcher_ != NULL)
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1070 {
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1071 OrthancPluginFreeFindMatcher(context_, matcher_);
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1072 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1073 }
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1074
c02f6ec404d8 OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2206
diff changeset
1075
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1076
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1077 bool FindMatcher::IsMatch(const void* dicom,
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1078 uint32_t size) const
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1079 {
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1080 int32_t result;
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1081
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1082 if (matcher_ != NULL)
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1083 {
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1084 result = OrthancPluginFindMatcherIsMatch(context_, matcher_, dicom, size);
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1085 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1086 else if (worklist_ != NULL)
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1087 {
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1088 result = OrthancPluginWorklistIsMatch(context_, worklist_, dicom, size);
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1089 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1090 else
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1091 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
1092 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1093 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1094
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1095 if (result == 0)
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1096 {
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1097 return false;
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1098 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1099 else if (result == 1)
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1100 {
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1101 return true;
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1102 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1103 else
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1104 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
1105 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1106 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1107 }
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1108
2231
61e0564d03bb backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2215
diff changeset
1109 #endif /* HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 */
2213
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1110
95d1d758abb7 FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2212
diff changeset
1111
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1112 bool RestApiGet(Json::Value& result,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1113 OrthancPluginContext* context,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1114 const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1115 bool applyPlugins)
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 MemoryBuffer answer(context);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118 if (!answer.RestApiGet(uri, applyPlugins))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1120 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1124 answer.ToJson(result);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1126 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1127 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1129
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1130 bool RestApiPost(Json::Value& result,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1131 OrthancPluginContext* context,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1132 const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1133 const char* body,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1134 size_t bodySize,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1135 bool applyPlugins)
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1136 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1137 MemoryBuffer answer(context);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1138 if (!answer.RestApiPost(uri, body, bodySize, applyPlugins))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1139 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1140 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1141 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1143 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1144 answer.ToJson(result);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1145 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1146 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1147 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1150 bool RestApiPost(Json::Value& result,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1151 OrthancPluginContext* context,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1152 const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1153 const Json::Value& body,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1154 bool applyPlugins)
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1155 {
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1156 Json::FastWriter writer;
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1157 return RestApiPost(result, context, uri, writer.write(body), applyPlugins);
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1158 }
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1159
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1160
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1161 bool RestApiPut(Json::Value& result,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1162 OrthancPluginContext* context,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1163 const std::string& uri,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1164 const char* body,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1165 size_t bodySize,
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1166 bool applyPlugins)
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1168 MemoryBuffer answer(context);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 if (!answer.RestApiPut(uri, body, bodySize, applyPlugins))
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1175 answer.ToJson(result);
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1176 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1181 bool RestApiPut(Json::Value& result,
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1182 OrthancPluginContext* context,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1183 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1184 const Json::Value& body,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1185 bool applyPlugins)
2058
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1186 {
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1187 Json::FastWriter writer;
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1188 return RestApiPut(result, context, uri, writer.write(body), applyPlugins);
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1189 }
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1190
43cd2ab060c7 cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2048
diff changeset
1191
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 bool RestApiDelete(OrthancPluginContext* context,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 const std::string& uri,
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194 bool applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 OrthancPluginErrorCode error;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1198 if (applyPlugins)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1199 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1200 error = OrthancPluginRestApiDeleteAfterPlugins(context, uri.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 error = OrthancPluginRestApiDelete(context, uri.c_str());
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1205 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1206
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1207 if (error == OrthancPluginErrorCode_Success)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 return true;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 else if (error == OrthancPluginErrorCode_UnknownResource ||
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 error == OrthancPluginErrorCode_InexistentItem)
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213 {
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214 return false;
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216 else
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 {
2234
a78d15509a1c cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2231
diff changeset
1218 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error);
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1219 }
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1220 }
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1221
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1222
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2267
diff changeset
1223 void ReportMinimalOrthancVersion(OrthancPluginContext* context,
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2267
diff changeset
1224 unsigned int major,
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2267
diff changeset
1225 unsigned int minor,
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2267
diff changeset
1226 unsigned int revision)
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1227 {
2267
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1228 std::string s = ("Your version of the Orthanc core (" +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1229 std::string(context->orthancVersion) +
2268
ce5c13b95dac New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2267
diff changeset
1230 ") is too old to run this plugin (version " +
2267
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1231 boost::lexical_cast<std::string>(major) + "." +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1232 boost::lexical_cast<std::string>(minor) + "." +
2850
am@osimis.io
parents: 2848
diff changeset
1233 boost::lexical_cast<std::string>(revision) +
2267
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1234 " is required)");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1235
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2266
diff changeset
1236 OrthancPluginLogError(context, s.c_str());
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1237 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1238
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1239
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1240 bool CheckMinimalOrthancVersion(OrthancPluginContext* context,
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1241 unsigned int major,
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1242 unsigned int minor,
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1243 unsigned int revision)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1244 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1245 if (context == NULL)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1246 {
2850
am@osimis.io
parents: 2848
diff changeset
1247 OrthancPluginLogError(context, "Bad Orthanc context in the plugin");
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1248 return false;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1249 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1250
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1251 if (!strcmp(context->orthancVersion, "mainline"))
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1252 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1253 // Assume compatibility with the mainline
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1254 return true;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1255 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1256
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1257 // Parse the version of the Orthanc core
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1258 int aa, bb, cc;
2850
am@osimis.io
parents: 2848
diff changeset
1259 if (
am@osimis.io
parents: 2848
diff changeset
1260 #ifdef _MSC_VER
am@osimis.io
parents: 2848
diff changeset
1261 sscanf_s
am@osimis.io
parents: 2848
diff changeset
1262 #else
am@osimis.io
parents: 2848
diff changeset
1263 sscanf
am@osimis.io
parents: 2848
diff changeset
1264 #endif
am@osimis.io
parents: 2848
diff changeset
1265 (context->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
am@osimis.io
parents: 2848
diff changeset
1266 aa < 0 ||
am@osimis.io
parents: 2848
diff changeset
1267 bb < 0 ||
am@osimis.io
parents: 2848
diff changeset
1268 cc < 0)
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1269 {
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1270 return false;
2109
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1271 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1272
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1273 unsigned int a = static_cast<unsigned int>(aa);
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1274 unsigned int b = static_cast<unsigned int>(bb);
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1275 unsigned int c = static_cast<unsigned int>(cc);
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1276
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1277 // Check the major version number
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1278
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1279 if (a > major)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1280 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1281 return true;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1282 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1283
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1284 if (a < major)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1285 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1286 return false;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1287 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1288
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1289
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1290 // Check the minor version number
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1291 assert(a == major);
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1292
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1293 if (b > minor)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1294 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1295 return true;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1296 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1297
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1298 if (b < minor)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1299 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1300 return false;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1301 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1302
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1303 // Check the patch level version number
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1304 assert(a == major && b == minor);
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1305
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1306 if (c >= revision)
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1307 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1308 return true;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1309 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1310 else
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1311 {
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1312 return false;
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1313 }
d5c29fd74ffa OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2062
diff changeset
1314 }
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1315
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1316
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1317
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1318
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1319 #if HAS_ORTHANC_PLUGIN_PEERS == 1
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1320 size_t OrthancPeers::GetPeerIndex(const std::string& name) const
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1321 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1322 size_t index;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1323 if (LookupName(index, name))
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1324 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1325 return index;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1326 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1327 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1328 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1329 std::string s = "Inexistent peer: " + name;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1330 OrthancPluginLogError(context_, s.c_str());
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1331 ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1332 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1333 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1334
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1335
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1336 OrthancPeers::OrthancPeers(OrthancPluginContext* context) :
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1337 context_(context),
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1338 peers_(NULL),
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1339 timeout_(0)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1340 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1341 if (context_ == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1342 {
2850
am@osimis.io
parents: 2848
diff changeset
1343 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_NullPointer);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1344 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1345
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1346 peers_ = OrthancPluginGetPeers(context_);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1347
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1348 if (peers_ == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1349 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1350 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1351 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1352
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1353 uint32_t count = OrthancPluginGetPeersCount(context_, peers_);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1354
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1355 for (uint32_t i = 0; i < count; i++)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1356 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1357 const char* name = OrthancPluginGetPeerName(context_, peers_, i);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1358 if (name == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1359 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1360 OrthancPluginFreePeers(context_, peers_);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1361 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1362 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1363
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1364 index_[name] = i;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1365 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1366 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1367
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1368
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1369 OrthancPeers::~OrthancPeers()
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1370 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1371 if (peers_ != NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1372 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1373 OrthancPluginFreePeers(context_, peers_);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1374 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1375 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1376
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1377
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1378 bool OrthancPeers::LookupName(size_t& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1379 const std::string& name) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1380 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1381 Index::const_iterator found = index_.find(name);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1382
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1383 if (found == index_.end())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1384 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1385 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1386 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1387 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1388 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1389 target = found->second;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1390 return true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1391 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1392 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1393
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1394
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1395 std::string OrthancPeers::GetPeerName(size_t index) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1396 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1397 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1398 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1399 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1400 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1401 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1402 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1403 const char* s = OrthancPluginGetPeerName(context_, peers_, static_cast<uint32_t>(index));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1404 if (s == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1405 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1406 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1407 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1408 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1409 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1410 return s;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1411 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1412 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1413 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1414
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1415
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1416 std::string OrthancPeers::GetPeerUrl(size_t index) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1417 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1418 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1419 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1420 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1421 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1422 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1423 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1424 const char* s = OrthancPluginGetPeerUrl(context_, peers_, static_cast<uint32_t>(index));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1425 if (s == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1426 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1427 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1428 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1429 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1430 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1431 return s;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1432 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1433 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1434 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1435
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1436
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1437 std::string OrthancPeers::GetPeerUrl(const std::string& name) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1438 {
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1439 return GetPeerUrl(GetPeerIndex(name));
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1440 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1441
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1442
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1443 bool OrthancPeers::LookupUserProperty(std::string& value,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1444 size_t index,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1445 const std::string& key) const
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1446 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1447 if (index >= index_.size())
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1448 {
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1449 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1450 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1451 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1452 {
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1453 const char* s = OrthancPluginGetPeerUserProperty(context_, peers_, static_cast<uint32_t>(index), key.c_str());
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1454 if (s == NULL)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1455 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1456 return false;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1457 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1458 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1459 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1460 value.assign(s);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1461 return true;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1462 }
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1463 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1464 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1465
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1466
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1467 bool OrthancPeers::LookupUserProperty(std::string& value,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1468 const std::string& peer,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1469 const std::string& key) const
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1470 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1471 return LookupUserProperty(value, GetPeerIndex(peer), key);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1472 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1473
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2822
diff changeset
1474
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1475 bool OrthancPeers::DoGet(MemoryBuffer& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1476 size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1477 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1478 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1479 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1480 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1481 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1482 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1483
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1484 OrthancPluginMemoryBuffer answer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1485 uint16_t status;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1486 OrthancPluginErrorCode code = OrthancPluginCallPeerApi
2850
am@osimis.io
parents: 2848
diff changeset
1487 (context_, &answer, NULL, &status, peers_,
am@osimis.io
parents: 2848
diff changeset
1488 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(),
am@osimis.io
parents: 2848
diff changeset
1489 0, NULL, NULL, NULL, 0, timeout_);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1490
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1491 if (code == OrthancPluginErrorCode_Success)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1492 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1493 target.Assign(answer);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1494 return (status == 200);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1495 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1496 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1497 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1498 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1499 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1500 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1501
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1502
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1503 bool OrthancPeers::DoGet(MemoryBuffer& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1504 const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1505 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1506 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1507 size_t index;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1508 return (LookupName(index, name) &&
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1509 DoGet(target, index, uri));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1510 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1511
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1512
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1513 bool OrthancPeers::DoGet(Json::Value& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1514 size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1515 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1516 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1517 MemoryBuffer buffer(context_);
2850
am@osimis.io
parents: 2848
diff changeset
1518
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1519 if (DoGet(buffer, index, uri))
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1520 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1521 buffer.ToJson(target);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1522 return true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1523 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1524 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1525 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1526 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1527 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1528 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1529
2850
am@osimis.io
parents: 2848
diff changeset
1530
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1531 bool OrthancPeers::DoGet(Json::Value& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1532 const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1533 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1534 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1535 MemoryBuffer buffer(context_);
2850
am@osimis.io
parents: 2848
diff changeset
1536
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1537 if (DoGet(buffer, name, uri))
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1538 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1539 buffer.ToJson(target);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1540 return true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1541 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1542 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1543 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1544 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1545 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1546 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1547
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1548
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1549 bool OrthancPeers::DoPost(MemoryBuffer& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1550 const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1551 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1552 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1553 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1554 size_t index;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1555 return (LookupName(index, name) &&
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1556 DoPost(target, index, uri, body));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1557 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1558
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1559
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1560 bool OrthancPeers::DoPost(Json::Value& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1561 size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1562 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1563 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1564 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1565 MemoryBuffer buffer(context_);
2850
am@osimis.io
parents: 2848
diff changeset
1566
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1567 if (DoPost(buffer, index, uri, body))
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1568 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1569 buffer.ToJson(target);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1570 return true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1571 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1572 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1573 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1574 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1575 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1576 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1577
2850
am@osimis.io
parents: 2848
diff changeset
1578
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1579 bool OrthancPeers::DoPost(Json::Value& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1580 const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1581 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1582 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1583 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1584 MemoryBuffer buffer(context_);
2850
am@osimis.io
parents: 2848
diff changeset
1585
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1586 if (DoPost(buffer, name, uri, body))
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1587 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1588 buffer.ToJson(target);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1589 return true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1590 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1591 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1592 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1593 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1594 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1595 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1596
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1597
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1598 bool OrthancPeers::DoPost(MemoryBuffer& target,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1599 size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1600 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1601 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1602 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1603 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1604 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1605 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1606 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1607
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1608 OrthancPluginMemoryBuffer answer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1609 uint16_t status;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1610 OrthancPluginErrorCode code = OrthancPluginCallPeerApi
2850
am@osimis.io
parents: 2848
diff changeset
1611 (context_, &answer, NULL, &status, peers_,
am@osimis.io
parents: 2848
diff changeset
1612 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(),
am@osimis.io
parents: 2848
diff changeset
1613 0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1614
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1615 if (code == OrthancPluginErrorCode_Success)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1616 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1617 target.Assign(answer);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1618 return (status == 200);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1619 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1620 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1621 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1622 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1623 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1624 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1625
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1626
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1627 bool OrthancPeers::DoPut(size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1628 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1629 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1630 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1631 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1632 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1633 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1634 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1635
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1636 OrthancPluginMemoryBuffer answer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1637 uint16_t status;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1638 OrthancPluginErrorCode code = OrthancPluginCallPeerApi
2850
am@osimis.io
parents: 2848
diff changeset
1639 (context_, &answer, NULL, &status, peers_,
am@osimis.io
parents: 2848
diff changeset
1640 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
am@osimis.io
parents: 2848
diff changeset
1641 0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1642
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1643 if (code == OrthancPluginErrorCode_Success)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1644 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1645 OrthancPluginFreeMemoryBuffer(context_, &answer);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1646 return (status == 200);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1647 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1648 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1649 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1650 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1651 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1652 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1653
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1654
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1655 bool OrthancPeers::DoPut(const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1656 const std::string& uri,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1657 const std::string& body) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1658 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1659 size_t index;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1660 return (LookupName(index, name) &&
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1661 DoPut(index, uri, body));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1662 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1663
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1664
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1665 bool OrthancPeers::DoDelete(size_t index,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1666 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1667 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1668 if (index >= index_.size())
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1669 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1670 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1671 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1672
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1673 OrthancPluginMemoryBuffer answer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1674 uint16_t status;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1675 OrthancPluginErrorCode code = OrthancPluginCallPeerApi
2850
am@osimis.io
parents: 2848
diff changeset
1676 (context_, &answer, NULL, &status, peers_,
am@osimis.io
parents: 2848
diff changeset
1677 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
am@osimis.io
parents: 2848
diff changeset
1678 0, NULL, NULL, NULL, 0, timeout_);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1679
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1680 if (code == OrthancPluginErrorCode_Success)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1681 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1682 OrthancPluginFreeMemoryBuffer(context_, &answer);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1683 return (status == 200);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1684 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1685 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1686 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1687 return false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1688 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1689 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1690
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1691
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1692 bool OrthancPeers::DoDelete(const std::string& name,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1693 const std::string& uri) const
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1694 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1695 size_t index;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1696 return (LookupName(index, name) &&
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1697 DoDelete(index, uri));
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1698 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1699 #endif
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1700
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1701
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1702
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1703 #if HAS_ORTHANC_PLUGIN_JOB == 1
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1704 void OrthancJob::CallbackFinalize(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1705 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1706 if (job != NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1707 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1708 delete reinterpret_cast<OrthancJob*>(job);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1709 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1710 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1711
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1712
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1713 float OrthancJob::CallbackGetProgress(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1714 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1715 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1716
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1717 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1718 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1719 return reinterpret_cast<OrthancJob*>(job)->progress_;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1720 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1721 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1722 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1723 return 0;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1724 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1725 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1726
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1727
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1728 const char* OrthancJob::CallbackGetContent(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1729 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1730 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1731
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1732 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1733 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1734 return reinterpret_cast<OrthancJob*>(job)->content_.c_str();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1735 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1736 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1737 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1738 return 0;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1739 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1740 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1741
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1742
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1743 const char* OrthancJob::CallbackGetSerialized(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1744 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1745 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1746
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1747 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1748 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1749 const OrthancJob& tmp = *reinterpret_cast<OrthancJob*>(job);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1750
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1751 if (tmp.hasSerialized_)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1752 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1753 return tmp.serialized_.c_str();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1754 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1755 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1756 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1757 return NULL;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1758 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1759 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1760 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1761 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1762 return 0;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1763 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1764 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1765
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1766
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1767 OrthancPluginJobStepStatus OrthancJob::CallbackStep(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1768 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1769 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1770
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1771 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1772 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1773 return reinterpret_cast<OrthancJob*>(job)->Step();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1774 }
2822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2817
diff changeset
1775 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS&)
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1776 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1777 return OrthancPluginJobStepStatus_Failure;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1778 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1779 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1780 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1781 return OrthancPluginJobStepStatus_Failure;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1782 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1783 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1784
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1785
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1786 OrthancPluginErrorCode OrthancJob::CallbackStop(void* job,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1787 OrthancPluginJobStopReason reason)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1788 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1789 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1790
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1791 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1792 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1793 reinterpret_cast<OrthancJob*>(job)->Stop(reason);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1794 return OrthancPluginErrorCode_Success;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1795 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1796 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1797 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1798 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1799 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1800 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1801 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1802 return OrthancPluginErrorCode_Plugin;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1803 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1804 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1805
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1806
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1807 OrthancPluginErrorCode OrthancJob::CallbackReset(void* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1808 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1809 assert(job != NULL);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1810
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1811 try
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1812 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1813 reinterpret_cast<OrthancJob*>(job)->Reset();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1814 return OrthancPluginErrorCode_Success;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1815 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1816 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1817 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1818 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1819 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1820 catch (...)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1821 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1822 return OrthancPluginErrorCode_Plugin;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1823 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1824 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1825
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1826
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1827 void OrthancJob::ClearContent()
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1828 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1829 Json::Value empty = Json::objectValue;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1830 UpdateContent(empty);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1831 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1832
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1833
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1834 void OrthancJob::UpdateContent(const Json::Value& content)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1835 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1836 if (content.type() != Json::objectValue)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1837 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1838 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_BadFileFormat);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1839 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1840 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1841 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1842 Json::FastWriter writer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1843 content_ = writer.write(content);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1844 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1845 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1846
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1847
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1848 void OrthancJob::ClearSerialized()
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1849 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1850 hasSerialized_ = false;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1851 serialized_.clear();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1852 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1853
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1854
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1855 void OrthancJob::UpdateSerialized(const Json::Value& serialized)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1856 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1857 if (serialized.type() != Json::objectValue)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1858 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1859 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_BadFileFormat);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1860 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1861 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1862 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1863 Json::FastWriter writer;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1864 serialized_ = writer.write(serialized);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1865 hasSerialized_ = true;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1866 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1867 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1868
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1869
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1870 void OrthancJob::UpdateProgress(float progress)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1871 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1872 if (progress < 0 ||
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1873 progress > 1)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1874 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1875 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1876 }
2850
am@osimis.io
parents: 2848
diff changeset
1877
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1878 progress_ = progress;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1879 }
2850
am@osimis.io
parents: 2848
diff changeset
1880
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1881
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1882 OrthancJob::OrthancJob(const std::string& jobType) :
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1883 jobType_(jobType),
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1884 progress_(0)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1885 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1886 ClearContent();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1887 ClearSerialized();
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1888 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1889
2850
am@osimis.io
parents: 2848
diff changeset
1890
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1891 OrthancPluginJob* OrthancJob::Create(OrthancPluginContext* context,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1892 OrthancJob* job)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1893 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1894 if (job == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1895 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1896 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_NullPointer);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1897 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1898
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1899 OrthancPluginJob* orthanc = OrthancPluginCreateJob(
2850
am@osimis.io
parents: 2848
diff changeset
1900 context, job, CallbackFinalize, job->jobType_.c_str(),
am@osimis.io
parents: 2848
diff changeset
1901 CallbackGetProgress, CallbackGetContent, CallbackGetSerialized,
am@osimis.io
parents: 2848
diff changeset
1902 CallbackStep, CallbackStop, CallbackReset);
2817
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1903
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1904 if (orthanc == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1905 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1906 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1907 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1908 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1909 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1910 return orthanc;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1911 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1912 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1913
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1914
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1915 std::string OrthancJob::Submit(OrthancPluginContext* context,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1916 OrthancJob* job,
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1917 int priority)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1918 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1919 OrthancPluginJob* orthanc = Create(context, job);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1920
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1921 char* id = OrthancPluginSubmitJob(context, orthanc, priority);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1922
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1923 if (id == NULL)
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1924 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1925 OrthancPluginLogError(context, "Plugin cannot submit job");
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1926 OrthancPluginFreeJob(context, orthanc);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1927 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_Plugin);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1928 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1929 else
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1930 {
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1931 std::string tmp(id);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1932 tmp.assign(id);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1933 OrthancPluginFreeString(context, id);
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1934
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1935 return tmp;
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1936 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1937 }
473bf302d629 C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2803
diff changeset
1938 #endif
2047
438f86ee19fc toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1939 }