diff SQLite/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 17bce6a07b2b
children c0cb5d2cd696
line wrap: on
line diff
--- a/SQLite/Plugins/IndexPlugin.cpp	Thu Jul 12 10:44:17 2018 +0200
+++ b/SQLite/Plugins/IndexPlugin.cpp	Thu Jul 12 12:17:39 2018 +0200
@@ -20,45 +20,24 @@
 
 
 #include "SQLiteIndex.h"
+#include "../../Framework/Plugins/PluginInitialization.h"
 
-#include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
 #include <Core/Logging.h>
 
 static std::auto_ptr<OrthancDatabases::SQLiteIndex> backend_;
 
 
-static bool DisplayPerformanceWarning()
-{
-  (void) DisplayPerformanceWarning;   // Disable warning about unused function
-  LOG(WARNING) << "Performance warning in SQLite 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, "SQLite index", 
+         "Stores the Orthanc index into a SQLite 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 SQLite database.");
-
 #if 0
     OrthancPlugins::OrthancConfiguration configuration(context);