diff OrthancServer/Search/Compatibility/DatabaseLookup.cpp @ 3075:ead8576a02ef db-changes

IDatabaseWrapper::ApplyLookupResources now returns lists
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Jan 2019 18:39:25 +0100
parents 5ebd2ef5e7ae
children 195ba4cbac3f
line wrap: on
line diff
--- a/OrthancServer/Search/Compatibility/DatabaseLookup.cpp	Wed Jan 02 15:50:44 2019 +0100
+++ b/OrthancServer/Search/Compatibility/DatabaseLookup.cpp	Wed Jan 02 18:39:25 2019 +0100
@@ -312,8 +312,8 @@
     }
                            
 
-    void DatabaseLookup::ApplyLookupResources(std::vector<std::string>& resourcesId,
-                                              std::vector<std::string>* instancesId,
+    void DatabaseLookup::ApplyLookupResources(std::list<std::string>& resourcesId,
+                                              std::list<std::string>* instancesId,
                                               const std::vector<DatabaseConstraint>& lookup,
                                               ResourceType queryLevel,
                                               size_t limit)
@@ -389,13 +389,6 @@
 
       // Get the public ID of all the selected resources
 
-      resourcesId.resize(resources.size());
-
-      if (instancesId != NULL)
-      {
-        instancesId->resize(resources.size());
-      }
-
       size_t pos = 0;
 
       for (std::list<int64_t>::const_iterator
@@ -403,18 +396,20 @@
       {
         assert(database_.GetResourceType(*it) == queryLevel);
 
-        resourcesId[pos] = database_.GetPublicId(*it);
+        const std::string resource = database_.GetPublicId(*it);
+        resourcesId.push_back(resource);
 
         if (instancesId != NULL)
         {
-          // Collect one child instance for each of the selected resources
           if (queryLevel == ResourceType_Instance)
           {
-            (*instancesId) [pos] = resourcesId[pos];
+            // The resource is itself the instance
+            instancesId->push_back(resource);
           }
           else
           {
-            (*instancesId) [pos] = GetOneInstance(database_, *it, queryLevel);
+            // Collect one child instance for each of the selected resources
+            instancesId->push_back(GetOneInstance(database_, *it, queryLevel));
           }
         }
       }