diff SQLite/Plugins/IndexPlugin.cpp @ 222:c8e06b41feec

refactoring registration/finalization of index backend
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 01 Apr 2021 11:16:13 +0200
parents c2e4a909de0e
children d1b124d116c1
line wrap: on
line diff
--- a/SQLite/Plugins/IndexPlugin.cpp	Tue Mar 30 10:40:34 2021 +0200
+++ b/SQLite/Plugins/IndexPlugin.cpp	Thu Apr 01 11:16:13 2021 +0200
@@ -20,14 +20,10 @@
 
 
 #include "SQLiteIndex.h"
-#include "../../Framework/Plugins/DatabaseBackendAdapterV3.h"
 #include "../../Framework/Plugins/PluginInitialization.h"
 
-#include <Compatibility.h>  // For std::unique_ptr<>
 #include <Logging.h>
 
-static std::unique_ptr<OrthancDatabases::SQLiteIndex> backend_;
-
 
 extern "C"
 {
@@ -62,11 +58,9 @@
 
     try
     {
-      /* Create the database back-end */
-      backend_.reset(new OrthancDatabases::SQLiteIndex(context, "index.db"));  // TODO parameter
-
       /* Register the SQLite index into Orthanc */
-      OrthancDatabases::IndexBackend::Register(*backend_);
+      OrthancDatabases::IndexBackend::Register(
+        new OrthancDatabases::SQLiteIndex(context, "index.db"));  // TODO parameter
     }
     catch (Orthanc::OrthancException& e)
     {
@@ -86,7 +80,7 @@
   ORTHANC_PLUGINS_API void OrthancPluginFinalize()
   {
     LOG(WARNING) << "SQLite index is finalizing";
-    backend_.reset(NULL);
+    OrthancDatabases::IndexBackend::Finalize();
   }