Mercurial > hg > orthanc
annotate Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2976:cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Dec 2018 12:23:46 +0100 |
parents | e361df74639f |
children | 9b734c3e1095 |
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 | 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 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
42 static OrthancPluginContext* globalContext_ = NULL; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
43 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
44 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
45 void SetGlobalContext(OrthancPluginContext* context) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
46 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
47 if (context == NULL) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
48 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
49 ORTHANC_PLUGINS_THROW_EXCEPTION(NullPointer); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
50 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
51 else if (globalContext_ == NULL) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
52 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
53 globalContext_ = context; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
54 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
55 else |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
56 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
57 ORTHANC_PLUGINS_THROW_EXCEPTION(BadSequenceOfCalls); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
58 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
59 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
60 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
61 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
62 bool HasGlobalContext() |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
63 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
64 return globalContext_ != NULL; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
65 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
66 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
67 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
68 OrthancPluginContext* GetGlobalContext() |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
69 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
70 if (globalContext_ == NULL) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
71 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
72 ORTHANC_PLUGINS_THROW_EXCEPTION(BadSequenceOfCalls); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
73 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
74 else |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
75 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
76 return globalContext_; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
77 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
78 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
79 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
80 |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
81 void MemoryBuffer::Check(OrthancPluginErrorCode code) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
82 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
83 if (code != OrthancPluginErrorCode_Success) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
84 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
85 // Prevent using garbage information |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
86 buffer_.data = NULL; |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
87 buffer_.size = 0; |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
88 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
89 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
90 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
91 |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
92 |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
93 bool MemoryBuffer::CheckHttp(OrthancPluginErrorCode code) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
94 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
95 if (code != OrthancPluginErrorCode_Success) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
96 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
97 // Prevent using garbage information |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
98 buffer_.data = NULL; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
99 buffer_.size = 0; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
100 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
101 |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
102 if (code == OrthancPluginErrorCode_Success) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
103 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
104 return true; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
105 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
106 else if (code == OrthancPluginErrorCode_UnknownResource || |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
107 code == OrthancPluginErrorCode_InexistentItem) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
108 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
109 return false; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
110 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
111 else |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
112 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
113 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
|
114 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
115 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
116 |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
117 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
118 MemoryBuffer::MemoryBuffer() |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 buffer_.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 buffer_.size = 0; |
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 |
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 void MemoryBuffer::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 if (buffer_.data != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
129 OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &buffer_); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 buffer_.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 buffer_.size = 0; |
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 |
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 void MemoryBuffer::Assign(OrthancPluginMemoryBuffer& other) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 buffer_.data = other.data; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 buffer_.size = other.size; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 other.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 other.size = 0; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 } |
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 |
2792
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
148 OrthancPluginMemoryBuffer MemoryBuffer::Release() |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
149 { |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
150 OrthancPluginMemoryBuffer result = buffer_; |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
151 |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
152 buffer_.data = NULL; |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 buffer_.size = 0; |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
155 return result; |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
156 } |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
157 |
57e2d65d37ce
OrthancPlugins::MemoryBuffer::Release(), fixing openssl link
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
158 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 void MemoryBuffer::ToString(std::string& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 if (buffer_.size == 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 target.clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 else |
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 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
|
168 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 void MemoryBuffer::ToJson(Json::Value& target) const |
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 if (buffer_.data == NULL || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 buffer_.size == 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
177 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 } |
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 const char* tmp = reinterpret_cast<const char*>(buffer_.data); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 Json::Reader reader; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 if (!reader.parse(tmp, tmp + buffer_.size, target)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
185 LogError("Cannot convert some memory buffer to JSON"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
186 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 bool MemoryBuffer::RestApiGet(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 bool applyPlugins) |
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 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
198 return CheckHttp(OrthancPluginRestApiGetAfterPlugins(GetGlobalContext(), &buffer_, uri.c_str())); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
202 return CheckHttp(OrthancPluginRestApiGet(GetGlobalContext(), &buffer_, uri.c_str())); |
2047
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 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 bool MemoryBuffer::RestApiPost(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 const char* body, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 size_t bodySize, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
216 return CheckHttp(OrthancPluginRestApiPostAfterPlugins(GetGlobalContext(), &buffer_, uri.c_str(), body, bodySize)); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
220 return CheckHttp(OrthancPluginRestApiPost(GetGlobalContext(), &buffer_, uri.c_str(), body, bodySize)); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 bool MemoryBuffer::RestApiPut(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 const char* body, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 size_t bodySize, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
234 return CheckHttp(OrthancPluginRestApiPutAfterPlugins(GetGlobalContext(), &buffer_, uri.c_str(), body, bodySize)); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
238 return CheckHttp(OrthancPluginRestApiPut(GetGlobalContext(), &buffer_, uri.c_str(), body, bodySize)); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
243 bool MemoryBuffer::RestApiPost(const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
244 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
245 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
246 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
247 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
248 return RestApiPost(uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
249 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
250 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
251 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
252 bool MemoryBuffer::RestApiPut(const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
253 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
254 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
255 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
256 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
257 return RestApiPut(uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
258 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
259 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
260 |
2059 | 261 void MemoryBuffer::CreateDicom(const Json::Value& tags, |
262 OrthancPluginCreateDicomFlags flags) | |
263 { | |
264 Clear(); | |
265 | |
266 Json::FastWriter writer; | |
267 std::string s = writer.write(tags); | |
268 | |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
269 Check(OrthancPluginCreateDicom(GetGlobalContext(), &buffer_, s.c_str(), NULL, flags)); |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
270 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
271 |
2849 | 272 void MemoryBuffer::CreateDicom(const Json::Value& tags, |
273 const OrthancImage& pixelData, | |
274 OrthancPluginCreateDicomFlags flags) | |
2848 | 275 { |
276 Clear(); | |
277 | |
278 Json::FastWriter writer; | |
279 std::string s = writer.write(tags); | |
280 | |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
281 Check(OrthancPluginCreateDicom(GetGlobalContext(), &buffer_, s.c_str(), pixelData.GetObject(), flags)); |
2848 | 282 } |
283 | |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
284 |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
285 void MemoryBuffer::ReadFile(const std::string& path) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
286 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
287 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
288 Check(OrthancPluginReadFile(GetGlobalContext(), &buffer_, path.c_str())); |
2059 | 289 } |
290 | |
291 | |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
292 void MemoryBuffer::GetDicomQuery(const OrthancPluginWorklistQuery* query) |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
293 { |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
294 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
295 Check(OrthancPluginWorklistGetDicomQuery(GetGlobalContext(), &buffer_, query)); |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
296 } |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
297 |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
298 |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
299 void OrthancString::Assign(char* str) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 { |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
301 if (str == NULL) |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
302 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
303 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
304 } |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
305 else |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
306 { |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
307 Clear(); |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
308 str_ = str; |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
309 } |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 void OrthancString::Clear() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 if (str_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
317 OrthancPluginFreeString(GetGlobalContext(), str_); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 str_ = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 void OrthancString::ToString(std::string& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 if (str_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 target.clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 target.assign(str_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 void OrthancString::ToJson(Json::Value& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 if (str_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
340 LogError("Cannot convert an empty memory buffer to JSON"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
341 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 Json::Reader reader; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 if (!reader.parse(str_, target)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
347 LogError("Cannot convert some memory buffer to JSON"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
348 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 } |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
351 |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
352 |
2206
27106f7e3759
more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2205
diff
changeset
|
353 void MemoryBuffer::DicomToJson(Json::Value& target, |
27106f7e3759
more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2205
diff
changeset
|
354 OrthancPluginDicomToJsonFormat format, |
27106f7e3759
more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2205
diff
changeset
|
355 OrthancPluginDicomToJsonFlags flags, |
27106f7e3759
more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2205
diff
changeset
|
356 uint32_t maxStringLength) |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
357 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
358 OrthancString str; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
359 str.Assign(OrthancPluginDicomBufferToJson |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
360 (GetGlobalContext(), GetData(), GetSize(), format, flags, maxStringLength)); |
2206
27106f7e3759
more refactoring of the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2205
diff
changeset
|
361 str.ToJson(target); |
2205
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
362 } |
395522e46b2b
refactoring of the worklist sample using OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2177
diff
changeset
|
363 |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
364 |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
365 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
|
366 const std::string& username, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
367 const std::string& password) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
368 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
369 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
370 return CheckHttp(OrthancPluginHttpGet(GetGlobalContext(), &buffer_, url.c_str(), |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
371 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
|
372 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
|
373 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
374 |
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 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
|
377 const std::string& body, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
378 const std::string& username, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
379 const std::string& password) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
380 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
381 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
382 return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), |
2267 | 383 body.c_str(), body.size(), |
384 username.empty() ? NULL : username.c_str(), | |
385 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
|
386 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
387 |
2850 | 388 |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
389 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
|
390 const std::string& body, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
391 const std::string& username, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
392 const std::string& password) |
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 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
395 return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
396 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
|
397 body.size(), |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
398 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
|
399 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
|
400 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
401 |
2796
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
402 |
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
403 void MemoryBuffer::GetDicomInstance(const std::string& instanceId) |
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
404 { |
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
405 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
406 Check(OrthancPluginGetDicomForInstance(GetGlobalContext(), &buffer_, instanceId.c_str())); |
2796
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
407 } |
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
408 |
4df3c64402ba
MemoryBuffer::GetDicomInstance()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2792
diff
changeset
|
409 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
410 bool HttpDelete(const std::string& url, |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
411 const std::string& username, |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
412 const std::string& password) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
413 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
414 OrthancPluginErrorCode error = OrthancPluginHttpDelete |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
415 (GetGlobalContext(), url.c_str(), |
2850 | 416 username.empty() ? NULL : username.c_str(), |
417 password.empty() ? NULL : password.c_str()); | |
418 | |
2264
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
419 if (error == OrthancPluginErrorCode_Success) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
420 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
421 return true; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
422 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
423 else if (error == OrthancPluginErrorCode_UnknownResource || |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
424 error == OrthancPluginErrorCode_InexistentItem) |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
425 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
426 return false; |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
427 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
428 else |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
429 { |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
430 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
|
431 } |
8e5e0de75839
primitives for HTTP client in plugin C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2263
diff
changeset
|
432 } |
2047
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 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
435 void LogError(const std::string& message) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
436 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
437 if (HasGlobalContext()) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
438 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
439 OrthancPluginLogError(GetGlobalContext(), message.c_str()); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
440 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
441 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
442 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
443 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
444 void LogWarning(const std::string& message) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
446 if (HasGlobalContext()) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
447 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
448 OrthancPluginLogWarning(GetGlobalContext(), message.c_str()); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
449 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
450 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
451 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
452 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
453 void LogInfo(const std::string& message) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
454 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
455 if (HasGlobalContext()) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
456 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
457 OrthancPluginLogInfo(GetGlobalContext(), message.c_str()); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
458 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
459 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
460 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
461 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
462 OrthancConfiguration::OrthancConfiguration() |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
463 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
464 OrthancString str; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
465 str.Assign(OrthancPluginGetConfiguration(GetGlobalContext())); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 if (str.GetContent() == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
469 LogError("Cannot access the Orthanc configuration"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
470 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2047
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 str.ToJson(configuration_); |
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 if (configuration_.type() != Json::objectValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
477 LogError("Unable to read the Orthanc configuration"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
478 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 } |
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 std::string OrthancConfiguration::GetPath(const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 if (path_.empty()) |
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 return key; |
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 else |
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 path_ + "." + key; |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 |
2167
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
496 bool OrthancConfiguration::IsSection(const std::string& key) const |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
497 { |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
498 assert(configuration_.type() == Json::objectValue); |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
499 |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
500 return (configuration_.isMember(key) && |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
501 configuration_[key].type() == Json::objectValue); |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
502 } |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
503 |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
504 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 void OrthancConfiguration::GetSection(OrthancConfiguration& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 const std::string& key) const |
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 assert(configuration_.type() == Json::objectValue); |
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 target.path_ = GetPath(key); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 target.configuration_ = Json::objectValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 if (configuration_[key].type() != Json::objectValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
520 LogError("The configuration section \"" + target.path_ + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
521 "\" is not an associative array as expected"); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
523 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 target.configuration_ = configuration_[key]; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 bool OrthancConfiguration::LookupStringValue(std::string& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 return false; |
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 if (configuration_[key].type() != Json::stringValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
543 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
544 "\" is not a string as expected"); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
546 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 target = configuration_[key].asString(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 bool OrthancConfiguration::LookupIntegerValue(int& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 if (!configuration_.isMember(key)) |
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 return false; |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 switch (configuration_[key].type()) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 { |
2850 | 566 case Json::intValue: |
567 target = configuration_[key].asInt(); | |
568 return true; | |
569 | |
570 case Json::uintValue: | |
571 target = configuration_[key].asUInt(); | |
572 return true; | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 |
2850 | 574 default: |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
575 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
576 "\" is not an integer as expected"); |
2850 | 577 |
578 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 } |
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 |
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 bool OrthancConfiguration::LookupUnsignedIntegerValue(unsigned int& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 const std::string& key) const |
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 int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 if (!LookupIntegerValue(tmp, key)) |
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 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 if (tmp < 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
594 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
595 "\" is not a positive integer as expected"); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
597 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 target = static_cast<unsigned int>(tmp); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 return true; |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 bool OrthancConfiguration::LookupBooleanValue(bool& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 if (configuration_[key].type() != Json::booleanValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
619 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
620 "\" is not a Boolean as expected"); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
622 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 target = configuration_[key].asBool(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 return true; |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 bool OrthancConfiguration::LookupFloatValue(float& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 switch (configuration_[key].type()) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 { |
2850 | 642 case Json::realValue: |
643 target = configuration_[key].asFloat(); | |
644 return true; | |
645 | |
646 case Json::intValue: | |
647 target = static_cast<float>(configuration_[key].asInt()); | |
648 return true; | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 |
2850 | 650 case Json::uintValue: |
651 target = static_cast<float>(configuration_[key].asUInt()); | |
652 return true; | |
653 | |
654 default: | |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
655 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
656 "\" is not an integer as expected"); |
2850 | 657 |
658 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
662 |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
663 bool OrthancConfiguration::LookupListOfStrings(std::list<std::string>& target, |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
664 const std::string& key, |
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
665 bool allowSingleString) const |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
666 { |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
667 assert(configuration_.type() == Json::objectValue); |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
668 |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
669 target.clear(); |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
670 |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
671 if (!configuration_.isMember(key)) |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
672 { |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
673 return false; |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
674 } |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
675 |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
676 switch (configuration_[key].type()) |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
677 { |
2850 | 678 case Json::arrayValue: |
679 { | |
680 bool ok = true; | |
681 | |
682 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
|
683 { |
2850 | 684 if (configuration_[key][i].type() == Json::stringValue) |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
685 { |
2850 | 686 target.push_back(configuration_[key][i].asString()); |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
687 } |
2850 | 688 else |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
689 { |
2850 | 690 ok = false; |
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 } |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
693 |
2850 | 694 if (ok) |
695 { | |
696 return true; | |
697 } | |
698 | |
699 break; | |
700 } | |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
701 |
2850 | 702 case Json::stringValue: |
703 if (allowSingleString) | |
704 { | |
705 target.push_back(configuration_[key].asString()); | |
706 return true; | |
707 } | |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
708 |
2850 | 709 break; |
710 | |
711 default: | |
712 break; | |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
713 } |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
714 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
715 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
716 "\" is not a list of strings as expected"); |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
717 |
2265
e46b0ee6c19d
allowSingleString in OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2264
diff
changeset
|
718 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
2263
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
719 } |
b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
720 |
2266
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
721 |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
722 bool OrthancConfiguration::LookupSetOfStrings(std::set<std::string>& target, |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
723 const std::string& key, |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
724 bool allowSingleString) const |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
725 { |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
726 std::list<std::string> lst; |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
727 |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
728 if (LookupListOfStrings(lst, key, allowSingleString)) |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
729 { |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
730 target.clear(); |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
731 |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
732 for (std::list<std::string>::const_iterator |
2850 | 733 it = lst.begin(); it != lst.end(); ++it) |
2266
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
734 { |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
735 target.insert(*it); |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
736 } |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
737 |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
738 return true; |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
739 } |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
740 else |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
741 { |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
742 return false; |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
743 } |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
744 } |
a344e47e9c9a
OrthancConfiguration::LookupSetOfStrings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2265
diff
changeset
|
745 |
2047
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 std::string OrthancConfiguration::GetStringValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 const std::string& defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 std::string tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 if (LookupStringValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 return tmp; |
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 else |
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 return defaultValue; |
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 } |
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 int OrthancConfiguration::GetIntegerValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 int defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 if (LookupIntegerValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 return tmp; |
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 else |
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 return defaultValue; |
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 } |
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 unsigned int OrthancConfiguration::GetUnsignedIntegerValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 unsigned int defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 unsigned int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 if (LookupUnsignedIntegerValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 return tmp; |
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 else |
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 return defaultValue; |
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 } |
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 bool OrthancConfiguration::GetBooleanValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 bool defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 bool tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 if (LookupBooleanValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 float OrthancConfiguration::GetFloatValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 float defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 float tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 if (LookupFloatValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 |
2803
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
822 void OrthancConfiguration::GetDictionary(std::map<std::string, std::string>& target, |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
823 const std::string& key) const |
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 assert(configuration_.type() == Json::objectValue); |
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 target.clear(); |
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 (!configuration_.isMember(key)) |
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 return; |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
832 } |
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 if (configuration_[key].type() != Json::objectValue) |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
835 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
836 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
837 "\" is not a string as expected"); |
2803
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 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
840 } |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
841 |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
842 Json::Value::Members members = configuration_[key].getMemberNames(); |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
843 |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
844 for (size_t i = 0; i < members.size(); i++) |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
845 { |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
846 const Json::Value& value = configuration_[key][members[i]]; |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
847 |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
848 if (value.type() == Json::stringValue) |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
849 { |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
850 target[members[i]] = value.asString(); |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
851 } |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
852 else |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
853 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
854 LogError("The configuration option \"" + GetPath(key) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
855 "\" is not a dictionary mapping strings to strings"); |
2803
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
856 |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
857 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
858 } |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
859 } |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
860 } |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
861 |
579acc5e5412
OrthancConfiguration::GetDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2796
diff
changeset
|
862 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 void OrthancImage::Clear() |
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 (image_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
867 OrthancPluginFreeImage(GetGlobalContext(), image_); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 image_ = NULL; |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
872 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 void OrthancImage::CheckImageAvailable() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
877 LogError("Trying to access a NULL image"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
878 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 } |
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 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
883 OrthancImage::OrthancImage() : |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
884 image_(NULL) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
885 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
886 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
887 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
888 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
889 OrthancImage::OrthancImage(OrthancPluginImage* image) : |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 image_(image) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
892 } |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
893 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
894 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
895 OrthancImage::OrthancImage(OrthancPluginPixelFormat format, |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
896 uint32_t width, |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
897 uint32_t height) |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
898 { |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
899 image_ = OrthancPluginCreateImage(GetGlobalContext(), format, width, height); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
900 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
901 if (image_ == NULL) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
903 LogError("Cannot create an image"); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
904 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
909 OrthancImage::OrthancImage(OrthancPluginPixelFormat format, |
2848 | 910 uint32_t width, |
911 uint32_t height, | |
912 uint32_t pitch, | |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
913 void* buffer) |
2848 | 914 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
915 image_ = OrthancPluginCreateImageAccessor |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
916 (GetGlobalContext(), format, width, height, pitch, buffer); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
917 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
918 if (image_ == NULL) |
2848 | 919 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
920 LogError("Cannot create an image accessor"); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
921 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2848 | 922 } |
923 } | |
2047
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 void OrthancImage::UncompressPngImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 size_t size) |
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 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
929 |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
930 image_ = OrthancPluginUncompressImage(GetGlobalContext(), data, size, OrthancPluginImageFormat_Png); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
931 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
934 LogError("Cannot uncompress a PNG image"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
935 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 void OrthancImage::UncompressJpegImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 size_t size) |
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 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
944 image_ = OrthancPluginUncompressImage(GetGlobalContext(), data, size, OrthancPluginImageFormat_Jpeg); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
947 LogError("Cannot uncompress a JPEG image"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
948 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
949 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
953 void OrthancImage::DecodeDicomImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 size_t size, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 unsigned int frame) |
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 Clear(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
958 image_ = OrthancPluginDecodeDicomImage(GetGlobalContext(), data, size, frame); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
961 LogError("Cannot uncompress a DICOM image"); |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
962 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
2047
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 |
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 OrthancPluginPixelFormat OrthancImage::GetPixelFormat() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
970 return OrthancPluginGetImagePixelFormat(GetGlobalContext(), image_); |
2047
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 |
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 unsigned int OrthancImage::GetWidth() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
975 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
976 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
977 return OrthancPluginGetImageWidth(GetGlobalContext(), image_); |
2047
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 |
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 unsigned int OrthancImage::GetHeight() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
984 return OrthancPluginGetImageHeight(GetGlobalContext(), image_); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
985 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 |
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 unsigned int OrthancImage::GetPitch() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
989 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
990 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
991 return OrthancPluginGetImagePitch(GetGlobalContext(), image_); |
2047
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 |
2850 | 994 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
995 const void* OrthancImage::GetBuffer() |
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 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
998 return OrthancPluginGetImageBuffer(GetGlobalContext(), image_); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
999 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1002 void OrthancImage::CompressPngImage(MemoryBuffer& target) |
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 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1005 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1006 OrthancPluginMemoryBuffer tmp; |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1007 OrthancPluginCompressPngImage(GetGlobalContext(), &tmp, GetPixelFormat(), |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1008 GetWidth(), GetHeight(), GetPitch(), GetBuffer()); |
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 target.Assign(tmp); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1011 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1012 |
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 void OrthancImage::CompressJpegImage(MemoryBuffer& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1015 uint8_t quality) |
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 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1018 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1019 OrthancPluginMemoryBuffer tmp; |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1020 OrthancPluginCompressJpegImage(GetGlobalContext(), &tmp, GetPixelFormat(), |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1021 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1022 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1023 target.Assign(tmp); |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 void OrthancImage::AnswerPngImage(OrthancPluginRestOutput* output) |
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(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1030 OrthancPluginCompressAndAnswerPngImage(GetGlobalContext(), output, GetPixelFormat(), |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1031 GetWidth(), GetHeight(), GetPitch(), GetBuffer()); |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1035 void OrthancImage::AnswerJpegImage(OrthancPluginRestOutput* output, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1036 uint8_t quality) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1037 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1038 CheckImageAvailable(); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1039 OrthancPluginCompressAndAnswerJpegImage(GetGlobalContext(), output, GetPixelFormat(), |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1040 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1041 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1042 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1043 |
2231
61e0564d03bb
backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2215
diff
changeset
|
1044 |
61e0564d03bb
backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2215
diff
changeset
|
1045 #if HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1046 FindMatcher::FindMatcher(const OrthancPluginWorklistQuery* worklist) : |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1047 matcher_(NULL), |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1048 worklist_(worklist) |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1049 { |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1050 if (worklist_ == NULL) |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1051 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
1052 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1053 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1054 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1055 |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1056 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1057 void FindMatcher::SetupDicom(const void* query, |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1058 uint32_t size) |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1059 { |
2215
028214a95194
refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2213
diff
changeset
|
1060 worklist_ = NULL; |
028214a95194
refactoring the worklist sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2213
diff
changeset
|
1061 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1062 matcher_ = OrthancPluginCreateFindMatcher(GetGlobalContext(), query, size); |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1063 if (matcher_ == NULL) |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1064 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
1065 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1066 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1067 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1068 |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1069 |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1070 FindMatcher::~FindMatcher() |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1071 { |
2850 | 1072 // The "worklist_" field |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1073 |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1074 if (matcher_ != NULL) |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1075 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1076 OrthancPluginFreeFindMatcher(GetGlobalContext(), matcher_); |
2212
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1077 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1078 } |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1079 |
c02f6ec404d8
OrthancPlugins::FindMatcher
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2206
diff
changeset
|
1080 |
2213
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 bool FindMatcher::IsMatch(const void* dicom, |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1083 uint32_t size) const |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1084 { |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1085 int32_t result; |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1086 |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1087 if (matcher_ != NULL) |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1088 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1089 result = OrthancPluginFindMatcherIsMatch(GetGlobalContext(), matcher_, dicom, size); |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1090 } |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1091 else if (worklist_ != NULL) |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1092 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1093 result = OrthancPluginWorklistIsMatch(GetGlobalContext(), worklist_, dicom, size); |
2213
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 else |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1096 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
1097 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2213
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 |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1100 if (result == 0) |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1101 { |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1102 return false; |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1103 } |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1104 else if (result == 1) |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1105 { |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1106 return true; |
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 else |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1109 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
1110 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1111 } |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1112 } |
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1113 |
2231
61e0564d03bb
backwards compatibility within OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2215
diff
changeset
|
1114 #endif /* HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 */ |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1115 |
2968 | 1116 void AnswerJson(const Json::Value& value, |
1117 OrthancPluginRestOutput* output | |
1118 ) | |
1119 { | |
1120 Json::StyledWriter writer; | |
1121 std::string bodyString = writer.write(value); | |
1122 | |
1123 OrthancPluginAnswerBuffer(GetGlobalContext(), output, bodyString.c_str(), bodyString.size(), "application/json"); | |
1124 } | |
1125 | |
1126 bool RestApiGetString(std::string& result, | |
1127 const std::string& uri, | |
1128 bool applyPlugins) | |
1129 { | |
1130 MemoryBuffer answer; | |
1131 if (!answer.RestApiGet(uri, applyPlugins)) | |
1132 { | |
1133 return false; | |
1134 } | |
1135 else | |
1136 { | |
1137 answer.ToString(result); | |
1138 return true; | |
1139 } | |
1140 } | |
1141 | |
2213
95d1d758abb7
FindMatcher::IsMatch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2212
diff
changeset
|
1142 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1143 bool RestApiGet(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1144 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1145 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1147 MemoryBuffer answer; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1148 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1149 if (!answer.RestApiGet(uri, applyPlugins)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1150 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1152 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1154 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 answer.ToJson(result); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1156 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1161 bool RestApiPost(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1162 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1163 const char* body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1164 size_t bodySize, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1165 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1166 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1167 MemoryBuffer answer; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1168 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1169 if (!answer.RestApiPost(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 RestApiPost(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1182 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1183 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1184 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1185 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1186 Json::FastWriter writer; |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1187 return RestApiPost(result, uri, writer.write(body), applyPlugins); |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1188 } |
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 bool RestApiPut(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1192 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1193 const char* body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1194 size_t bodySize, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1195 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1196 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1197 MemoryBuffer answer; |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1198 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1199 if (!answer.RestApiPut(uri, body, bodySize, applyPlugins)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1200 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1201 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1202 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1203 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1204 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1205 answer.ToJson(result); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1206 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1207 } |
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 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1210 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1211 bool RestApiPut(Json::Value& result, |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1212 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1213 const Json::Value& body, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1214 bool applyPlugins) |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1215 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1216 Json::FastWriter writer; |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1217 return RestApiPut(result, uri, writer.write(body), applyPlugins); |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1218 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1219 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
1220 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1221 bool RestApiDelete(const std::string& uri, |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1222 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1223 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1224 OrthancPluginErrorCode error; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1225 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1226 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1227 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1228 error = OrthancPluginRestApiDeleteAfterPlugins(GetGlobalContext(), uri.c_str()); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1229 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1230 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1231 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1232 error = OrthancPluginRestApiDelete(GetGlobalContext(), uri.c_str()); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1233 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1234 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1235 if (error == OrthancPluginErrorCode_Success) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1236 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1237 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1238 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1239 else if (error == OrthancPluginErrorCode_UnknownResource || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1240 error == OrthancPluginErrorCode_InexistentItem) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1241 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1242 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1243 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1244 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1245 { |
2234
a78d15509a1c
cleaner separation of PluginException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2231
diff
changeset
|
1246 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1247 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1248 } |
2109
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 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1251 void ReportMinimalOrthancVersion(unsigned int major, |
2268
ce5c13b95dac
New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2267
diff
changeset
|
1252 unsigned int minor, |
ce5c13b95dac
New function: OrthancPluginRegisterIncomingHttpRequestFilter2()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2267
diff
changeset
|
1253 unsigned int revision) |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1254 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1255 LogError("Your version of the Orthanc core (" + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1256 std::string(GetGlobalContext()->orthancVersion) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1257 ") is too old to run this plugin (version " + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1258 boost::lexical_cast<std::string>(major) + "." + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1259 boost::lexical_cast<std::string>(minor) + "." + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1260 boost::lexical_cast<std::string>(revision) + |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1261 " is required)"); |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1262 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1263 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1264 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1265 bool CheckMinimalOrthancVersion(unsigned int major, |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1266 unsigned int minor, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1267 unsigned int revision) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1268 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1269 if (!HasGlobalContext()) |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1270 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1271 LogError("Bad Orthanc context in the plugin"); |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1272 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1273 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1274 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1275 if (!strcmp(GetGlobalContext()->orthancVersion, "mainline")) |
2109
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 // Assume compatibility with the mainline |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1278 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1279 } |
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 // Parse the version of the Orthanc core |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1282 int aa, bb, cc; |
2850 | 1283 if ( |
1284 #ifdef _MSC_VER | |
1285 sscanf_s | |
1286 #else | |
1287 sscanf | |
1288 #endif | |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1289 (GetGlobalContext()->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 || |
2850 | 1290 aa < 0 || |
1291 bb < 0 || | |
1292 cc < 0) | |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1293 { |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1294 return false; |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1295 } |
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 unsigned int a = static_cast<unsigned int>(aa); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1298 unsigned int b = static_cast<unsigned int>(bb); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1299 unsigned int c = static_cast<unsigned int>(cc); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1300 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1301 // Check the major version number |
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 if (a > major) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1304 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1305 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1306 } |
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 if (a < major) |
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 return false; |
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 |
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 // Check the minor version number |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1315 assert(a == major); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1316 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1317 if (b > minor) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1318 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1319 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1320 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1321 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1322 if (b < minor) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1323 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1324 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1325 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1326 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1327 // Check the patch level version number |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1328 assert(a == major && b == minor); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1329 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1330 if (c >= revision) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1331 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1332 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1333 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1334 else |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1335 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1336 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1337 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1338 } |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1339 |
2968 | 1340 const char* GetMimeType(const std::string& path) |
1341 { | |
1342 size_t dot = path.find_last_of('.'); | |
1343 | |
1344 std::string extension = (dot == std::string::npos) ? "" : path.substr(dot); | |
1345 std::transform(extension.begin(), extension.end(), extension.begin(), tolower); | |
1346 | |
1347 if (extension == ".html") | |
1348 { | |
1349 return "text/html"; | |
1350 } | |
1351 else if (extension == ".css") | |
1352 { | |
1353 return "text/css"; | |
1354 } | |
1355 else if (extension == ".js") | |
1356 { | |
1357 return "application/javascript"; | |
1358 } | |
1359 else if (extension == ".gif") | |
1360 { | |
1361 return "image/gif"; | |
1362 } | |
1363 else if (extension == ".svg") | |
1364 { | |
1365 return "image/svg+xml"; | |
1366 } | |
1367 else if (extension == ".json") | |
1368 { | |
1369 return "application/json"; | |
1370 } | |
1371 else if (extension == ".xml") | |
1372 { | |
1373 return "application/xml"; | |
1374 } | |
1375 else if (extension == ".wasm") | |
1376 { | |
1377 return "application/wasm"; | |
1378 } | |
1379 else if (extension == ".png") | |
1380 { | |
1381 return "image/png"; | |
1382 } | |
1383 else if (extension == ".jpg" || extension == ".jpeg") | |
1384 { | |
1385 return "image/jpeg"; | |
1386 } | |
1387 else | |
1388 { | |
1389 return "application/octet-stream"; | |
1390 } | |
1391 } | |
2817
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 #if HAS_ORTHANC_PLUGIN_PEERS == 1 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1396 size_t OrthancPeers::GetPeerIndex(const std::string& name) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1397 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1398 size_t index; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1399 if (LookupName(index, name)) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1400 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1401 return index; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1402 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1403 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1404 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1405 LogError("Inexistent peer: " + name); |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1406 ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1407 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1408 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1409 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1410 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1411 OrthancPeers::OrthancPeers() : |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1412 peers_(NULL), |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1413 timeout_(0) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1414 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1415 peers_ = OrthancPluginGetPeers(GetGlobalContext()); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1416 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1417 if (peers_ == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1418 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1419 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
|
1420 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1421 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1422 uint32_t count = OrthancPluginGetPeersCount(GetGlobalContext(), peers_); |
2817
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 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
|
1425 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1426 const char* name = OrthancPluginGetPeerName(GetGlobalContext(), peers_, i); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1427 if (name == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1428 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1429 OrthancPluginFreePeers(GetGlobalContext(), peers_); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1430 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
|
1431 } |
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 index_[name] = i; |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1438 OrthancPeers::~OrthancPeers() |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1439 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1440 if (peers_ != NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1441 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1442 OrthancPluginFreePeers(GetGlobalContext(), peers_); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1443 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1444 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1445 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1446 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1447 bool OrthancPeers::LookupName(size_t& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1448 const std::string& name) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1449 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1450 Index::const_iterator found = index_.find(name); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1451 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1452 if (found == index_.end()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1453 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1454 return false; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1455 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1456 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1457 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1458 target = found->second; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1459 return true; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1460 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1461 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1462 |
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 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
|
1465 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1466 if (index >= index_.size()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1467 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1468 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
|
1469 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1470 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1471 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1472 const char* s = OrthancPluginGetPeerName(GetGlobalContext(), peers_, static_cast<uint32_t>(index)); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1473 if (s == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1474 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1475 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
|
1476 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1477 else |
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 return s; |
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 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1485 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
|
1486 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1487 if (index >= index_.size()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1488 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1489 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
|
1490 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1491 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1492 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1493 const char* s = OrthancPluginGetPeerUrl(GetGlobalContext(), peers_, static_cast<uint32_t>(index)); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1494 if (s == NULL) |
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 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
|
1497 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1498 else |
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 return s; |
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 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1504 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1505 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1506 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
|
1507 { |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1508 return GetPeerUrl(GetPeerIndex(name)); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1509 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1510 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1511 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1512 bool OrthancPeers::LookupUserProperty(std::string& value, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1513 size_t index, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1514 const std::string& key) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1515 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1516 if (index >= index_.size()) |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1517 { |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1518 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
|
1519 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1520 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1521 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1522 const char* s = OrthancPluginGetPeerUserProperty(GetGlobalContext(), peers_, static_cast<uint32_t>(index), key.c_str()); |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1523 if (s == NULL) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1524 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1525 return false; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1526 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1527 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1528 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1529 value.assign(s); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1530 return true; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1531 } |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1532 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1533 } |
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 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1536 bool OrthancPeers::LookupUserProperty(std::string& value, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1537 const std::string& peer, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1538 const std::string& key) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1539 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1540 return LookupUserProperty(value, GetPeerIndex(peer), key); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1541 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1542 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2822
diff
changeset
|
1543 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1544 bool OrthancPeers::DoGet(MemoryBuffer& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1545 size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1546 const std::string& uri) const |
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 if (index >= index_.size()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1549 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1550 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
|
1551 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1552 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1553 OrthancPluginMemoryBuffer answer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1554 uint16_t status; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1555 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1556 (GetGlobalContext(), &answer, NULL, &status, peers_, |
2850 | 1557 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(), |
1558 0, NULL, NULL, NULL, 0, timeout_); | |
2817
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 if (code == OrthancPluginErrorCode_Success) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1561 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1562 target.Assign(answer); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1563 return (status == 200); |
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 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1566 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1567 return false; |
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 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1570 |
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 bool OrthancPeers::DoGet(MemoryBuffer& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1573 const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1574 const std::string& uri) const |
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 size_t index; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1577 return (LookupName(index, name) && |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1578 DoGet(target, index, uri)); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1579 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1580 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1581 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1582 bool OrthancPeers::DoGet(Json::Value& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1583 size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1584 const std::string& uri) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1585 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1586 MemoryBuffer buffer; |
2850 | 1587 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1588 if (DoGet(buffer, index, uri)) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1589 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1590 buffer.ToJson(target); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1591 return true; |
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 else |
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 return false; |
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 |
2850 | 1599 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1600 bool OrthancPeers::DoGet(Json::Value& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1601 const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1602 const std::string& uri) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1603 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1604 MemoryBuffer buffer; |
2850 | 1605 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1606 if (DoGet(buffer, name, uri)) |
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 buffer.ToJson(target); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1609 return true; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1610 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1611 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1612 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1613 return false; |
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 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1618 bool OrthancPeers::DoPost(MemoryBuffer& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1619 const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1620 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1621 const std::string& body) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1622 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1623 size_t index; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1624 return (LookupName(index, name) && |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1625 DoPost(target, index, uri, body)); |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1628 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1629 bool OrthancPeers::DoPost(Json::Value& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1630 size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1631 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1632 const std::string& body) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1633 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1634 MemoryBuffer buffer; |
2850 | 1635 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1636 if (DoPost(buffer, index, uri, body)) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1637 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1638 buffer.ToJson(target); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1639 return true; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1640 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1641 else |
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 return false; |
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 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1646 |
2850 | 1647 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1648 bool OrthancPeers::DoPost(Json::Value& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1649 const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1650 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1651 const std::string& body) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1652 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1653 MemoryBuffer buffer; |
2850 | 1654 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1655 if (DoPost(buffer, name, uri, body)) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1656 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1657 buffer.ToJson(target); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1658 return true; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1659 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1660 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1661 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1662 return false; |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1666 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1667 bool OrthancPeers::DoPost(MemoryBuffer& target, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1668 size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1669 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1670 const std::string& body) const |
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 if (index >= index_.size()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1673 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1674 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
|
1675 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1676 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1677 OrthancPluginMemoryBuffer answer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1678 uint16_t status; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1679 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1680 (GetGlobalContext(), &answer, NULL, &status, peers_, |
2850 | 1681 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(), |
1682 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
|
1683 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1684 if (code == OrthancPluginErrorCode_Success) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1685 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1686 target.Assign(answer); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1687 return (status == 200); |
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 else |
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 return false; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1692 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1693 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1696 bool OrthancPeers::DoPut(size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1697 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1698 const std::string& body) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1699 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1700 if (index >= index_.size()) |
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 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
|
1703 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1704 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1705 OrthancPluginMemoryBuffer answer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1706 uint16_t status; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1707 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1708 (GetGlobalContext(), &answer, NULL, &status, peers_, |
2850 | 1709 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(), |
1710 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
|
1711 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1712 if (code == OrthancPluginErrorCode_Success) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1713 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1714 OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1715 return (status == 200); |
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 else |
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 false; |
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 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1724 bool OrthancPeers::DoPut(const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1725 const std::string& uri, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1726 const std::string& body) const |
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 size_t index; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1729 return (LookupName(index, name) && |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1730 DoPut(index, uri, body)); |
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 |
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 bool OrthancPeers::DoDelete(size_t index, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1735 const std::string& uri) const |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1736 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1737 if (index >= index_.size()) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1738 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1739 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
|
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 OrthancPluginMemoryBuffer answer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1743 uint16_t status; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1744 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1745 (GetGlobalContext(), &answer, NULL, &status, peers_, |
2850 | 1746 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(), |
1747 0, NULL, NULL, NULL, 0, timeout_); | |
2817
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 if (code == OrthancPluginErrorCode_Success) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1750 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1751 OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1752 return (status == 200); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1753 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1754 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1755 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1756 return false; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1757 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1761 bool OrthancPeers::DoDelete(const std::string& name, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1762 const std::string& uri) const |
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 size_t index; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1765 return (LookupName(index, name) && |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1766 DoDelete(index, uri)); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1767 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1768 #endif |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1769 |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1772 #if HAS_ORTHANC_PLUGIN_JOB == 1 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1773 void OrthancJob::CallbackFinalize(void* job) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1774 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1775 if (job != NULL) |
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 delete reinterpret_cast<OrthancJob*>(job); |
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 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1782 float OrthancJob::CallbackGetProgress(void* job) |
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 assert(job != NULL); |
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 try |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1787 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1788 return reinterpret_cast<OrthancJob*>(job)->progress_; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1789 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1790 catch (...) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1791 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1792 return 0; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1793 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1794 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1797 const char* OrthancJob::CallbackGetContent(void* job) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1798 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1799 assert(job != NULL); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1800 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1801 try |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1802 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1803 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
|
1804 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1805 catch (...) |
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 return 0; |
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 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1812 const char* OrthancJob::CallbackGetSerialized(void* job) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1813 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1814 assert(job != NULL); |
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 try |
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 const OrthancJob& tmp = *reinterpret_cast<OrthancJob*>(job); |
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 if (tmp.hasSerialized_) |
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 tmp.serialized_.c_str(); |
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 else |
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 return NULL; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1827 } |
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 catch (...) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1830 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1831 return 0; |
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 |
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 OrthancPluginJobStepStatus OrthancJob::CallbackStep(void* job) |
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 assert(job != NULL); |
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 try |
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 return reinterpret_cast<OrthancJob*>(job)->Step(); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1843 } |
2822 | 1844 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS&) |
2817
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 return OrthancPluginJobStepStatus_Failure; |
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 catch (...) |
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 return OrthancPluginJobStepStatus_Failure; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1851 } |
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 OrthancPluginErrorCode OrthancJob::CallbackStop(void* job, |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1856 OrthancPluginJobStopReason reason) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1857 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1858 assert(job != NULL); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1859 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1860 try |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1861 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1862 reinterpret_cast<OrthancJob*>(job)->Stop(reason); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1863 return OrthancPluginErrorCode_Success; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1864 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1865 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e) |
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 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); |
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 catch (...) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1870 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1871 return OrthancPluginErrorCode_Plugin; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1872 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1873 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1876 OrthancPluginErrorCode OrthancJob::CallbackReset(void* job) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1877 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1878 assert(job != NULL); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1879 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1880 try |
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 reinterpret_cast<OrthancJob*>(job)->Reset(); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1883 return OrthancPluginErrorCode_Success; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1884 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1885 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1886 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1887 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); |
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 catch (...) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1890 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1891 return OrthancPluginErrorCode_Plugin; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1892 } |
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 |
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 void OrthancJob::ClearContent() |
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 Json::Value empty = Json::objectValue; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1899 UpdateContent(empty); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1900 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1901 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1902 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1903 void OrthancJob::UpdateContent(const Json::Value& content) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1904 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1905 if (content.type() != Json::objectValue) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1906 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1907 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
|
1908 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1909 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1910 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1911 Json::FastWriter writer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1912 content_ = writer.write(content); |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1916 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1917 void OrthancJob::ClearSerialized() |
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 hasSerialized_ = false; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1920 serialized_.clear(); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1921 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1924 void OrthancJob::UpdateSerialized(const Json::Value& serialized) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1925 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1926 if (serialized.type() != Json::objectValue) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1927 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1928 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
|
1929 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1930 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1931 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1932 Json::FastWriter writer; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1933 serialized_ = writer.write(serialized); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1934 hasSerialized_ = true; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1935 } |
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 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1939 void OrthancJob::UpdateProgress(float progress) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1940 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1941 if (progress < 0 || |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1942 progress > 1) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1943 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1944 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
|
1945 } |
2850 | 1946 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1947 progress_ = progress; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1948 } |
2850 | 1949 |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1950 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1951 OrthancJob::OrthancJob(const std::string& jobType) : |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1952 jobType_(jobType), |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1953 progress_(0) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1954 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1955 ClearContent(); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1956 ClearSerialized(); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1957 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1958 |
2850 | 1959 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1960 OrthancPluginJob* OrthancJob::Create(OrthancJob* job) |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1961 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1962 if (job == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1963 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1964 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
|
1965 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1966 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1967 OrthancPluginJob* orthanc = OrthancPluginCreateJob( |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1968 GetGlobalContext(), job, CallbackFinalize, job->jobType_.c_str(), |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1969 CallbackGetProgress, CallbackGetContent, CallbackGetSerialized, |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1970 CallbackStep, CallbackStop, CallbackReset); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1971 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1972 if (orthanc == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1973 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1974 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
|
1975 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1976 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1977 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1978 return orthanc; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1979 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1980 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1981 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1982 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1983 std::string OrthancJob::Submit(OrthancJob* job, |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1984 int priority) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1985 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1986 OrthancPluginJob* orthanc = Create(job); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1987 |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1988 char* id = OrthancPluginSubmitJob(GetGlobalContext(), orthanc, priority); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1989 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1990 if (id == NULL) |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1991 { |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1992 LogError("Plugin cannot submit job"); |
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
1993 OrthancPluginFreeJob(GetGlobalContext(), orthanc); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1994 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
|
1995 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1996 else |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1997 { |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1998 std::string tmp(id); |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
1999 tmp.assign(id); |
2958
bb7a66efbeb1
OrthancPlugins::SetGlobalContext() in OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2851
diff
changeset
|
2000 OrthancPluginFreeString(GetGlobalContext(), id); |
2817
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
2001 |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
2002 return tmp; |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
2003 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
2004 } |
473bf302d629
C++ wrappers around OrthancPluginJob and OrthancPluginPeers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2803
diff
changeset
|
2005 #endif |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2006 } |