changeset 233:7d46c99523a2

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Apr 2021 15:07:27 +0200
parents 4e15eace9b90
children d1b124d116c1
files Framework/Plugins/DatabaseBackendAdapterV3.cpp
diffstat 1 files changed, 10 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Apr 06 12:50:06 2021 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Apr 06 15:07:27 2021 +0200
@@ -24,6 +24,8 @@
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
 
+#include <MultiThreading/SharedMessageQueue.h>
+
 #include <OrthancException.h>
 
 #include <stdexcept>
@@ -31,8 +33,6 @@
 #include <string>
 #include <cassert>
 
-#include <boost/thread/mutex.hpp>  // TODO - REMOVE
-
 
 #define ORTHANC_PLUGINS_DATABASE_CATCH(context)                         \
   catch (::Orthanc::OrthancException& e)                                \
@@ -97,20 +97,7 @@
       return context_;
     }
 
-    uint32_t GetDatabaseVersion()
-    {
-      boost::mutex::scoped_lock lock(managerMutex_);
-      return backend_->GetDatabaseVersion(GetManager());
-    }
-
-    void UpgradeDatabase(OrthancPluginStorageArea* storageArea,
-                         uint32_t targetVersion)
-    {
-      boost::mutex::scoped_lock lock(managerMutex_);
-      backend_->UpgradeDatabase(GetManager(), targetVersion, storageArea);
-    }
-
-    void OpenConnection()
+    void OpenConnections()
     {
       boost::mutex::scoped_lock  lock(managerMutex_);
 
@@ -124,7 +111,7 @@
       }
     }
 
-    void CloseConnection()
+    void CloseConnections()
     {
       boost::mutex::scoped_lock  lock(managerMutex_);
 
@@ -890,7 +877,7 @@
 
     try
     {
-      adapter->OpenConnection();
+      adapter->OpenConnections();
       return OrthancPluginErrorCode_Success;
     }
     ORTHANC_PLUGINS_DATABASE_CATCH(adapter->GetContext());
@@ -903,7 +890,7 @@
 
     try
     {
-      adapter->CloseConnection();
+      adapter->CloseConnections();
       return OrthancPluginErrorCode_Success;
     }
     ORTHANC_PLUGINS_DATABASE_CATCH(adapter->GetContext());
@@ -943,7 +930,8 @@
       
     try
     {
-      *version = adapter->GetDatabaseVersion();
+      DatabaseBackendAdapterV3::Adapter::DatabaseAccessor accessor(*adapter);
+      *version = accessor.GetBackend().GetDatabaseVersion(accessor.GetManager());
       return OrthancPluginErrorCode_Success;
     }
     ORTHANC_PLUGINS_DATABASE_CATCH(adapter->GetContext());
@@ -958,7 +946,8 @@
       
     try
     {
-      adapter->UpgradeDatabase(storageArea, targetVersion);
+      DatabaseBackendAdapterV3::Adapter::DatabaseAccessor accessor(*adapter);
+      accessor.GetBackend().UpgradeDatabase(accessor.GetManager(), targetVersion, storageArea);
       return OrthancPluginErrorCode_Success;
     }
     ORTHANC_PLUGINS_DATABASE_CATCH(adapter->GetContext());