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