Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/FindResponse.cpp @ 5592:1e2631b8b9af find-refactoring
GenericFind::Execute() is working for a basic request
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2024 21:26:06 +0200 |
parents | b51ee994cd6f |
children | a906dc19264c |
comparison
equal
deleted
inserted
replaced
5591:043c8016ed6a | 5592:1e2631b8b9af |
---|---|
28 #include <cassert> | 28 #include <cassert> |
29 | 29 |
30 | 30 |
31 namespace Orthanc | 31 namespace Orthanc |
32 { | 32 { |
33 class FindResponse::DicomTagsAtLevel::DicomValue : public boost::noncopyable | 33 class FindResponse::Resource::DicomValue : public boost::noncopyable |
34 { | 34 { |
35 public: | 35 public: |
36 enum ValueType | 36 enum ValueType |
37 { | 37 { |
38 ValueType_String, | 38 ValueType_String, |
71 } | 71 } |
72 } | 72 } |
73 }; | 73 }; |
74 | 74 |
75 | 75 |
76 FindResponse::DicomTagsAtLevel::~DicomTagsAtLevel() | 76 void FindResponse::Resource::AddNullDicomTag(uint16_t group, |
77 { | 77 uint16_t element) |
78 for (Content::iterator it = content_.begin(); it != content_.end(); ++it) | |
79 { | |
80 assert(it->second != NULL); | |
81 delete it->second; | |
82 } | |
83 } | |
84 | |
85 | |
86 void FindResponse::DicomTagsAtLevel::AddNullValue(uint16_t group, | |
87 uint16_t element) | |
88 { | 78 { |
89 const DicomTag tag(group, element); | 79 const DicomTag tag(group, element); |
90 | 80 |
91 if (content_.find(tag) == content_.end()) | 81 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
92 { | 82 { |
93 content_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); | 83 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); |
94 } | 84 } |
95 else | 85 else |
96 { | 86 { |
97 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 87 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
98 } | 88 } |
99 } | 89 } |
100 | 90 |
101 | 91 |
102 void FindResponse::DicomTagsAtLevel::AddStringValue(uint16_t group, | 92 void FindResponse::Resource::AddStringDicomTag(uint16_t group, |
103 uint16_t element, | 93 uint16_t element, |
104 const std::string& value) | 94 const std::string& value) |
105 { | 95 { |
106 const DicomTag tag(group, element); | 96 const DicomTag tag(group, element); |
107 | 97 |
108 if (content_.find(tag) == content_.end()) | 98 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
109 { | 99 { |
110 content_[tag] = new DicomValue(DicomValue::ValueType_String, value); | 100 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value); |
111 } | 101 } |
112 else | 102 else |
113 { | 103 { |
114 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 104 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
115 } | 105 } |
116 } | 106 } |
117 | 107 |
118 | 108 |
119 void FindResponse::DicomTagsAtLevel::Fill(DicomMap& target) const | 109 void FindResponse::Resource::GetMainDicomTags(DicomMap& target) const |
120 { | 110 { |
121 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it) | 111 for (MainDicomTags::const_iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
122 { | 112 { |
123 assert(it->second != NULL); | 113 assert(it->second != NULL); |
124 | 114 |
125 switch (it->second->GetType()) | 115 switch (it->second->GetType()) |
126 { | 116 { |
150 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 140 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
151 } | 141 } |
152 } | 142 } |
153 | 143 |
154 | 144 |
155 FindResponse::DicomTagsAtLevel& FindResponse::Resource::GetDicomTagsAtLevel(ResourceType level) | |
156 { | |
157 switch (level) | |
158 { | |
159 case ResourceType_Patient: | |
160 return patientTags_; | |
161 | |
162 case ResourceType_Study: | |
163 return studyTags_; | |
164 | |
165 case ResourceType_Series: | |
166 return seriesTags_; | |
167 | |
168 case ResourceType_Instance: | |
169 return instanceTags_; | |
170 | |
171 default: | |
172 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
173 } | |
174 } | |
175 | |
176 | |
177 FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level) | 145 FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level) |
178 { | 146 { |
179 switch (level) | 147 switch (level) |
180 { | 148 { |
181 case ResourceType_Study: | 149 case ResourceType_Study: |
269 return *parentIdentifier_; | 237 return *parentIdentifier_; |
270 } | 238 } |
271 else | 239 else |
272 { | 240 { |
273 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 241 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
242 } | |
243 } | |
244 | |
245 | |
246 FindResponse::Resource::~Resource() | |
247 { | |
248 for (MainDicomTags::iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) | |
249 { | |
250 assert(it->second != NULL); | |
251 delete it->second; | |
274 } | 252 } |
275 } | 253 } |
276 | 254 |
277 | 255 |
278 void FindResponse::Resource::SetParentIdentifier(const std::string& id) | 256 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |