annotate Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h @ 524:48aba35fe64e large-queries

merged BEGIN and SET TRANSACTION statements
author Alain Mazy <am@orthanc.team>
date Tue, 09 Jul 2024 16:30:52 +0200
parents 54d518dcd74a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
459
ecd0b719cff5 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 425
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
160
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
13 *
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "OrthancPluginException.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <orthanc/OrthancCPlugin.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <boost/noncopyable.hpp>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <boost/lexical_cast.hpp>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <boost/date_time/posix_time/posix_time.hpp>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <json/value.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include <vector>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include <list>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include <set>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include <map>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 * The definition of ORTHANC_PLUGINS_VERSION_IS_ABOVE below is for
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 * backward compatibility with Orthanc SDK <= 1.3.0.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 * $ hg diff -r Orthanc-1.3.0:Orthanc-1.3.1 ../../../Plugins/Include/orthanc/OrthancCPlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 #if !defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 #define ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(major, minor, revision) \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 (ORTHANC_VERSION_MAJOR > major || \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 (ORTHANC_VERSION_MAJOR == major && \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 (ORTHANC_VERSION_MINOR > minor || \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 (ORTHANC_VERSION_MINOR == minor && \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 ORTHANC_VERSION_REVISION >= revision))))
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 # define HAS_ORTHANC_PLUGIN_PEERS 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 # define HAS_ORTHANC_PLUGIN_JOB 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 # define HAS_ORTHANC_PLUGIN_PEERS 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 # define HAS_ORTHANC_PLUGIN_JOB 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 # define HAS_ORTHANC_PLUGIN_METRICS 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 # define HAS_ORTHANC_PLUGIN_METRICS 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 1, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 # define HAS_ORTHANC_PLUGIN_HTTP_CLIENT 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 # define HAS_ORTHANC_PLUGIN_HTTP_CLIENT 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 7)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 # define HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_CLIENT 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 # define HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_CLIENT 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 7)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 # define HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_SERVER 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 # define HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_SERVER 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 6, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 # define HAS_ORTHANC_PLUGIN_STORAGE_COMMITMENT_SCP 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 # define HAS_ORTHANC_PLUGIN_STORAGE_COMMITMENT_SCP 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
119 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
120 # define HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
121 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
122 # define HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
123 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
124
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
125 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 10, 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
126 # define HAS_ORTHANC_PLUGIN_WEBDAV 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
127 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
128 # define HAS_ORTHANC_PLUGIN_WEBDAV 0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
129 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
130
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
131 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
132 # define HAS_ORTHANC_PLUGIN_LOG_MESSAGE 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
133 #else
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
134 # define HAS_ORTHANC_PLUGIN_LOG_MESSAGE 0
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
135 #endif
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
136
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
137
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
138 // Macro to tag a function as having been deprecated
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
139 #if (__cplusplus >= 201402L) // C++14
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
140 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) [[deprecated]] f
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
141 #elif defined(__GNUC__) || defined(__clang__)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
142 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) f __attribute__((deprecated))
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
143 #elif defined(_MSC_VER)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
144 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) __declspec(deprecated) f
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
145 #else
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
146 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
147 #endif
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
148
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
149
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
150 #if !defined(__ORTHANC_FILE__)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
151 # if defined(_MSC_VER)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
152 # pragma message("Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries")
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
153 # else
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
154 # warning Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
155 # endif
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
156 # define __ORTHANC_FILE__ __FILE__
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
157 #endif
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
158
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
159
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
160 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
161 # define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Error, __ORTHANC_FILE__, __LINE__, msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
162 # define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Warning, __ORTHANC_FILE__, __LINE__, msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
163 # define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Info, __ORTHANC_FILE__, __LINE__, msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
164 #else
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
165 # define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogError(msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
166 # define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogWarning(msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
167 # define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogInfo(msg)
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
168 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 namespace OrthancPlugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 typedef void (*RestCallback) (OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 const OrthancPluginHttpRequest* request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 void SetGlobalContext(OrthancPluginContext* context);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
179 void SetGlobalContext(OrthancPluginContext* context,
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
180 const char* pluginName);
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
181
425
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
182 void ResetGlobalContext();
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
183
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 bool HasGlobalContext();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 OrthancPluginContext* GetGlobalContext();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 class OrthancImage;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 class MemoryBuffer : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 OrthancPluginMemoryBuffer buffer_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 void Check(OrthancPluginErrorCode code);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 bool CheckHttp(OrthancPluginErrorCode code);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 MemoryBuffer();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 // This constructor makes a copy of the given buffer in the memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 // handled by the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 MemoryBuffer(const void* buffer,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 size_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 ~MemoryBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 OrthancPluginMemoryBuffer* operator*()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 return &buffer_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 // This transfers ownership from "other" to "this"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 void Assign(OrthancPluginMemoryBuffer& other);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 void Swap(MemoryBuffer& other);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 OrthancPluginMemoryBuffer Release();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 const char* GetData() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 if (buffer_.size > 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 return reinterpret_cast<const char*>(buffer_.data);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 return NULL;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 size_t GetSize() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 return buffer_.size;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 bool IsEmpty() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 return GetSize() == 0 || GetData() == NULL;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 void Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 void ToString(std::string& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 void ToJson(Json::Value& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 bool RestApiGet(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 bool RestApiGet(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 bool RestApiPost(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 bool RestApiPut(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 bool RestApiPost(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
277 #if HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
278 bool RestApiPost(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
279 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
280 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
281 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
282
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
283 bool RestApiPost(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
284 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
285 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
286 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
287 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
288 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
289
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 bool RestApiPut(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 bool RestApiPost(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 bool applyPlugins)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 return RestApiPost(uri, body.empty() ? NULL : body.c_str(), body.size(), applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 bool RestApiPut(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 bool applyPlugins)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 return RestApiPut(uri, body.empty() ? NULL : body.c_str(), body.size(), applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 void CreateDicom(const Json::Value& tags,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 OrthancPluginCreateDicomFlags flags);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 void CreateDicom(const Json::Value& tags,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 const OrthancImage& pixelData,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 OrthancPluginCreateDicomFlags flags);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 void ReadFile(const std::string& path);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 void GetDicomQuery(const OrthancPluginWorklistQuery* query);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 void DicomToJson(Json::Value& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 OrthancPluginDicomToJsonFormat format,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 OrthancPluginDicomToJsonFlags flags,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 uint32_t maxStringLength);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 bool HttpGet(const std::string& url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 const std::string& username,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 const std::string& password);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 bool HttpPost(const std::string& url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 const std::string& username,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 const std::string& password);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 bool HttpPut(const std::string& url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 const std::string& username,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 const std::string& password);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 void GetDicomInstance(const std::string& instanceId);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 class OrthancString : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 char* str_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 void Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 OrthancString() :
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 str_(NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 ~OrthancString()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 // This transfers ownership, warning: The string must have been
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 // allocated by the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 void Assign(char* str);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 const char* GetContent() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 return str_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
369 bool IsNullOrEmpty() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
370 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
371 return str_ == NULL || str_[0] == 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
372 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
373
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 void ToString(std::string& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 void ToJson(Json::Value& target) const;
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
377
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
378 void ToJsonWithoutComments(Json::Value& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
379 };
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 class OrthancConfiguration : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 Json::Value configuration_; // Necessarily a Json::objectValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 std::string path_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 std::string GetPath(const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 void LoadConfiguration();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 public:
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
393 OrthancConfiguration(); // loads the full Orthanc configuration
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 explicit OrthancConfiguration(bool load);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
397 explicit OrthancConfiguration(const Json::Value& configuration, const std::string& path); // e.g. to load a section from a default json content
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
398
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 const Json::Value& GetJson() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 return configuration_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 bool IsSection(const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 void GetSection(OrthancConfiguration& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 bool LookupStringValue(std::string& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 bool LookupIntegerValue(int& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 bool LookupUnsignedIntegerValue(unsigned int& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 bool LookupBooleanValue(bool& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 bool LookupFloatValue(float& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 bool LookupListOfStrings(std::list<std::string>& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 bool allowSingleString) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 bool LookupSetOfStrings(std::set<std::string>& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 bool allowSingleString) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 std::string GetStringValue(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 const std::string& defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 int GetIntegerValue(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 int defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 unsigned int GetUnsignedIntegerValue(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 unsigned int defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 bool GetBooleanValue(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 bool defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 float GetFloatValue(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 float defaultValue) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 void GetDictionary(std::map<std::string, std::string>& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 class OrthancImage : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 OrthancPluginImage* image_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 void Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 void CheckImageAvailable() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 OrthancImage();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 explicit OrthancImage(OrthancPluginImage* image);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 OrthancImage(OrthancPluginPixelFormat format,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 uint32_t width,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 uint32_t height);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 OrthancImage(OrthancPluginPixelFormat format,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 uint32_t width,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 uint32_t height,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 uint32_t pitch,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 void* buffer);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 ~OrthancImage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 Clear();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 void UncompressPngImage(const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 size_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 void UncompressJpegImage(const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 size_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 void DecodeDicomImage(const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 size_t size,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 unsigned int frame);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 OrthancPluginPixelFormat GetPixelFormat() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 unsigned int GetWidth() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 unsigned int GetHeight() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 unsigned int GetPitch() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 void* GetBuffer() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 const OrthancPluginImage* GetObject() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 return image_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 void CompressPngImage(MemoryBuffer& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 void CompressJpegImage(MemoryBuffer& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 uint8_t quality) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 void AnswerPngImage(OrthancPluginRestOutput* output) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 void AnswerJpegImage(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 uint8_t quality) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 void* GetWriteableBuffer();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 OrthancPluginImage* Release();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 #if HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 class FindMatcher : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 OrthancPluginFindMatcher* matcher_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 const OrthancPluginWorklistQuery* worklist_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 void SetupDicom(const void* query,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 uint32_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 explicit FindMatcher(const OrthancPluginWorklistQuery* worklist);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 FindMatcher(const void* query,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 uint32_t size)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 SetupDicom(query, size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 explicit FindMatcher(const MemoryBuffer& dicom)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 SetupDicom(dicom.GetData(), dicom.GetSize());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 ~FindMatcher();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 bool IsMatch(const void* dicom,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 uint32_t size) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 bool IsMatch(const MemoryBuffer& dicom) const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 return IsMatch(dicom.GetData(), dicom.GetSize());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
193
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
558 bool ReadJson(Json::Value& target,
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
559 const std::string& source);
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
560
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
561 bool ReadJson(Json::Value& target,
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
562 const void* buffer,
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
563 size_t size);
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
564
272
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
565 bool ReadJsonWithoutComments(Json::Value& target,
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
566 const std::string& source);
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
567
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
568 bool ReadJsonWithoutComments(Json::Value& target,
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
569 const void* buffer,
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
570 size_t size);
c7dc70a0a477 upgrade to Orthanc SDK 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
571
193
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
572 void WriteFastJson(std::string& target,
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
573 const Json::Value& source);
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
574
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
575 void WriteStyledJson(std::string& target,
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
576 const Json::Value& source);
3236894320d6 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 170
diff changeset
577
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 bool RestApiGet(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
582 bool RestApiGet(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
583 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
584 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
585 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
586
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 bool RestApiGetString(std::string& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 bool RestApiGetString(std::string& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 bool RestApiPost(std::string& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 bool RestApiPost(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
608 #if HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
609 bool RestApiPost(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
610 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
611 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
612 const std::map<std::string, std::string>& httpHeaders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
613 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
614 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
615
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 bool RestApiPost(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 inline bool RestApiPost(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 bool applyPlugins)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 return RestApiPost(result, uri, body.empty() ? NULL : body.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 body.size(), applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 inline bool RestApiPost(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 const MemoryBuffer& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 bool applyPlugins)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 return RestApiPost(result, uri, body.GetData(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 body.GetSize(), applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 bool RestApiPut(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 const void* body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 size_t bodySize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 bool RestApiPut(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 inline bool RestApiPut(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 bool applyPlugins)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 return RestApiPut(result, uri, body.empty() ? NULL : body.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 body.size(), applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 bool RestApiDelete(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 bool applyPlugins);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 bool HttpDelete(const std::string& url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 const std::string& username,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 const std::string& password);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 void AnswerJson(const Json::Value& value,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 OrthancPluginRestOutput* output);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 void AnswerString(const std::string& answer,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 const char* mimeType,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 OrthancPluginRestOutput* output);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 void AnswerHttpError(uint16_t httpError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 OrthancPluginRestOutput* output);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 void AnswerMethodNotAllowed(OrthancPluginRestOutput* output, const char* allowedMethods);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 const char* AutodetectMimeType(const std::string& path);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
682 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
683 void LogMessage(OrthancPluginLogLevel level,
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
684 const char* file,
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
685 uint32_t line,
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
686 const std::string& message);
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
687 #endif
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
688
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
689 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
690 // Use macro ORTHANC_PLUGINS_LOG_ERROR() instead
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
691 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogError(const std::string& message));
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
692 #else
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 void LogError(const std::string& message);
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
694 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
696 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
697 // Use macro ORTHANC_PLUGINS_LOG_WARNING() instead
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
698 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogWarning(const std::string& message));
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
699 #else
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700 void LogWarning(const std::string& message);
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
701 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
703 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
704 // Use macro ORTHANC_PLUGINS_LOG_INFO() instead
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
705 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogInfo(const std::string& message));
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
706 #else
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 void LogInfo(const std::string& message);
507
54d518dcd74a updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 491
diff changeset
708 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 void ReportMinimalOrthancVersion(unsigned int major,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 unsigned int minor,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 unsigned int revision);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 bool CheckMinimalOrthancVersion(unsigned int major,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715 unsigned int minor,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 unsigned int revision);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
718 bool CheckMinimalVersion(const char* version,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
719 unsigned int major,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
720 unsigned int minor,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
721 unsigned int revision);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 namespace Internals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 template <RestCallback Callback>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 static OrthancPluginErrorCode Protect(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 const OrthancPluginHttpRequest* request)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 try
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 Callback(output, url, request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 return OrthancPluginErrorCode_Success;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 #if HAS_ORTHANC_EXCEPTION == 1 && HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 if (HasGlobalContext() &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 e.HasDetails())
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 // The "false" instructs Orthanc not to log the detailed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 // error message. This is to avoid duplicating the details,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 // because "OrthancException" already does it on construction.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744 OrthancPluginSetHttpErrorDetails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 (GetGlobalContext(), output, e.GetDetails(), false);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 catch (boost::bad_lexical_cast&)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 return OrthancPluginErrorCode_BadFileFormat;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 catch (...)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 return OrthancPluginErrorCode_Plugin;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 template <RestCallback Callback>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 void RegisterRestCallback(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 bool isThreadSafe)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 if (isThreadSafe)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 OrthancPluginRegisterRestCallbackNoLock
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 OrthancPluginRegisterRestCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 #if HAS_ORTHANC_PLUGIN_PEERS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 class OrthancPeers : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 typedef std::map<std::string, uint32_t> Index;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 OrthancPluginPeers *peers_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 Index index_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 uint32_t timeout_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 size_t GetPeerIndex(const std::string& name) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 OrthancPeers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 ~OrthancPeers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 uint32_t GetTimeout() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799 return timeout_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 void SetTimeout(uint32_t timeout)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 timeout_ = timeout;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 bool LookupName(size_t& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 const std::string& name) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 std::string GetPeerName(size_t index) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 std::string GetPeerUrl(size_t index) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 std::string GetPeerUrl(const std::string& name) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 size_t GetPeersCount() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 return index_.size();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 bool LookupUserProperty(std::string& value,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 size_t index,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 bool LookupUserProperty(std::string& value,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 const std::string& peer,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 const std::string& key) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 bool DoGet(MemoryBuffer& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 size_t index,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
831 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
832 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 bool DoGet(MemoryBuffer& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 const std::string& name,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
836 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
837 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839 bool DoGet(Json::Value& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 size_t index,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
841 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
842 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 bool DoGet(Json::Value& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 const std::string& name,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
846 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
847 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 bool DoPost(MemoryBuffer& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 size_t index,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
852 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
853 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 bool DoPost(MemoryBuffer& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 const std::string& name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
858 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
859 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 bool DoPost(Json::Value& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 size_t index,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
864 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
865 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 bool DoPost(Json::Value& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 const std::string& name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
870 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
871 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873 bool DoPut(size_t index,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
875 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
876 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 bool DoPut(const std::string& name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 const std::string& uri,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
880 const std::string& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
881 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
883 bool DoDelete(size_t index,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
884 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
885 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887 bool DoDelete(const std::string& name,
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
888 const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
889 const std::map<std::string, std::string>& headers) const;
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 #if HAS_ORTHANC_PLUGIN_JOB == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 class OrthancJob : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 std::string jobType_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 std::string content_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 bool hasSerialized_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 std::string serialized_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 float progress_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 static void CallbackFinalize(void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 static float CallbackGetProgress(void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
909 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 11, 3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
910 static OrthancPluginErrorCode CallbackGetContent(OrthancPluginMemoryBuffer* target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
911 void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
912 #else
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 static const char* CallbackGetContent(void* job);
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
914 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
916 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 11, 3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
917 static int32_t CallbackGetSerialized(OrthancPluginMemoryBuffer* target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
918 void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
919 #else
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 static const char* CallbackGetSerialized(void* job);
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
921 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 static OrthancPluginJobStepStatus CallbackStep(void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 static OrthancPluginErrorCode CallbackStop(void* job,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 OrthancPluginJobStopReason reason);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 static OrthancPluginErrorCode CallbackReset(void* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 protected:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 void ClearContent();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 void UpdateContent(const Json::Value& content);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 void ClearSerialized();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 void UpdateSerialized(const Json::Value& serialized);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 void UpdateProgress(float progress);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 public:
170
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 167
diff changeset
942 explicit OrthancJob(const std::string& jobType);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 virtual ~OrthancJob()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 virtual OrthancPluginJobStepStatus Step() = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 virtual void Stop(OrthancPluginJobStopReason reason) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 virtual void Reset() = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 static OrthancPluginJob* Create(OrthancJob* job /* takes ownership */);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 static std::string Submit(OrthancJob* job /* takes ownership */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 int priority);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 static void SubmitAndWait(Json::Value& result,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 OrthancJob* job /* takes ownership */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 int priority);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 // Submit a job from a POST on the REST API with the same
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 // conventions as in the Orthanc core (according to the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 // "Synchronous" and "Priority" options)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966 static void SubmitFromRestApiPost(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
967 const Json::Value& body,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968 OrthancJob* job);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
973 #if HAS_ORTHANC_PLUGIN_METRICS == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 inline void SetMetricsValue(char* name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 float value)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977 OrthancPluginSetMetricsValue(GetGlobalContext(), name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978 value, OrthancPluginMetricsType_Default);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981 class MetricsTimer : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
984 std::string name_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
985 boost::posix_time::ptime start_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 explicit MetricsTimer(const char* name);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990 ~MetricsTimer();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995 #if HAS_ORTHANC_PLUGIN_HTTP_CLIENT == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 class HttpClient : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
997 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
998 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
999 typedef std::map<std::string, std::string> HttpHeaders;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1000
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001 class IRequestBody : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004 virtual ~IRequestBody()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008 virtual bool ReadNextChunk(std::string& chunk) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1011
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 class IAnswer : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1014 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015 virtual ~IAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019 virtual void AddHeader(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 const std::string& value) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 virtual void AddChunk(const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 size_t size) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 class RequestBodyWrapper;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 uint16_t httpStatus_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 OrthancPluginHttpMethod method_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 std::string url_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033 HttpHeaders headers_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 std::string username_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 std::string password_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 uint32_t timeout_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 std::string certificateFile_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 std::string certificateKeyFile_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 std::string certificateKeyPassword_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 bool pkcs11_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 std::string fullBody_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042 IRequestBody* chunkedBody_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 bool allowChunkedTransfers_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 #if HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_CLIENT == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 void ExecuteWithStream(uint16_t& httpStatus, // out
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 IAnswer& answer, // out
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 IRequestBody& body) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 void ExecuteWithoutStream(uint16_t& httpStatus, // out
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 HttpHeaders& answerHeaders, // out
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 std::string& answerBody, // out
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 const std::string& body) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 HttpClient();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 uint16_t GetHttpStatus() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 return httpStatus_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 void SetMethod(OrthancPluginHttpMethod method)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 method_ = method;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069 const std::string& GetUrl() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071 return url_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074 void SetUrl(const std::string& url)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1075 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 url_ = url;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1078
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079 void SetHeaders(const HttpHeaders& headers)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 headers_ = headers;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1084 void AddHeader(const std::string& key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 const std::string& value)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 headers_[key] = value;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090 void AddHeaders(const HttpHeaders& headers);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 void SetCredentials(const std::string& username,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 const std::string& password);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 void ClearCredentials();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097 void SetTimeout(unsigned int timeout) // 0 for default timeout
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1098 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1099 timeout_ = timeout;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1101
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1102 void SetCertificate(const std::string& certificateFile,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1103 const std::string& keyFile,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1104 const std::string& keyPassword);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1105
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 void ClearCertificate();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 void SetPkcs11(bool pkcs11)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110 pkcs11_ = pkcs11;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113 void ClearBody();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1115 void SwapBody(std::string& body);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 void SetBody(const std::string& body);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 void SetBody(IRequestBody& body);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1120
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121 // This function can be used to disable chunked transfers if the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122 // remote server is Orthanc with a version <= 1.5.6.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123 void SetChunkedTransfersAllowed(bool allow)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1124 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125 allowChunkedTransfers_ = allow;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1126 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1127
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128 bool IsChunkedTransfersAllowed() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1129 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1130 return allowChunkedTransfers_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1132
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1133 void Execute(IAnswer& answer);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1134
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1135 void Execute(HttpHeaders& answerHeaders /* out */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1136 std::string& answerBody /* out */);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1137
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1138 void Execute(HttpHeaders& answerHeaders /* out */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1139 Json::Value& answerBody /* out */);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1141 void Execute();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1143 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1144
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1145
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1146
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1147 class IChunkedRequestReader : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1150 virtual ~IChunkedRequestReader()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1151 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1152 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154 virtual void AddChunk(const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1155 size_t size) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157 virtual void Execute(OrthancPluginRestOutput* output) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1159
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1160
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1161 typedef IChunkedRequestReader* (*ChunkedRestCallback) (const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1162 const OrthancPluginHttpRequest* request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1163
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1164
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1165 namespace Internals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1166 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167 void NullRestCallback(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1168 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 const OrthancPluginHttpRequest* request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 IChunkedRequestReader *NullChunkedRestCallback(const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 const OrthancPluginHttpRequest* request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1175 #if HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_SERVER == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1176 template <ChunkedRestCallback Callback>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 static OrthancPluginErrorCode ChunkedProtect(OrthancPluginServerChunkedRequestReader** reader,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179 const OrthancPluginHttpRequest* request)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1181 try
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183 if (reader == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1185 return OrthancPluginErrorCode_InternalError;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1186 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1187 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1188 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1189 *reader = reinterpret_cast<OrthancPluginServerChunkedRequestReader*>(Callback(url, request));
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1190 if (*reader == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1191 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 return OrthancPluginErrorCode_Plugin;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 return OrthancPluginErrorCode_Success;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1198 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1199 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1200 catch (ORTHANC_PLUGINS_EXCEPTION_CLASS& e)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 catch (boost::bad_lexical_cast&)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1205 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1206 return OrthancPluginErrorCode_BadFileFormat;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1207 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208 catch (...)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 return OrthancPluginErrorCode_Plugin;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214 OrthancPluginErrorCode ChunkedRequestReaderAddChunk(
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215 OrthancPluginServerChunkedRequestReader* reader,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216 const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 uint32_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1218
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1219 OrthancPluginErrorCode ChunkedRequestReaderExecute(
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1220 OrthancPluginServerChunkedRequestReader* reader,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1221 OrthancPluginRestOutput* output);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1222
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1223 void ChunkedRequestReaderFinalize(
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1224 OrthancPluginServerChunkedRequestReader* reader);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1225
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1226 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1227
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1228 OrthancPluginErrorCode ChunkedRestCompatibility(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1229 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1230 const OrthancPluginHttpRequest* request,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1231 RestCallback GetHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1232 ChunkedRestCallback PostHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1233 RestCallback DeleteHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1234 ChunkedRestCallback PutHandler);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1235
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1236 template<
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1237 RestCallback GetHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1238 ChunkedRestCallback PostHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1239 RestCallback DeleteHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1240 ChunkedRestCallback PutHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1241 >
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1242 inline OrthancPluginErrorCode ChunkedRestCompatibility(OrthancPluginRestOutput* output,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1243 const char* url,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1244 const OrthancPluginHttpRequest* request)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1245 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1246 return ChunkedRestCompatibility(output, url, request, GetHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1247 PostHandler, DeleteHandler, PutHandler);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1248 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1249 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1250 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1254 // NB: We use a templated class instead of a templated function, because
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 // default values are only available in functions since C++11
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1256 template<
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1257 RestCallback GetHandler = Internals::NullRestCallback,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1258 ChunkedRestCallback PostHandler = Internals::NullChunkedRestCallback,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1259 RestCallback DeleteHandler = Internals::NullRestCallback,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1260 ChunkedRestCallback PutHandler = Internals::NullChunkedRestCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1261 >
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1262 class ChunkedRestRegistration : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1263 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1264 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1265 static void Apply(const std::string& uri)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1266 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1267 #if HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_SERVER == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1268 OrthancPluginRegisterChunkedRestCallback(
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1269 GetGlobalContext(), uri.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1270 GetHandler == Internals::NullRestCallback ? NULL : Internals::Protect<GetHandler>,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1271 PostHandler == Internals::NullChunkedRestCallback ? NULL : Internals::ChunkedProtect<PostHandler>,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1272 DeleteHandler == Internals::NullRestCallback ? NULL : Internals::Protect<DeleteHandler>,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1273 PutHandler == Internals::NullChunkedRestCallback ? NULL : Internals::ChunkedProtect<PutHandler>,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1274 Internals::ChunkedRequestReaderAddChunk,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1275 Internals::ChunkedRequestReaderExecute,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1276 Internals::ChunkedRequestReaderFinalize);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1277 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1278 OrthancPluginRegisterRestCallbackNoLock(
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1279 GetGlobalContext(), uri.c_str(),
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1280 Internals::ChunkedRestCompatibility<GetHandler, PostHandler, DeleteHandler, PutHandler>);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1281 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1282 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1284
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1285
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287 #if HAS_ORTHANC_PLUGIN_STORAGE_COMMITMENT_SCP == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1288 class IStorageCommitmentScpHandler : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1289 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1290 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1291 virtual ~IStorageCommitmentScpHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1292 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1293 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1294
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1295 virtual OrthancPluginStorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1296 const std::string& sopInstanceUid) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1297
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1298 static OrthancPluginErrorCode Lookup(OrthancPluginStorageCommitmentFailureReason* target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1299 void* rawHandler,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1300 const char* sopClassUid,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301 const char* sopInstanceUid);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 static void Destructor(void* rawHandler);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1304 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1305 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1307
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 class DicomInstance : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1309 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1311 bool toFree_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1312
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1313 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 6, 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 const OrthancPluginDicomInstance* instance_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1315 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1316 OrthancPluginDicomInstance* instance_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1317 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1318
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1319 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1320 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 6, 1)
167
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 160
diff changeset
1321 explicit DicomInstance(const OrthancPluginDicomInstance* instance);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1322 #else
167
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 160
diff changeset
1323 explicit DicomInstance(OrthancPluginDicomInstance* instance);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1324 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1325
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1326 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327 DicomInstance(const void* buffer,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 size_t size);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1329 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1330
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1331 ~DicomInstance();
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1332
425
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1333 const OrthancPluginDicomInstance* GetObject() const
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1334 {
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1335 return instance_;
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1336 }
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1337
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1338 std::string GetRemoteAet() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1340 const void* GetBuffer() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1342 return OrthancPluginGetInstanceData(GetGlobalContext(), instance_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 size_t GetSize() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1347 return static_cast<size_t>(OrthancPluginGetInstanceSize(GetGlobalContext(), instance_));
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1348 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1349
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1350 void GetJson(Json::Value& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1351
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1352 void GetSimplifiedJson(Json::Value& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1353
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1354 OrthancPluginInstanceOrigin GetOrigin() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1355 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1356 return OrthancPluginGetInstanceOrigin(GetGlobalContext(), instance_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1357 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 6, 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360 std::string GetTransferSyntaxUid() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 6, 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 bool HasPixelData() const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1366
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1367 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1368 unsigned int GetFramesCount() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1369 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370 return OrthancPluginGetInstanceFramesCount(GetGlobalContext(), instance_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1371 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1373
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 void GetRawFrame(std::string& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376 unsigned int frameIndex) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1378
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380 OrthancImage* GetDecodedFrame(unsigned int frameIndex) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384 void Serialize(std::string& target) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1385 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1386
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1387 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388 static DicomInstance* Transcode(const void* buffer,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389 size_t size,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390 const std::string& transferSyntax);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391 #endif
425
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1392
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1393 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 1)
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1394 static DicomInstance* Load(const std::string& instanceId,
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1395 OrthancPluginLoadDicomInstanceMode mode);
c1b0f3c4e1f5 sync Orthanc code
Alain Mazy <am@osimis.io>
parents: 397
diff changeset
1396 #endif
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1397 };
397
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1398
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1399 // helper method to convert Http headers from the plugin SDK to a std::map
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1400 void GetHttpHeaders(std::map<std::string, std::string>& result, const OrthancPluginHttpRequest* request);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1402 #if HAS_ORTHANC_PLUGIN_WEBDAV == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1403 class IWebDavCollection : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1404 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1405 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1406 class FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1407 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1408 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1409 std::string name_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1410 uint64_t contentSize_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1411 std::string mime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1412 std::string dateTime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1413
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1414 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1415 FileInfo(const std::string& name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1416 uint64_t contentSize,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1417 const std::string& dateTime) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1418 name_(name),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1419 contentSize_(contentSize),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1420 dateTime_(dateTime)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1421 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1422 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1423
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1424 const std::string& GetName() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1425 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1426 return name_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1427 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1428
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1429 uint64_t GetContentSize() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1430 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1431 return contentSize_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1432 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1433
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1434 void SetMimeType(const std::string& mime)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1435 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1436 mime_ = mime;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1437 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1438
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1439 const std::string& GetMimeType() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1440 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1441 return mime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1442 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1443
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1444 const std::string& GetDateTime() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1445 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1446 return dateTime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1447 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1448 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1449
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1450 class FolderInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1451 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1452 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1453 std::string name_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1454 std::string dateTime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1455
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1456 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1457 FolderInfo(const std::string& name,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1458 const std::string& dateTime) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1459 name_(name),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1460 dateTime_(dateTime)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1461 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1462 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1463
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1464 const std::string& GetName() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1465 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1466 return name_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1467 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1468
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1469 const std::string& GetDateTime() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1470 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1471 return dateTime_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1472 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1473 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1474
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1475 virtual ~IWebDavCollection()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1476 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1477 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1478
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1479 virtual bool IsExistingFolder(const std::vector<std::string>& path) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1480
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1481 virtual bool ListFolder(std::list<FileInfo>& files,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1482 std::list<FolderInfo>& subfolders,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1483 const std::vector<std::string>& path) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1484
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1485 virtual bool GetFile(std::string& content /* out */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1486 std::string& mime /* out */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1487 std::string& dateTime /* out */,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1488 const std::vector<std::string>& path) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1489
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1490 virtual bool StoreFile(const std::vector<std::string>& path,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1491 const void* data,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1492 size_t size) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1493
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1494 virtual bool CreateFolder(const std::vector<std::string>& path) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1495
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1496 virtual bool DeleteItem(const std::vector<std::string>& path) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1497
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1498 static void Register(const std::string& uri,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1499 IWebDavCollection& collection);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1500 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
1501 #endif
491
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1502
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1503 void SetRootUri(const std::string& pluginIdentifier,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1504 const std::string& uri);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1505
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1506 void SetDescription(const std::string& pluginIdentifier,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1507 const std::string& description);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1508
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1509 void ExtendOrthancExplorer(const std::string& pluginIdentifier,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 459
diff changeset
1510 const std::string& javascript);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1511 }