changeset 5769:0da33161acf7 find-refactoring

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 16:37:52 +0200
parents 23b5a090a64b
children e2771185dad6
files OrthancServer/Plugins/Engine/PluginsEnumerations.cpp OrthancServer/Plugins/Engine/PluginsEnumerations.h OrthancServer/Sources/Search/DatabaseConstraint.cpp OrthancServer/Sources/Search/DatabaseConstraint.h OrthancServer/Sources/ServerEnumerations.h
diffstat 5 files changed, 91 insertions(+), 168 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/PluginsEnumerations.cpp	Mon Sep 09 16:20:44 2024 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsEnumerations.cpp	Mon Sep 09 16:37:52 2024 +0200
@@ -598,5 +598,74 @@
           throw OrthancException(ErrorCode_ParameterOutOfRange);
       }
     }
+
+
+    OrthancPluginResourceType Convert(ResourceType type)
+    {
+      switch (type)
+      {
+        case ResourceType_Patient:
+          return OrthancPluginResourceType_Patient;
+
+        case ResourceType_Study:
+          return OrthancPluginResourceType_Study;
+
+        case ResourceType_Series:
+          return OrthancPluginResourceType_Series;
+
+        case ResourceType_Instance:
+          return OrthancPluginResourceType_Instance;
+
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+
+
+    ResourceType Convert(OrthancPluginResourceType type)
+    {
+      switch (type)
+      {
+        case OrthancPluginResourceType_Patient:
+          return ResourceType_Patient;
+
+        case OrthancPluginResourceType_Study:
+          return ResourceType_Study;
+
+        case OrthancPluginResourceType_Series:
+          return ResourceType_Series;
+
+        case OrthancPluginResourceType_Instance:
+          return ResourceType_Instance;
+
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+
+
+    OrthancPluginConstraintType Convert(ConstraintType constraint)
+    {
+      switch (constraint)
+      {
+        case ConstraintType_Equal:
+          return OrthancPluginConstraintType_Equal;
+
+        case ConstraintType_GreaterOrEqual:
+          return OrthancPluginConstraintType_GreaterOrEqual;
+
+        case ConstraintType_SmallerOrEqual:
+          return OrthancPluginConstraintType_SmallerOrEqual;
+
+        case ConstraintType_Wildcard:
+          return OrthancPluginConstraintType_Wildcard;
+
+        case ConstraintType_List:
+          return OrthancPluginConstraintType_List;
+
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
   }
 }
--- a/OrthancServer/Plugins/Engine/PluginsEnumerations.h	Mon Sep 09 16:20:44 2024 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsEnumerations.h	Mon Sep 09 16:37:52 2024 +0200
@@ -25,15 +25,7 @@
 
 #if ORTHANC_ENABLE_PLUGINS == 1
 
-/**
- * NB: Conversions to/from "OrthancPluginConstraintType" and
- * "OrthancPluginResourceType" are located in file
- * "../../Sources/Search/DatabaseConstraint.h" to be shared with the
- * "orthanc-databases" project.
- **/
-
 #include "../../../OrthancFramework/Sources/MetricsRegistry.h"
-#include "../../Sources/Search/DatabaseConstraint.h"
 #include "../../Sources/ServerEnumerations.h"
 #include "../Include/orthanc/OrthancCPlugin.h"
 
@@ -75,6 +67,12 @@
     StorageCommitmentFailureReason Convert(OrthancPluginStorageCommitmentFailureReason reason);
 
     MetricsUpdatePolicy Convert(OrthancPluginMetricsType type);
+
+    OrthancPluginResourceType Convert(ResourceType type);
+
+    ResourceType Convert(OrthancPluginResourceType type);
+
+    OrthancPluginConstraintType Convert(ConstraintType constraint);
   }
 }
 
--- a/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Mon Sep 09 16:20:44 2024 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Mon Sep 09 16:37:52 2024 +0200
@@ -26,116 +26,16 @@
 
 #include "../../../OrthancFramework/Sources/OrthancException.h"
 
+#if ORTHANC_ENABLE_PLUGINS == 1
+#  include "../../Plugins/Engine/PluginsEnumerations.h"
+#endif
+
 #include <boost/lexical_cast.hpp>
 #include <cassert>
 
 
 namespace Orthanc
 {
-  namespace Plugins
-  {
-#if ORTHANC_ENABLE_PLUGINS == 1
-    OrthancPluginResourceType Convert(ResourceType type)
-    {
-      switch (type)
-      {
-        case ResourceType_Patient:
-          return OrthancPluginResourceType_Patient;
-
-        case ResourceType_Study:
-          return OrthancPluginResourceType_Study;
-
-        case ResourceType_Series:
-          return OrthancPluginResourceType_Series;
-
-        case ResourceType_Instance:
-          return OrthancPluginResourceType_Instance;
-
-        default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
-      }
-    }
-#endif
-
-
-#if ORTHANC_ENABLE_PLUGINS == 1
-    ResourceType Convert(OrthancPluginResourceType type)
-    {
-      switch (type)
-      {
-        case OrthancPluginResourceType_Patient:
-          return ResourceType_Patient;
-
-        case OrthancPluginResourceType_Study:
-          return ResourceType_Study;
-
-        case OrthancPluginResourceType_Series:
-          return ResourceType_Series;
-
-        case OrthancPluginResourceType_Instance:
-          return ResourceType_Instance;
-
-        default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
-      }
-    }
-#endif
-
-
-#if ORTHANC_ENABLE_PLUGINS == 1
-    OrthancPluginConstraintType Convert(ConstraintType constraint)
-    {
-      switch (constraint)
-      {
-        case ConstraintType_Equal:
-          return OrthancPluginConstraintType_Equal;
-
-        case ConstraintType_GreaterOrEqual:
-          return OrthancPluginConstraintType_GreaterOrEqual;
-
-        case ConstraintType_SmallerOrEqual:
-          return OrthancPluginConstraintType_SmallerOrEqual;
-
-        case ConstraintType_Wildcard:
-          return OrthancPluginConstraintType_Wildcard;
-
-        case ConstraintType_List:
-          return OrthancPluginConstraintType_List;
-
-        default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
-      }
-    }
-#endif    
-
-    
-#if ORTHANC_ENABLE_PLUGINS == 1
-    ConstraintType Convert(OrthancPluginConstraintType constraint)
-    {
-      switch (constraint)
-      {
-        case OrthancPluginConstraintType_Equal:
-          return ConstraintType_Equal;
-
-        case OrthancPluginConstraintType_GreaterOrEqual:
-          return ConstraintType_GreaterOrEqual;
-
-        case OrthancPluginConstraintType_SmallerOrEqual:
-          return ConstraintType_SmallerOrEqual;
-
-        case OrthancPluginConstraintType_Wildcard:
-          return ConstraintType_Wildcard;
-
-        case OrthancPluginConstraintType_List:
-          return ConstraintType_List;
-
-        default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
-      }
-    }
-#endif
-  }
-
   DatabaseConstraint::DatabaseConstraint(ResourceType level,
                                          const DicomTag& tag,
                                          bool isIdentifier,
@@ -159,32 +59,6 @@
   }      
 
     
-#if ORTHANC_ENABLE_PLUGINS == 1
-  DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
-    level_(Plugins::Convert(constraint.level)),
-    tag_(constraint.tagGroup, constraint.tagElement),
-    isIdentifier_(constraint.isIdentifierTag),
-    constraintType_(Plugins::Convert(constraint.type)),
-    caseSensitive_(constraint.isCaseSensitive),
-    mandatory_(constraint.isMandatory)
-  {
-    if (constraintType_ != ConstraintType_List &&
-        constraint.valuesCount != 1)
-    {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
-    }
-
-    values_.resize(constraint.valuesCount);
-
-    for (uint32_t i = 0; i < constraint.valuesCount; i++)
-    {
-      assert(constraint.values[i] != NULL);
-      values_[i].assign(constraint.values[i]);
-    }
-  }
-#endif
-    
-
   const std::string& DatabaseConstraint::GetValue(size_t index) const
   {
     if (index >= values_.size())
--- a/OrthancServer/Sources/Search/DatabaseConstraint.h	Mon Sep 09 16:20:44 2024 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.h	Mon Sep 09 16:37:52 2024 +0200
@@ -23,40 +23,17 @@
 
 #pragma once
 
+#include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
+#include "../ServerEnumerations.h"
+
 #if ORTHANC_ENABLE_PLUGINS == 1
 #  include "../../Plugins/Include/orthanc/OrthancCDatabasePlugin.h"
 #endif
 
-#include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
-
 #include <deque>
 
 namespace Orthanc
 {
-  enum ConstraintType
-  {
-    ConstraintType_Equal,
-    ConstraintType_SmallerOrEqual,
-    ConstraintType_GreaterOrEqual,
-    ConstraintType_Wildcard,
-    ConstraintType_List
-  };
-
-
-#if ORTHANC_ENABLE_PLUGINS == 1
-  namespace Plugins
-  {
-    OrthancPluginResourceType Convert(ResourceType type);
-
-    ResourceType Convert(OrthancPluginResourceType type);
-
-    OrthancPluginConstraintType Convert(ConstraintType constraint);
-
-    ConstraintType Convert(OrthancPluginConstraintType constraint);
-  }
-#endif
-
-
   class DatabaseConstraint : public boost::noncopyable
   {
   private:
@@ -76,10 +53,6 @@
                        const std::vector<std::string>& values,
                        bool caseSensitive,
                        bool mandatory);
-
-#if ORTHANC_ENABLE_PLUGINS == 1
-    explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
-#endif
     
     ResourceType GetLevel() const
     {
--- a/OrthancServer/Sources/ServerEnumerations.h	Mon Sep 09 16:20:44 2024 +0200
+++ b/OrthancServer/Sources/ServerEnumerations.h	Mon Sep 09 16:37:52 2024 +0200
@@ -112,6 +112,15 @@
     TransactionType_ReadWrite
   };
 
+  enum ConstraintType
+  {
+    ConstraintType_Equal,
+    ConstraintType_SmallerOrEqual,
+    ConstraintType_GreaterOrEqual,
+    ConstraintType_Wildcard,
+    ConstraintType_List
+  };
+
 
   /**
    * WARNING: Do not change the explicit values in the enumerations