changeset 5765:247fc5368693 find-refactoring

un-sharing DatabaseConstraint and ISqlLookupFormatter with orthanc-databases
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 16:14:22 +0200
parents 1b0e67be3c15
children 3915736c40a5
files OrthancServer/CMakeLists.txt OrthancServer/Plugins/Samples/DelayedDeletion/CMakeLists.txt OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/Search/DatabaseConstraint.cpp OrthancServer/Sources/Search/DatabaseConstraint.h OrthancServer/Sources/Search/ISqlLookupFormatter.cpp OrthancServer/Sources/Search/ISqlLookupFormatter.h
diffstat 7 files changed, 25 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/CMakeLists.txt	Mon Sep 09 16:14:22 2024 +0200
@@ -332,7 +332,6 @@
 
 add_definitions(
   -DORTHANC_BUILD_UNIT_TESTS=1
-  -DORTHANC_BUILDING_SERVER_LIBRARY=1
 
   # Macros for the plugins
   -DHAS_ORTHANC_EXCEPTION=0
--- a/OrthancServer/Plugins/Samples/DelayedDeletion/CMakeLists.txt	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Plugins/Samples/DelayedDeletion/CMakeLists.txt	Mon Sep 09 16:14:22 2024 +0200
@@ -60,7 +60,6 @@
   -DORTHANC_PLUGIN_VERSION="${PLUGIN_VERSION}"
   -DORTHANC_ENABLE_LOGGING=1
   -DORTHANC_ENABLE_PLUGINS=1
-  -DORTHANC_BUILDING_SERVER_LIBRARY=0
   )
 
 include_directories(
--- a/OrthancServer/Resources/RunCppCheck.sh	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Resources/RunCppCheck.sh	Mon Sep 09 16:14:22 2024 +0200
@@ -55,7 +55,6 @@
             -DJSONCPP_VERSION_MAJOR=1 \
             -DJSONCPP_VERSION_MINOR=0 \
             -DORTHANC_BUILDING_FRAMEWORK_LIBRARY=0 \
-            -DORTHANC_BUILDING_SERVER_LIBRARY=1 \
             -DORTHANC_BUILD_UNIT_TESTS=1 \
             -DORTHANC_ENABLE_BASE64=1 \
             -DORTHANC_ENABLE_CIVETWEB=1 \
--- a/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Mon Sep 09 16:14:22 2024 +0200
@@ -21,21 +21,10 @@
  **/
 
 
-#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
-#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
-#endif
-
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../PrecompiledHeadersServer.h"
-#endif
-
+#include "../PrecompiledHeadersServer.h"
 #include "DatabaseConstraint.h"
 
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../../../OrthancFramework/Sources/OrthancException.h"
-#else
-#  include <OrthancException.h>
-#endif
+#include "../../../OrthancFramework/Sources/OrthancException.h"
 
 #include <boost/lexical_cast.hpp>
 #include <cassert>
@@ -93,7 +82,7 @@
 #endif
 
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
     OrthancPluginConstraintType Convert(ConstraintType constraint)
     {
       switch (constraint)
@@ -120,7 +109,7 @@
 #endif    
 
     
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
     ConstraintType Convert(OrthancPluginConstraintType constraint)
     {
       switch (constraint)
@@ -170,7 +159,7 @@
   }      
 
     
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
   DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
     level_(Plugins::Convert(constraint.level)),
     tag_(constraint.tagGroup, constraint.tagElement),
@@ -222,7 +211,7 @@
   }
 
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
   void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                                             std::vector<const char*>& tmpValues) const
   {
--- a/OrthancServer/Sources/Search/DatabaseConstraint.h	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.h	Mon Sep 09 16:14:22 2024 +0200
@@ -23,28 +23,11 @@
 
 #pragma once
 
-#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
-#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
-#endif
-
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
-#else
-// This is for the "orthanc-databases" project to reuse this file
-#  include <DicomFormat/DicomMap.h>
+#if ORTHANC_ENABLE_PLUGINS == 1
+#  include "../../Plugins/Include/orthanc/OrthancCDatabasePlugin.h"
 #endif
 
-#define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
-
-#if ORTHANC_ENABLE_PLUGINS == 1
-#  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
+#include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
 
 #include <deque>
 
@@ -59,27 +42,21 @@
     ConstraintType_List
   };
 
