diff Framework/Plugins/PluginInitialization.cpp @ 28:c0cb5d2cd696

checks depending on Orthanc version
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jul 2018 14:48:43 +0200
parents 17f849b2af34
children eedd082355f9
line wrap: on
line diff
--- a/Framework/Plugins/PluginInitialization.cpp	Sat Jul 14 13:18:31 2018 +0200
+++ b/Framework/Plugins/PluginInitialization.cpp	Mon Jul 16 14:48:43 2018 +0200
@@ -21,30 +21,36 @@
 
 #include "PluginInitialization.h"
 
+#include "../Common/ImplicitTransaction.h"
+
 #include <Core/Logging.h>
 
 namespace OrthancDatabases
 {
-  static bool DisplayPerformanceWarning(const std::string& shortName)
+  static bool DisplayPerformanceWarning(const std::string& dbms,
+                                        bool isIndex)
   {
     (void) DisplayPerformanceWarning;   // Disable warning about unused function
-    LOG(WARNING) << "Performance warning in " << shortName << ": "
-                 << "Non-release build, runtime debug assertions are turned on";
+    LOG(WARNING) << "Performance warning in " << dbms
+                 << (isIndex ? " index" : " storage area")
+                 << ": Non-release build, runtime debug assertions are turned on";
     return true;
   }
 
 
   bool InitializePlugin(OrthancPluginContext* context,
-                        const std::string& shortName,
-                        const std::string& description)
+                        const std::string& dbms,
+                        bool isIndex)
   {
     Orthanc::Logging::Initialize(context);
+    ImplicitTransaction::SetErrorOnDoubleExecution(false);
 
-    assert(DisplayPerformanceWarning(shortName));
+    assert(DisplayPerformanceWarning(dbms, isIndex));
 
     /* Check the version of the Orthanc core */
 
     bool useFallback = true;
+    bool isOptimal = false;
 
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0)
@@ -55,6 +61,12 @@
       return false;
     }
 
+    if (OrthancPluginCheckVersionAdvanced(context, 1, 4, 0) == 1)
+    {
+      ImplicitTransaction::SetErrorOnDoubleExecution(true);
+      isOptimal = true;
+    }
+
     useFallback = false;
 #  endif
 #endif
@@ -71,6 +83,20 @@
       return false;
     }
 
+    if (!isOptimal &&
+        isIndex)
+    {
+      LOG(WARNING) << "Performance warning in " << dbms
+                   << " index: Your version of Orthanc (" 
+                   << context->orthancVersion << ") should be upgraded to 1.4.0 "
+                   << "to benefit from best performance";
+    }
+
+
+    std::string description = ("Stores the Orthanc " +
+                               std::string(isIndex ? "index" : "storage area") +
+                               " into a " + dbms + " database");
+    
     OrthancPluginSetDescription(context, description.c_str());
 
     return true;