diff Framework/Plugins/IndexBackend.cpp @ 213:c2e4a909de0e

added IndexBackend::Register() to be used in all the index plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Mar 2021 15:59:23 +0100
parents a0c095a4ba7d
children dd6cfc250747
line wrap: on
line diff
--- a/Framework/Plugins/IndexBackend.cpp	Wed Mar 24 15:47:14 2021 +0100
+++ b/Framework/Plugins/IndexBackend.cpp	Wed Mar 24 15:59:23 2021 +0100
@@ -25,6 +25,8 @@
 #include "../Common/BinaryStringValue.h"
 #include "../Common/Integer64Value.h"
 #include "../Common/Utf8StringValue.h"
+#include "DatabaseBackendAdapterV2.h"
+#include "DatabaseBackendAdapterV3.h"
 #include "GlobalProperties.h"
 
 #include <Compatibility.h>  // For std::unique_ptr<>
@@ -2208,4 +2210,28 @@
     assert(result.seriesId != -1);
     assert(result.instanceId != -1);
   }
+
+
+  void IndexBackend::Register(IndexBackend& backend)
+  {
+    OrthancPluginContext* context = backend.GetContext();
+    
+    bool hasLoadedV3 = false;
+      
+#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
+#  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
+    if (OrthancPluginCheckVersionAdvanced(context, 1, 9, 2) == 1)
+    {
+      OrthancDatabases::DatabaseBackendAdapterV3::Register(backend);
+      hasLoadedV3 = true;
+    }
+#  endif
+#endif
+
+    if (!hasLoadedV3)
+    {
+      LOG(WARNING) << "Performance warning: Your version of Orthanc doesn't support multiple readers/writers";
+      OrthancDatabases::DatabaseBackendAdapterV2::Register(backend);
+    }
+  }
 }