changeset 3077:aae1d6d31fef db-changes

compatibility with orthanc-databases
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jan 2019 10:06:42 +0100
parents 8bc2cb1335f4
children 147497152ce3
files OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h OrthancServer/Search/DatabaseConstraint.cpp OrthancServer/Search/DatabaseConstraint.h OrthancServer/ServerEnumerations.h Plugins/Engine/PluginsEnumerations.cpp Plugins/Engine/PluginsEnumerations.h
diffstat 6 files changed, 155 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h	Wed Jan 02 19:04:15 2019 +0100
+++ b/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h	Thu Jan 03 10:06:42 2019 +0100
@@ -39,14 +39,6 @@
 {
   namespace Compatibility
   {
-    enum IdentifierConstraintType
-    {
-      IdentifierConstraintType_Equal,
-      IdentifierConstraintType_SmallerOrEqual,
-      IdentifierConstraintType_GreaterOrEqual,
-      IdentifierConstraintType_Wildcard        /* Case sensitive, "*" or "?" are the only allowed wildcards */
-    };
-
     /**
      * This is a compatibility class that contains database primitives
      * that were used in Orthanc <= 1.5.1, and that have been removed
--- a/OrthancServer/Search/DatabaseConstraint.cpp	Wed Jan 02 19:04:15 2019 +0100
+++ b/OrthancServer/Search/DatabaseConstraint.cpp	Thu Jan 03 10:06:42 2019 +0100
@@ -36,13 +36,113 @@
 
 #include "../../Core/OrthancException.h"
 
+
+namespace Orthanc
+{
+  namespace Plugins
+  {
 #if ORTHANC_ENABLE_PLUGINS == 1
-#  include "../../Plugins/Engine/PluginsEnumerations.h"
+    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
 
 
-namespace Orthanc
-{
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 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_PLUGINS_HAS_DATABASE_CONSTRAINT == 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,
@@ -66,7 +166,7 @@
   }      
 
     
-#if ORTHANC_ENABLE_PLUGINS == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
   DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
     level_(Plugins::Convert(constraint.level)),
     tag_(constraint.tagGroup, constraint.tagElement),
@@ -117,7 +217,7 @@
   }
 
 
-#if ORTHANC_ENABLE_PLUGINS == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
   void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                                             std::vector<const char*>& tmpValues) const
   {
--- a/OrthancServer/Search/DatabaseConstraint.h	Wed Jan 02 19:04:15 2019 +0100
+++ b/OrthancServer/Search/DatabaseConstraint.h	Thu Jan 03 10:06:42 2019 +0100
@@ -36,12 +36,40 @@
 #include "../../Core/DicomFormat/DicomMap.h"
 #include "../ServerEnumerations.h"
 
+#define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
+
 #if ORTHANC_ENABLE_PLUGINS == 1
-#  include "../../Plugins/Include/orthanc/OrthancCDatabasePlugin.h"
+#  include <orthanc/OrthancCDatabasePlugin.h>
+#  if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)      // Macro introduced in 1.3.1
+#    if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 2)
+#      undef  ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT
+#      define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 1
+#    endif
+#  endif
 #endif
 
 namespace Orthanc
 {
+  namespace Plugins
+  {
+#if ORTHANC_ENABLE_PLUGINS == 1
+    OrthancPluginResourceType Convert(ResourceType type);
+#endif
+
+#if ORTHANC_ENABLE_PLUGINS == 1
+    ResourceType Convert(OrthancPluginResourceType type);
+#endif
+
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+    OrthancPluginConstraintType Convert(ConstraintType constraint);
+#endif
+
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+    ConstraintType Convert(OrthancPluginConstraintType constraint);
+#endif
+  }
+
+
   // This class is also used by the "orthanc-databases" project
   class DatabaseConstraint
   {
@@ -63,7 +91,7 @@
                        bool caseSensitive,
                        bool mandatory);
 
-#if ORTHANC_ENABLE_PLUGINS == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
     DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
 #endif
     
@@ -108,7 +136,7 @@
 
     bool IsMatch(const DicomMap& dicom) const;
 
-#if ORTHANC_ENABLE_PLUGINS == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
     void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                           std::vector<const char*>& tmpValues) const;
 #endif    
--- a/OrthancServer/ServerEnumerations.h	Wed Jan 02 19:04:15 2019 +0100
+++ b/OrthancServer/ServerEnumerations.h	Thu Jan 03 10:06:42 2019 +0100
@@ -72,6 +72,17 @@
     ConstraintType_List
   };
 
+  namespace Compatibility
+  {
+    enum IdentifierConstraintType
+    {
+      IdentifierConstraintType_Equal,
+      IdentifierConstraintType_SmallerOrEqual,
+      IdentifierConstraintType_GreaterOrEqual,
+      IdentifierConstraintType_Wildcard        /* Case sensitive, "*" or "?" are the only allowed wildcards */
+    };
+  }
+
 
   /**
    * WARNING: Do not change the explicit values in the enumerations
--- a/Plugins/Engine/PluginsEnumerations.cpp	Wed Jan 02 19:04:15 2019 +0100
+++ b/Plugins/Engine/PluginsEnumerations.cpp	Thu Jan 03 10:06:42 2019 +0100
@@ -92,50 +92,6 @@
 
   namespace Plugins
   {
-    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);
-      }
-    }
-
-
     OrthancPluginChangeType Convert(ChangeType type)
     {
       switch (type)
@@ -593,55 +549,5 @@
           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);
-      }
-    }
-    
-
-    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);
-      }
-    }
   }
 }
--- a/Plugins/Engine/PluginsEnumerations.h	Wed Jan 02 19:04:15 2019 +0100
+++ b/Plugins/Engine/PluginsEnumerations.h	Thu Jan 03 10:06:42 2019 +0100
@@ -35,9 +35,15 @@
 
 #if ORTHANC_ENABLE_PLUGINS == 1
 
+/**
+ * NB: Conversions to/from "OrthancPluginConstraintType" and
+ * "OrthancPluginResourceType" are located in file
+ * "../../OrthancServer/Search/DatabaseConstraint.h" to be shared with
+ * the "orthanc-databases" project.
+ **/
+
 #include "../Include/orthanc/OrthancCPlugin.h"
-#include "../../OrthancServer/ServerEnumerations.h"
-#include "../../OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h"
+#include "../../OrthancServer/Search/DatabaseConstraint.h"
 
 namespace Orthanc
 {
@@ -50,10 +56,6 @@
 
   namespace Plugins
   {
-    OrthancPluginResourceType Convert(ResourceType type);
-
-    ResourceType Convert(OrthancPluginResourceType type);
-
     OrthancPluginChangeType Convert(ChangeType type);
 
     OrthancPluginPixelFormat Convert(PixelFormat format);
@@ -77,10 +79,6 @@
     OrthancPluginJobStepStatus Convert(JobStepCode step);
 
     JobStepCode Convert(OrthancPluginJobStepStatus step);
-
-    OrthancPluginConstraintType Convert(ConstraintType constraint);
-
-    ConstraintType Convert(OrthancPluginConstraintType constraint);
   }
 }