annotate OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h @ 4731:283d246fafdb

fix broken "Do lookup" button in Orthanc Explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 27 Jun 2021 12:48:26 +0200
parents d9473bd5ed43
children b51c08bd5c38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
10 * the License, or (at your option) any later version.
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
15 * Lesser General Public License for more details.
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
18 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
19 * <http://www.gnu.org/licenses/>.
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #if !defined(ORTHANC_ENABLE_PUGIXML)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 # error Macro ORTHANC_ENABLE_PUGIXML must be defined to use this file
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #endif
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "ITagVisitor.h"
4202
2007ab69ac16 moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
30 #include "../Compatibility.h" // For ORTHANC_OVERRIDE
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <json/value.h>
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 class ORTHANC_PUBLIC DicomWebJsonVisitor : public ITagVisitor
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 public:
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 enum BinaryMode
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 BinaryMode_Ignore,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 BinaryMode_BulkDataUri,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 BinaryMode_InlineBinary
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 };
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 class IBinaryFormatter : public boost::noncopyable
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 virtual ~IBinaryFormatter()
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 virtual BinaryMode Format(std::string& bulkDataUri,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ValueRepresentation vr) = 0;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 };
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 private:
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 Json::Value result_;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 IBinaryFormatter *formatter_;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 static std::string FormatTag(const DicomTag& tag);
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Json::Value& CreateNode(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 const DicomTag& tag);
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 static Json::Value FormatInteger(int64_t value);
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 static Json::Value FormatDouble(double value);
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 public:
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
76 DicomWebJsonVisitor();
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
78 void SetFormatter(IBinaryFormatter& formatter);
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
80 void Clear();
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
82 const Json::Value& GetResult() const;
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 #if ORTHANC_ENABLE_PUGIXML == 1
3203
810772486249 URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3202
diff changeset
85 void FormatXml(std::string& target) const;
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 #endif
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 virtual void VisitNotSupported(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 ValueRepresentation vr)
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
92 ORTHANC_OVERRIDE;
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 virtual void VisitEmptySequence(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 const DicomTag& tag)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 virtual void VisitBinary(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 ValueRepresentation vr,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 const void* data,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 size_t size)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 virtual void VisitIntegers(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 ValueRepresentation vr,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 const std::vector<int64_t>& values)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 virtual void VisitDoubles(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 ValueRepresentation vr,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 const std::vector<double>& values)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 virtual void VisitAttributes(const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 const std::vector<DicomTag>& values)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 virtual Action VisitString(std::string& newValue,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 const std::vector<DicomTag>& parentTags,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 const std::vector<size_t>& parentIndexes,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 const DicomTag& tag,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 ValueRepresentation vr,
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 const std::string& value)
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 ORTHANC_OVERRIDE;
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 };
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }