diff PostgreSQL/Plugins/IndexPlugin.cpp @ 24:17f849b2af34

sharing plugin initialization code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 12 Jul 2018 12:17:39 +0200
parents 0217486720b3
children c0cb5d2cd696
line wrap: on
line diff
--- a/PostgreSQL/Plugins/IndexPlugin.cpp	Thu Jul 12 10:44:17 2018 +0200
+++ b/PostgreSQL/Plugins/IndexPlugin.cpp	Thu Jul 12 12:17:39 2018 +0200
@@ -20,45 +20,24 @@
 
 
 #include "PostgreSQLIndex.h"
+#include "../../Framework/Plugins/PluginInitialization.h"
 
 #include <Core/Logging.h>
 
 static std::auto_ptr<OrthancDatabases::PostgreSQLIndex> backend_;
 
 
-
-static bool DisplayPerformanceWarning()
-{
-  (void) DisplayPerformanceWarning;   // Disable warning about unused function
-  LOG(WARNING) << "Performance warning in PostgreSQL index: "
-               << "Non-release build, runtime debug assertions are turned on";
-  return true;
-}
-
-
 extern "C"
 {
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
   {
-    Orthanc::Logging::Initialize(context);
-
-    assert(DisplayPerformanceWarning());
-
-    /* Check the version of the Orthanc core */
-    if (OrthancPluginCheckVersion(context) == 0)
+    if (!OrthancDatabases::InitializePlugin
+        (context, "PostgreSQL index", 
+         "Stores the Orthanc index into a PostgreSQL database."))
     {
-      char info[1024];
-      sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
-              context->orthancVersion,
-              ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
-              ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
-              ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
-      OrthancPluginLogError(context, info);
       return -1;
     }
 
-    OrthancPluginSetDescription(context, "Stores the Orthanc index into a PostgreSQL database.");
-
     OrthancPlugins::OrthancConfiguration configuration(context);
 
     if (!configuration.IsSection("PostgreSQL"))