Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/FindResponse.cpp @ 5589:b51ee994cd6f find-refactoring
renamed FindResponse::Item as FindResponse::Resource
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2024 17:26:06 +0200 |
parents | 1b0fc6685f57 |
children | 1e2631b8b9af |
comparison
equal
deleted
inserted
replaced
5588:1b0fc6685f57 | 5589:b51ee994cd6f |
---|---|
150 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 150 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 FindResponse::DicomTagsAtLevel& FindResponse::Item::GetDicomTagsAtLevel(ResourceType level) | 155 FindResponse::DicomTagsAtLevel& FindResponse::Resource::GetDicomTagsAtLevel(ResourceType level) |
156 { | 156 { |
157 switch (level) | 157 switch (level) |
158 { | 158 { |
159 case ResourceType_Patient: | 159 case ResourceType_Patient: |
160 return patientTags_; | 160 return patientTags_; |
172 throw OrthancException(ErrorCode_ParameterOutOfRange); | 172 throw OrthancException(ErrorCode_ParameterOutOfRange); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 | 176 |
177 FindResponse::ChildrenAtLevel& FindResponse::Item::GetChildrenAtLevel(ResourceType level) | 177 FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level) |
178 { | 178 { |
179 switch (level) | 179 switch (level) |
180 { | 180 { |
181 case ResourceType_Study: | 181 case ResourceType_Study: |
182 if (level_ == ResourceType_Patient) | 182 if (level_ == ResourceType_Patient) |
215 throw OrthancException(ErrorCode_ParameterOutOfRange); | 215 throw OrthancException(ErrorCode_ParameterOutOfRange); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 void FindResponse::Item::AddMetadata(MetadataType metadata, | 220 void FindResponse::Resource::AddMetadata(MetadataType metadata, |
221 const std::string& value) | 221 const std::string& value) |
222 { | 222 { |
223 if (metadata_.find(metadata) != metadata_.end()) | 223 if (metadata_.find(metadata) != metadata_.end()) |
224 { | 224 { |
225 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present | 225 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present |
226 } | 226 } |
229 metadata_[metadata] = value; | 229 metadata_[metadata] = value; |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 bool FindResponse::Item::LookupMetadata(std::string& value, | 234 bool FindResponse::Resource::LookupMetadata(std::string& value, |
235 MetadataType metadata) const | 235 MetadataType metadata) const |
236 { | 236 { |
237 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata); | 237 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata); |
238 | 238 |
239 if (found == metadata_.end()) | 239 if (found == metadata_.end()) |
240 { | 240 { |
246 return true; | 246 return true; |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 | 250 |
251 void FindResponse::Item::ListMetadata(std::set<MetadataType>& target) const | 251 void FindResponse::Resource::ListMetadata(std::set<MetadataType>& target) const |
252 { | 252 { |
253 target.clear(); | 253 target.clear(); |
254 | 254 |
255 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) | 255 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) |
256 { | 256 { |
257 target.insert(it->first); | 257 target.insert(it->first); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 const std::string& FindResponse::Item::GetParentIdentifier() const | 261 const std::string& FindResponse::Resource::GetParentIdentifier() const |
262 { | 262 { |
263 if (level_ == ResourceType_Patient) | 263 if (level_ == ResourceType_Patient) |
264 { | 264 { |
265 throw OrthancException(ErrorCode_BadParameterType); | 265 throw OrthancException(ErrorCode_BadParameterType); |
266 } | 266 } |
273 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 273 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 | 277 |
278 void FindResponse::Item::SetParentIdentifier(const std::string& id) | 278 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |
279 { | 279 { |
280 if (level_ == ResourceType_Patient) | 280 if (level_ == ResourceType_Patient) |
281 { | 281 { |
282 throw OrthancException(ErrorCode_BadParameterType); | 282 throw OrthancException(ErrorCode_BadParameterType); |
283 } | 283 } |
290 parentIdentifier_.reset(new std::string(id)); | 290 parentIdentifier_.reset(new std::string(id)); |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 bool FindResponse::Item::HasParentIdentifier() const | 295 bool FindResponse::Resource::HasParentIdentifier() const |
296 { | 296 { |
297 if (level_ == ResourceType_Patient) | 297 if (level_ == ResourceType_Patient) |
298 { | 298 { |
299 throw OrthancException(ErrorCode_BadParameterType); | 299 throw OrthancException(ErrorCode_BadParameterType); |
300 } | 300 } |
303 return parentIdentifier_.get() != NULL; | 303 return parentIdentifier_.get() != NULL; |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 void FindResponse::Item::AddLabel(const std::string& label) | 308 void FindResponse::Resource::AddLabel(const std::string& label) |
309 { | 309 { |
310 if (labels_.find(label) == labels_.end()) | 310 if (labels_.find(label) == labels_.end()) |
311 { | 311 { |
312 labels_.insert(label); | 312 labels_.insert(label); |
313 } | 313 } |
316 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 316 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 void FindResponse::Item::AddAttachment(const FileInfo& attachment) | 321 void FindResponse::Resource::AddAttachment(const FileInfo& attachment) |
322 { | 322 { |
323 if (attachments_.find(attachment.GetContentType()) == attachments_.end()) | 323 if (attachments_.find(attachment.GetContentType()) == attachments_.end()) |
324 { | 324 { |
325 attachments_[attachment.GetContentType()] = attachment; | 325 attachments_[attachment.GetContentType()] = attachment; |
326 } | 326 } |
329 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 329 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 | 333 |
334 bool FindResponse::Item::LookupAttachment(FileInfo& target, FileContentType type) const | 334 bool FindResponse::Resource::LookupAttachment(FileInfo& target, FileContentType type) const |
335 { | 335 { |
336 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); | 336 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); |
337 if (it != attachments_.end()) | 337 if (it != attachments_.end()) |
338 { | 338 { |
339 target = it->second; | 339 target = it->second; |
354 delete items_[i]; | 354 delete items_[i]; |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 | 358 |
359 void FindResponse::Add(Item* item /* takes ownership */) | 359 void FindResponse::Add(Resource* item /* takes ownership */) |
360 { | 360 { |
361 std::unique_ptr<Item> protection(item); | 361 std::unique_ptr<Resource> protection(item); |
362 | 362 |
363 if (item == NULL) | 363 if (item == NULL) |
364 { | 364 { |
365 throw OrthancException(ErrorCode_NullPointer); | 365 throw OrthancException(ErrorCode_NullPointer); |
366 } | 366 } |
384 } | 384 } |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 | 388 |
389 const FindResponse::Item& FindResponse::GetItem(size_t index) const | 389 const FindResponse::Resource& FindResponse::GetResource(size_t index) const |
390 { | 390 { |
391 if (index >= items_.size()) | 391 if (index >= items_.size()) |
392 { | 392 { |
393 throw OrthancException(ErrorCode_ParameterOutOfRange); | 393 throw OrthancException(ErrorCode_ParameterOutOfRange); |
394 } | 394 } |
398 return *items_[index]; | 398 return *items_[index]; |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 | 402 |
403 FindResponse::Item& FindResponse::GetItem(const std::string& id) | 403 FindResponse::Resource& FindResponse::GetResource(const std::string& id) |
404 { | 404 { |
405 Index::const_iterator found = index_.find(id); | 405 Index::const_iterator found = index_.find(id); |
406 | 406 |
407 if (found == index_.end()) | 407 if (found == index_.end()) |
408 { | 408 { |