Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h @ 4202:2007ab69ac16
moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 08:35:11 +0200 |
parents | bf7b9edf6b81 |
children | 785a2713323e |
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 | |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
5 * Copyright (C) 2017-2020 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: | |
76 DicomWebJsonVisitor() : | |
77 formatter_(NULL) | |
78 { | |
79 Clear(); | |
80 } | |
81 | |
82 void SetFormatter(IBinaryFormatter& formatter) | |
83 { | |
84 formatter_ = &formatter; | |
85 } | |
86 | |
87 void Clear() | |
88 { | |
89 result_ = Json::objectValue; | |
90 } | |
91 | |
92 const Json::Value& GetResult() const | |
93 { | |
94 return result_; | |
95 } | |
96 | |
97 #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
|
98 void FormatXml(std::string& target) const; |
3202 | 99 #endif |
100 | |
101 virtual void VisitNotSupported(const std::vector<DicomTag>& parentTags, | |
102 const std::vector<size_t>& parentIndexes, | |
103 const DicomTag& tag, | |
104 ValueRepresentation vr) | |
105 ORTHANC_OVERRIDE | |
106 { | |
107 } | |
108 | |
109 virtual void VisitEmptySequence(const std::vector<DicomTag>& parentTags, | |
110 const std::vector<size_t>& parentIndexes, | |
111 const DicomTag& tag) | |
112 ORTHANC_OVERRIDE; | |
113 | |
114 virtual void VisitBinary(const std::vector<DicomTag>& parentTags, | |
115 const std::vector<size_t>& parentIndexes, | |
116 const DicomTag& tag, | |
117 ValueRepresentation vr, | |
118 const void* data, | |
119 size_t size) | |
120 ORTHANC_OVERRIDE; | |
121 | |
122 virtual void VisitIntegers(const std::vector<DicomTag>& parentTags, | |
123 const std::vector<size_t>& parentIndexes, | |
124 const DicomTag& tag, | |
125 ValueRepresentation vr, | |
126 const std::vector<int64_t>& values) | |
127 ORTHANC_OVERRIDE; | |
128 | |
129 virtual void VisitDoubles(const std::vector<DicomTag>& parentTags, | |
130 const std::vector<size_t>& parentIndexes, | |
131 const DicomTag& tag, | |
132 ValueRepresentation vr, | |
133 const std::vector<double>& values) | |
134 ORTHANC_OVERRIDE; | |
135 | |
136 virtual void VisitAttributes(const std::vector<DicomTag>& parentTags, | |
137 const std::vector<size_t>& parentIndexes, | |
138 const DicomTag& tag, | |
139 const std::vector<DicomTag>& values) | |
140 ORTHANC_OVERRIDE; | |
141 | |
142 virtual Action VisitString(std::string& newValue, | |
143 const std::vector<DicomTag>& parentTags, | |
144 const std::vector<size_t>& parentIndexes, | |
145 const DicomTag& tag, | |
146 ValueRepresentation vr, | |
147 const std::string& value) | |
148 ORTHANC_OVERRIDE; | |
149 }; | |
150 } |