Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h @ 4145:c5cdb6dc6865
New config option "Worklist.LimitAnswers" for the sample modality worklist plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 Aug 2020 14:48:11 +0200 |
parents | bf7b9edf6b81 |
children | 2007ab69ac16 |
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" | |
30 | |
31 #include <json/value.h> | |
32 | |
33 | |
34 namespace Orthanc | |
35 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
36 class ORTHANC_PUBLIC DicomWebJsonVisitor : public ITagVisitor |
3202 | 37 { |
38 public: | |
39 enum BinaryMode | |
40 { | |
41 BinaryMode_Ignore, | |
42 BinaryMode_BulkDataUri, | |
43 BinaryMode_InlineBinary | |
44 }; | |
45 | |
46 class IBinaryFormatter : public boost::noncopyable | |
47 { | |
48 public: | |
49 virtual ~IBinaryFormatter() | |
50 { | |
51 } | |
52 | |
53 virtual BinaryMode Format(std::string& bulkDataUri, | |
54 const std::vector<DicomTag>& parentTags, | |
55 const std::vector<size_t>& parentIndexes, | |
56 const DicomTag& tag, | |
57 ValueRepresentation vr) = 0; | |
58 }; | |
59 | |
60 private: | |
61 Json::Value result_; | |
62 IBinaryFormatter *formatter_; | |
63 | |
64 static std::string FormatTag(const DicomTag& tag); | |
65 | |
66 Json::Value& CreateNode(const std::vector<DicomTag>& parentTags, | |
67 const std::vector<size_t>& parentIndexes, | |
68 const DicomTag& tag); | |
69 | |
70 static Json::Value FormatInteger(int64_t value); | |
71 | |
72 static Json::Value FormatDouble(double value); | |
73 | |
74 public: | |
75 DicomWebJsonVisitor() : | |
76 formatter_(NULL) | |
77 { | |
78 Clear(); | |
79 } | |
80 | |
81 void SetFormatter(IBinaryFormatter& formatter) | |
82 { | |
83 formatter_ = &formatter; | |
84 } | |
85 | |
86 void Clear() | |
87 { | |
88 result_ = Json::objectValue; | |
89 } | |
90 | |
91 const Json::Value& GetResult() const | |
92 { | |
93 return result_; | |
94 } | |
95 | |
96 #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
|
97 void FormatXml(std::string& target) const; |
3202 | 98 #endif |
99 | |
100 virtual void VisitNotSupported(const std::vector<DicomTag>& parentTags, | |
101 const std::vector<size_t>& parentIndexes, | |
102 const DicomTag& tag, | |
103 ValueRepresentation vr) | |
104 ORTHANC_OVERRIDE | |
105 { | |
106 } | |
107 | |
108 virtual void VisitEmptySequence(const std::vector<DicomTag>& parentTags, | |
109 const std::vector<size_t>& parentIndexes, | |
110 const DicomTag& tag) | |
111 ORTHANC_OVERRIDE; | |
112 | |
113 virtual void VisitBinary(const std::vector<DicomTag>& parentTags, | |
114 const std::vector<size_t>& parentIndexes, | |
115 const DicomTag& tag, | |
116 ValueRepresentation vr, | |
117 const void* data, | |
118 size_t size) | |
119 ORTHANC_OVERRIDE; | |
120 | |
121 virtual void VisitIntegers(const std::vector<DicomTag>& parentTags, | |
122 const std::vector<size_t>& parentIndexes, | |
123 const DicomTag& tag, | |
124 ValueRepresentation vr, | |
125 const std::vector<int64_t>& values) | |
126 ORTHANC_OVERRIDE; | |
127 | |
128 virtual void VisitDoubles(const std::vector<DicomTag>& parentTags, | |
129 const std::vector<size_t>& parentIndexes, | |
130 const DicomTag& tag, | |
131 ValueRepresentation vr, | |
132 const std::vector<double>& values) | |
133 ORTHANC_OVERRIDE; | |
134 | |
135 virtual void VisitAttributes(const std::vector<DicomTag>& parentTags, | |
136 const std::vector<size_t>& parentIndexes, | |
137 const DicomTag& tag, | |
138 const std::vector<DicomTag>& values) | |
139 ORTHANC_OVERRIDE; | |
140 | |
141 virtual Action VisitString(std::string& newValue, | |
142 const std::vector<DicomTag>& parentTags, | |
143 const std::vector<size_t>& parentIndexes, | |
144 const DicomTag& tag, | |
145 ValueRepresentation vr, | |
146 const std::string& value) | |
147 ORTHANC_OVERRIDE; | |
148 }; | |
149 } |