diff OrthancServer/ServerIndex.cpp @ 714:6a1dbba0cca7

new implementation of C-Find handler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Feb 2014 11:26:12 +0100
parents 4789da60d655
children 696dbb4fd390
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp	Fri Feb 14 09:21:23 2014 +0100
+++ b/OrthancServer/ServerIndex.cpp	Fri Feb 14 11:26:12 2014 +0100
@@ -1107,6 +1107,37 @@
   }
 
 
+  void ServerIndex::GetChildren(std::list<std::string>& result,
+                                const std::string& publicId)
+  {
+    result.clear();
+
+    boost::mutex::scoped_lock lock(mutex_);
+
+    ResourceType type;
+    int64_t resource;
+    if (!db_->LookupResource(publicId, resource, type))
+    {
+      throw OrthancException(ErrorCode_UnknownResource);
+    }
+
+    if (type == ResourceType_Instance)
+    {
+      // An instance cannot have a child
+      throw OrthancException(ErrorCode_BadParameterType);
+    }
+
+    std::list<int64_t> tmp;
+    db_->GetChildrenInternalId(tmp, resource);
+
+    for (std::list<int64_t>::const_iterator 
+           it = tmp.begin(); it != tmp.end(); ++it)
+    {
+      result.push_back(db_->GetPublicId(*it));
+    }
+  }
+
+
   void ServerIndex::GetChildInstances(std::list<std::string>& result,
                                       const std::string& publicId)
   {