diff OrthancServer/Sources/Database/FindResponse.cpp @ 5592:1e2631b8b9af find-refactoring

GenericFind::Execute() is working for a basic request
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 May 2024 21:26:06 +0200
parents b51ee994cd6f
children a906dc19264c
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Fri May 03 18:30:29 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Fri May 03 21:26:06 2024 +0200
@@ -30,7 +30,7 @@
 
 namespace Orthanc
 {
-  class FindResponse::DicomTagsAtLevel::DicomValue : public boost::noncopyable
+  class FindResponse::Resource::DicomValue : public boost::noncopyable
   {
   public:
     enum ValueType
@@ -73,24 +73,14 @@
   };
 
 
-  FindResponse::DicomTagsAtLevel::~DicomTagsAtLevel()
-  {
-    for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
-    {
-      assert(it->second != NULL);
-      delete it->second;
-    }
-  }
-
-
-  void FindResponse::DicomTagsAtLevel::AddNullValue(uint16_t group,
-                                                    uint16_t element)
+  void FindResponse::Resource::AddNullDicomTag(uint16_t group,
+                                               uint16_t element)
   {
     const DicomTag tag(group, element);
 
-    if (content_.find(tag) == content_.end())
+    if (mainDicomTags_.find(tag) == mainDicomTags_.end())
     {
-      content_[tag] = new DicomValue(DicomValue::ValueType_Null, "");
+      mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, "");
     }
     else
     {
@@ -99,15 +89,15 @@
   }
 
 
-  void FindResponse::DicomTagsAtLevel::AddStringValue(uint16_t group,
-                                                      uint16_t element,
-                                                      const std::string& value)
+  void FindResponse::Resource::AddStringDicomTag(uint16_t group,
+                                                 uint16_t element,
+                                                 const std::string& value)
   {
     const DicomTag tag(group, element);
 
-    if (content_.find(tag) == content_.end())
+    if (mainDicomTags_.find(tag) == mainDicomTags_.end())
     {
-      content_[tag] = new DicomValue(DicomValue::ValueType_String, value);
+      mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value);
     }
     else
     {
@@ -116,9 +106,9 @@
   }
 
 
-  void FindResponse::DicomTagsAtLevel::Fill(DicomMap& target) const
+  void FindResponse::Resource::GetMainDicomTags(DicomMap& target) const
   {
-    for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
+    for (MainDicomTags::const_iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it)
     {
       assert(it->second != NULL);
 
@@ -152,28 +142,6 @@
   }
 
 
-  FindResponse::DicomTagsAtLevel& FindResponse::Resource::GetDicomTagsAtLevel(ResourceType level)
-  {
-    switch (level)
-    {
-      case ResourceType_Patient:
-        return patientTags_;
-
-      case ResourceType_Study:
-        return studyTags_;
-
-      case ResourceType_Series:
-        return seriesTags_;
-
-      case ResourceType_Instance:
-        return instanceTags_;
-
-      default:
-        throw OrthancException(ErrorCode_ParameterOutOfRange);
-    }
-  }
-
-
   FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level)
   {
     switch (level)
@@ -275,6 +243,16 @@
   }
 
 
+  FindResponse::Resource::~Resource()
+  {
+    for (MainDicomTags::iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it)
+    {
+      assert(it->second != NULL);
+      delete it->second;
+    }
+  }
+
+
   void FindResponse::Resource::SetParentIdentifier(const std::string& id)
   {
     if (level_ == ResourceType_Patient)