Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h @ 5094:c94c1e08340e Orthanc-1.11.2
fix GetResourceType prototype
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 10 Oct 2022 10:27:09 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
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 | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3202 | 7 * |
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
3202 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * 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
|
16 * Lesser General Public License for more details. |
3202 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
3202 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #if !defined(ORTHANC_ENABLE_PUGIXML) | |
27 # error Macro ORTHANC_ENABLE_PUGIXML must be defined to use this file | |
28 #endif | |
29 | |
30 #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
|
31 #include "../Compatibility.h" // For ORTHANC_OVERRIDE |
3202 | 32 |
33 #include <json/value.h> | |
34 | |
35 | |
36 namespace Orthanc | |
37 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
38 class ORTHANC_PUBLIC DicomWebJsonVisitor : public ITagVisitor |
3202 | 39 { |
40 public: | |
41 enum BinaryMode | |
42 { | |
43 BinaryMode_Ignore, | |
44 BinaryMode_BulkDataUri, | |
45 BinaryMode_InlineBinary | |
46 }; | |
47 | |
48 class IBinaryFormatter : public boost::noncopyable | |
49 { | |
50 public: | |
51 virtual ~IBinaryFormatter() | |
52 { | |
53 } | |
54 | |
55 virtual BinaryMode Format(std::string& bulkDataUri, | |
56 const std::vector<DicomTag>& parentTags, | |
57 const std::vector<size_t>& parentIndexes, | |
58 const DicomTag& tag, | |
59 ValueRepresentation vr) = 0; | |
60 }; | |
61 | |
62 private: | |
63 Json::Value result_; | |
64 IBinaryFormatter *formatter_; | |
65 | |
66 static std::string FormatTag(const DicomTag& tag); | |
67 | |
68 Json::Value& CreateNode(const std::vector<DicomTag>& parentTags, | |
69 const std::vector<size_t>& parentIndexes, | |
70 const DicomTag& tag); | |
71 | |
72 static Json::Value FormatInteger(int64_t value); | |
73 | |
74 static Json::Value FormatDouble(double value); | |
75 | |
76 public: | |
4297 | 77 DicomWebJsonVisitor(); |
3202 | 78 |
4297 | 79 void SetFormatter(IBinaryFormatter& formatter); |
3202 | 80 |
4297 | 81 void Clear(); |
3202 | 82 |
4297 | 83 const Json::Value& GetResult() const; |
3202 | 84 |
85 #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
|
86 void FormatXml(std::string& target) const; |
3202 | 87 #endif |
88 | |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
89 virtual Action VisitNotSupported(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
90 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
91 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
92 ValueRepresentation vr) |
4297 | 93 ORTHANC_OVERRIDE; |
3202 | 94 |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
95 virtual Action VisitSequence(const std::vector<DicomTag>& parentTags, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
96 const std::vector<size_t>& parentIndexes, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
97 const DicomTag& tag, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
98 size_t countItems) |
3202 | 99 ORTHANC_OVERRIDE; |
100 | |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
101 virtual Action VisitBinary(const std::vector<DicomTag>& parentTags, |
3202 | 102 const std::vector<size_t>& parentIndexes, |
103 const DicomTag& tag, | |
104 ValueRepresentation vr, | |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
105 const void* data, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
106 size_t size) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
107 ORTHANC_OVERRIDE; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
108 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
109 virtual Action VisitIntegers(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
110 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
111 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
112 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
113 const std::vector<int64_t>& values) |
3202 | 114 ORTHANC_OVERRIDE; |
115 | |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
116 virtual Action VisitDoubles(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
117 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
118 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
119 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
120 const std::vector<double>& values) |
3202 | 121 ORTHANC_OVERRIDE; |
122 | |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
123 virtual Action VisitAttributes(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
124 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
125 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 const std::vector<DicomTag>& values) |
3202 | 127 ORTHANC_OVERRIDE; |
128 | |
129 virtual Action VisitString(std::string& newValue, | |
130 const std::vector<DicomTag>& parentTags, | |
131 const std::vector<size_t>& parentIndexes, | |
132 const DicomTag& tag, | |
133 ValueRepresentation vr, | |
134 const std::string& value) | |
135 ORTHANC_OVERRIDE; | |
136 }; | |
137 } |