comparison OrthancServer/Sources/Database/FindResponse.cpp @ 5588:1b0fc6685f57 find-refactoring

add index of resources into FindResponse
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 May 2024 17:20:27 +0200
parents fc3914c07dd3
children b51ee994cd6f
comparison
equal deleted inserted replaced
5587:0f5586c498d1 5588:1b0fc6685f57
362 362
363 if (item == NULL) 363 if (item == NULL)
364 { 364 {
365 throw OrthancException(ErrorCode_NullPointer); 365 throw OrthancException(ErrorCode_NullPointer);
366 } 366 }
367 else if (!items_.empty() &&
368 items_[0]->GetLevel() != item->GetLevel())
369 {
370 throw OrthancException(ErrorCode_BadParameterType, "A find response must only contain resources of the same type");
371 }
367 else 372 else
368 { 373 {
369 const std::string& id = item->GetIdentifier(); 374 const std::string& id = item->GetIdentifier();
370 375
371 if (index_.find(id) == index_.end()) 376 if (index_.find(id) == index_.end())
393 return *items_[index]; 398 return *items_[index];
394 } 399 }
395 } 400 }
396 401
397 402
398 const FindResponse::Item* FindResponse::LookupItem(const std::string& id) const 403 FindResponse::Item& FindResponse::GetItem(const std::string& id)
399 { 404 {
400 Index::const_iterator found = index_.find(id); 405 Index::const_iterator found = index_.find(id);
401 406
402 if (found == index_.end()) 407 if (found == index_.end())
403 { 408 {
404 return NULL; 409 throw OrthancException(ErrorCode_InexistentItem);
405 } 410 }
406 else 411 else
407 { 412 {
408 assert(found->second != NULL); 413 assert(found->second != NULL);
409 return found->second; 414 return *found->second;
410 } 415 }
411 } 416 }
412 } 417 }