+
+#if ORTHANC_ENABLE_PLUGINS == 1
   namespace Plugins
   {
-#if ORTHANC_ENABLE_PLUGINS == 1
     OrthancPluginResourceType Convert(ResourceType type);
-#endif
+
+    ResourceType Convert(OrthancPluginResourceType type);
 
-#if ORTHANC_ENABLE_PLUGINS == 1
-    ResourceType Convert(OrthancPluginResourceType type);
+    OrthancPluginConstraintType Convert(ConstraintType constraint);
+
+    ConstraintType Convert(OrthancPluginConstraintType constraint);
+  }
 #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 : public boost::noncopyable
   {
   private:
@@ -100,7 +77,7 @@
                        bool caseSensitive,
                        bool mandatory);
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
     explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
 #endif
     
@@ -145,7 +122,7 @@
 
     bool IsMatch(const DicomMap& dicom) const;
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_ENABLE_PLUGINS == 1
     void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                           std::vector<const char*>& tmpValues) const;
 #endif    
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Mon Sep 09 16:14:22 2024 +0200
@@ -21,25 +21,12 @@
  **/
 
 
-#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
-#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
-#endif
-
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../PrecompiledHeadersServer.h"
-#endif
-
+#include "../PrecompiledHeadersServer.h"
 #include "ISqlLookupFormatter.h"
 
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../../../OrthancFramework/Sources/OrthancException.h"
-#  include "../../../OrthancFramework/Sources/Toolbox.h"
-#  include "../Database/FindRequest.h"
-#else
-#  include <OrthancException.h>
-#  include <Toolbox.h>
-#endif
-
+#include "../../../OrthancFramework/Sources/OrthancException.h"
+#include "../../../OrthancFramework/Sources/Toolbox.h"
+#include "../Database/FindRequest.h"
 #include "DatabaseConstraint.h"
 
 #include <cassert>
@@ -617,7 +604,7 @@
     }
   }
 
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+
   void ISqlLookupFormatter::Apply(std::string& sql,
                                   ISqlLookupFormatter& formatter,
                                   const FindRequest& request)
@@ -754,9 +741,7 @@
     {
       sql += formatter.FormatLimits(request.GetLimitsSince(), request.GetLimitsCount());
     }
-
   }
-#endif
 
 
   void ISqlLookupFormatter::ApplySingleLevel(std::string& sql,
@@ -872,5 +857,4 @@
       sql += " LIMIT " + boost::lexical_cast<std::string>(limit);
     }
   }
-
 }
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Fri Sep 06 16:51:44 2024 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Mon Sep 09 16:14:22 2024 +0200
@@ -23,11 +23,7 @@
 
 #pragma once
 
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
-#  include "../../../OrthancFramework/Sources/Enumerations.h"
-#else
-#  include <Enumerations.h>
-#endif
+#include "../../../OrthancFramework/Sources/Enumerations.h"
 
 #include <boost/noncopyable.hpp>
 #include <vector>
@@ -44,7 +40,6 @@
     LabelsConstraint_None
   };
 
-  // This class is also used by the "orthanc-databases" project
   class ISqlLookupFormatter : public boost::noncopyable
   {
   public:
@@ -88,10 +83,8 @@
                                  LabelsConstraint labelsConstraint,    // New in Orthanc 1.12.0
                                  size_t limit);
 
-#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
     static void Apply(std::string& sql,
                       ISqlLookupFormatter& formatter,
                       const FindRequest& request);
-#endif
   };
 }