diff 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
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Fri May 03 17:06:42 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Fri May 03 17:20:27 2024 +0200
@@ -364,6 +364,11 @@
     {
       throw OrthancException(ErrorCode_NullPointer);
     }
+    else if (!items_.empty() &&
+             items_[0]->GetLevel() != item->GetLevel())
+    {
+      throw OrthancException(ErrorCode_BadParameterType, "A find response must only contain resources of the same type");
+    }
     else
     {
       const std::string& id = item->GetIdentifier();
@@ -395,18 +400,18 @@
   }
 
 
-  const FindResponse::Item* FindResponse::LookupItem(const std::string& id) const
+  FindResponse::Item& FindResponse::GetItem(const std::string& id)
   {
     Index::const_iterator found = index_.find(id);
 
     if (found == index_.end())
     {
-      return NULL;
+      throw OrthancException(ErrorCode_InexistentItem);
     }
     else
     {
       assert(found->second != NULL);
-      return found->second;
+      return *found->second;
     }
   }
 }