Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h @ 4681:c5528c7847a6
new class DicomPath
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Jun 2021 17:05:48 +0200 |
parents | d9473bd5ed43 |
children | b51c08bd5c38 |
rev | line source |
---|---|
3202 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
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 | 6 * |
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 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
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 | 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 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #if !defined(ORTHANC_ENABLE_PUGIXML) | |
26 # error Macro ORTHANC_ENABLE_PUGIXML must be defined to use this file | |
27 #endif | |
28 | |
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 | 31 |
32 #include <json/value.h> | |
33 | |
34 | |
35 namespace Orthanc | |
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 | 38 { |
39 public: | |
40 enum BinaryMode | |
41 { | |
42 BinaryMode_Ignore, | |
43 BinaryMode_BulkDataUri, | |
44 BinaryMode_InlineBinary | |
45 }; | |
46 | |
47 class IBinaryFormatter : public boost::noncopyable | |
48 { | |
49 public: | |
50 virtual ~IBinaryFormatter() | |
51 { | |
52 } | |
53 | |
54 virtual BinaryMode Format(std::string& bulkDataUri, | |
55 const std::vector<DicomTag>& parentTags, | |
56 const std::vector<size_t>& parentIndexes, | |
57 const DicomTag& tag, | |
58 ValueRepresentation vr) = 0; | |
59 }; | |
60 | |
61 private: | |
62 Json::Value result_; | |
63 IBinaryFormatter *formatter_; | |
64 | |
65 static std::string FormatTag(const DicomTag& tag); | |
66 | |
67 Json::Value& CreateNode(const std::vector<DicomTag>& parentTags, | |
68 const std::vector<size_t>& parentIndexes, | |
69 const DicomTag& tag); | |
70 | |
71 static Json::Value FormatInteger(int64_t value); | |
72 | |
73 static Json::Value FormatDouble(double value); | |
74 | |
75 public: | |
4297 | 76 DicomWebJsonVisitor(); |
3202 | 77 |
4297 | 78 void SetFormatter(IBinaryFormatter& formatter); |
3202 | 79 |
4297 | 80 void Clear(); |
3202 | 81 |
4297 | 82 const Json::Value& GetResult() const; |
3202 | 83 |
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 | 86 #endif |
87 | |
88 virtual void VisitNotSupported(const std::vector<DicomTag>& parentTags, | |
89 const std::vector<size_t>& parentIndexes, | |
90 const DicomTag& tag, | |
91 ValueRepresentation vr) | |
4297 | 92 ORTHANC_OVERRIDE; |
3202 | 93 |
94 virtual void VisitEmptySequence(const std::vector<DicomTag>& parentTags, | |
95 const std::vector<size_t>& parentIndexes, | |
96 const DicomTag& tag) | |
97 ORTHANC_OVERRIDE; | |
98 | |
99 virtual void VisitBinary(const std::vector<DicomTag>& parentTags, | |
100 const std::vector<size_t>& parentIndexes, | |
101 const DicomTag& tag, | |
102 ValueRepresentation vr, | |
103 const void* data, | |
104 size_t size) | |
105 ORTHANC_OVERRIDE; | |
106 | |
107 virtual void VisitIntegers(const std::vector<DicomTag>& parentTags, | |
108 const std::vector<size_t>& parentIndexes, | |
109 const DicomTag& tag, | |
110 ValueRepresentation vr, | |
111 const std::vector<int64_t>& values) | |
112 ORTHANC_OVERRIDE; | |
113 | |
114 virtual void VisitDoubles(const std::vector<DicomTag>& parentTags, | |
115 const std::vector<size_t>& parentIndexes, | |
116 const DicomTag& tag, | |
117 ValueRepresentation vr, | |
118 const std::vector<double>& values) | |
119 ORTHANC_OVERRIDE; | |
120 | |
121 virtual void VisitAttributes(const std::vector<DicomTag>& parentTags, | |
122 const std::vector<size_t>& parentIndexes, | |
123 const DicomTag& tag, | |
124 const std::vector<DicomTag>& values) | |
125 ORTHANC_OVERRIDE; | |
126 | |
127 virtual Action VisitString(std::string& newValue, | |
128 const std::vector<DicomTag>& parentTags, | |
129 const std::vector<size_t>& parentIndexes, | |
130 const DicomTag& tag, | |
131 ValueRepresentation vr, | |
132 const std::string& value) | |
133 ORTHANC_OVERRIDE; | |
134 }; | |
135 } |