changeset 565:373cf7d747cc find-refactoring

fix build against orthanc mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 22 Sep 2024 10:03:36 +0200
parents 3a83c434b284
children a7f841fc4a9f
files Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexBackend.h Framework/Plugins/MessagesToolbox.h
diffstat 4 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Fri Sep 20 18:36:52 2024 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Sun Sep 22 10:03:36 2024 +0200
@@ -27,6 +27,7 @@
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0)
 
 #include "IndexConnectionsPool.h"
+#include "MessagesToolbox.h"
 
 #include <OrthancDatabasePlugin.pb.h>  // Include protobuf messages
 
@@ -97,7 +98,6 @@
     Orthanc::DatabasePluginMessages::DeleteAttachment::Response*         deleteAttachment_;
     Orthanc::DatabasePluginMessages::DeleteResource::Response*           deleteResource_;
     Orthanc::DatabasePluginMessages::GetChanges::Response*               getChanges_;
-    Orthanc::DatabasePluginMessages::GetChangesExtended::Response*       getChangesExtended_;
     Orthanc::DatabasePluginMessages::GetExportedResources::Response*     getExportedResources_;
     Orthanc::DatabasePluginMessages::GetLastChange::Response*            getLastChange_;
     Orthanc::DatabasePluginMessages::GetLastExportedResource::Response*  getLastExportedResource_;
@@ -105,18 +105,25 @@
     Orthanc::DatabasePluginMessages::LookupAttachment::Response*         lookupAttachment_;
     Orthanc::DatabasePluginMessages::LookupResources::Response*          lookupResources_;
 
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
+    Orthanc::DatabasePluginMessages::GetChangesExtended::Response*       getChangesExtended_;
+#endif
+
     void Clear()
     {
       deleteAttachment_ = NULL;
       deleteResource_ = NULL;
       getChanges_ = NULL;
-      getChangesExtended_ = NULL;
       getExportedResources_ = NULL;
       getLastChange_ = NULL;
       getLastExportedResource_ = NULL;
       getMainDicomTags_ = NULL;
       lookupAttachment_ = NULL;
       lookupResources_ = NULL;
+
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
+      getChangesExtended_ = NULL;
+#endif
     }
     
   public:
@@ -138,11 +145,13 @@
       getChanges_ = &getChanges;
     }
 
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
     Output(Orthanc::DatabasePluginMessages::GetChangesExtended::Response& getChangesExtended)
     {
       Clear();
       getChangesExtended_ = &getChangesExtended;
     }
+#endif
 
     Output(Orthanc::DatabasePluginMessages::GetExportedResources::Response& getExportedResources)
     {
@@ -296,10 +305,12 @@
       {
         change = getChanges_->add_changes();
       }
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
       else if (getChangesExtended_ != NULL)
       {
         change = getChangesExtended_->add_changes();
       }
+#endif
       else if (getLastChange_ != NULL)
       {
         if (getLastChange_->found())
@@ -429,7 +440,7 @@
         response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency());
 #endif
 
-#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+#if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
         response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport());
         response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges());
 #endif
@@ -777,7 +788,7 @@
         response.mutable_get_changes()->set_done(done);
         break;
       }
-#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
       case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED:
       {
         Output output(*response.mutable_get_changes_extended());
@@ -1304,11 +1315,13 @@
         break;
       }
       
+#if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
       case Orthanc::DatabasePluginMessages::OPERATION_FIND:
       {
         backend.ExecuteFind(response, manager, request.find());
         break;
       }
+#endif
 
       default:
         LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation();
--- a/Framework/Plugins/IndexBackend.cpp	Fri Sep 20 18:36:52 2024 +0200
+++ b/Framework/Plugins/IndexBackend.cpp	Sun Sep 22 10:03:36 2024 +0200
@@ -638,11 +638,14 @@
       hasTo = true;
       filters.push_back("seq<=${to}");
     }
+
+#if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1
     if (changeType != _OrthancPluginChangeType_All)
     {
       hasFilterType = true;
       filters.push_back("changeType=${changeType}");
     }
+#endif
 
     std::string filtersString;
     if (filters.size() > 0)
--- a/Framework/Plugins/IndexBackend.h	Fri Sep 20 18:36:52 2024 +0200
+++ b/Framework/Plugins/IndexBackend.h	Sun Sep 22 10:03:36 2024 +0200
@@ -429,11 +429,13 @@
 
     virtual uint64_t MeasureLatency(DatabaseManager& manager) ORTHANC_OVERRIDE;
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
     // New primitive since Orthanc 1.12.5
     virtual bool HasExtendedChanges() const ORTHANC_OVERRIDE
     {
       return true;
     }
+#endif
 
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
     virtual bool HasFindSupport() const ORTHANC_OVERRIDE;
--- a/Framework/Plugins/MessagesToolbox.h	Fri Sep 20 18:36:52 2024 +0200
+++ b/Framework/Plugins/MessagesToolbox.h	Sun Sep 22 10:03:36 2024 +0200
@@ -24,17 +24,11 @@
 #pragma once
 
 #include <orthanc/OrthancCDatabasePlugin.h>
+#include <OrthancDatabasePlugin.pb.h>
 
 // Ensure that "ORTHANC_PLUGINS_VERSION_IS_ABOVE" is defined
 #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 
-#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
-#  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
-#    include <OrthancDatabasePlugin.pb.h>
-#  endif
-#endif
-
-
 #define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
 
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
@@ -55,6 +49,16 @@
 #endif
 
 
+#define ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED 0
+
+#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
+#  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+#    undef  ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED
+#    define ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED 1
+#  endif
+#endif
+
+
 #include <Enumerations.h>