# HG changeset patch # User Sebastien Jodogne # Date 1616597963 -3600 # Node ID c2e4a909de0ef58c7bfc8ed59ae48ef53c959ac3 # Parent 821d4ba83dc3dab087b057d70089590318bc553c added IndexBackend::Register() to be used in all the index plugins diff -r 821d4ba83dc3 -r c2e4a909de0e Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Wed Mar 24 15:47:14 2021 +0100 +++ b/Framework/Plugins/IndexBackend.cpp Wed Mar 24 15:59:23 2021 +0100 @@ -25,6 +25,8 @@ #include "../Common/BinaryStringValue.h" #include "../Common/Integer64Value.h" #include "../Common/Utf8StringValue.h" +#include "DatabaseBackendAdapterV2.h" +#include "DatabaseBackendAdapterV3.h" #include "GlobalProperties.h" #include // For std::unique_ptr<> @@ -2208,4 +2210,28 @@ assert(result.seriesId != -1); assert(result.instanceId != -1); } + + + void IndexBackend::Register(IndexBackend& backend) + { + OrthancPluginContext* context = backend.GetContext(); + + bool hasLoadedV3 = false; + +#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 +# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) + if (OrthancPluginCheckVersionAdvanced(context, 1, 9, 2) == 1) + { + OrthancDatabases::DatabaseBackendAdapterV3::Register(backend); + hasLoadedV3 = true; + } +# endif +#endif + + if (!hasLoadedV3) + { + LOG(WARNING) << "Performance warning: Your version of Orthanc doesn't support multiple readers/writers"; + OrthancDatabases::DatabaseBackendAdapterV2::Register(backend); + } + } } diff -r 821d4ba83dc3 -r c2e4a909de0e Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Wed Mar 24 15:47:14 2021 +0100 +++ b/Framework/Plugins/IndexBackend.h Wed Mar 24 15:59:23 2021 +0100 @@ -22,7 +22,7 @@ #pragma once #include "../Common/DatabaseManager.h" -#include "DatabaseBackendAdapterV2.h" +#include "IDatabaseBackend.h" #include @@ -339,7 +339,7 @@ const char* hashPatient, const char* hashStudy, const char* hashSeries, - const char* hashInstance) + const char* hashInstance) ORTHANC_OVERRIDE { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } @@ -352,5 +352,7 @@ const char* hashStudy, const char* hashSeries, const char* hashInstance); + + static void Register(IndexBackend& backend); }; } diff -r 821d4ba83dc3 -r c2e4a909de0e Framework/Plugins/IndexUnitTests.h --- a/Framework/Plugins/IndexUnitTests.h Wed Mar 24 15:47:14 2021 +0100 +++ b/Framework/Plugins/IndexUnitTests.h Wed Mar 24 15:59:23 2021 +0100 @@ -22,6 +22,7 @@ #pragma once #include "../Common/ImplicitTransaction.h" +#include "DatabaseBackendAdapterV2.h" #include "GlobalProperties.h" #include // For std::unique_ptr<> diff -r 821d4ba83dc3 -r c2e4a909de0e MySQL/Plugins/IndexPlugin.cpp --- a/MySQL/Plugins/IndexPlugin.cpp Wed Mar 24 15:47:14 2021 +0100 +++ b/MySQL/Plugins/IndexPlugin.cpp Wed Mar 24 15:59:23 2021 +0100 @@ -71,7 +71,7 @@ backend_.reset(new OrthancDatabases::MySQLIndex(context, parameters)); /* Register the MySQL index into Orthanc */ - OrthancDatabases::DatabaseBackendAdapterV2::Register(*backend_); + OrthancDatabases::IndexBackend::Register(*backend_); } catch (Orthanc::OrthancException& e) { diff -r 821d4ba83dc3 -r c2e4a909de0e PostgreSQL/Plugins/IndexPlugin.cpp --- a/PostgreSQL/Plugins/IndexPlugin.cpp Wed Mar 24 15:47:14 2021 +0100 +++ b/PostgreSQL/Plugins/IndexPlugin.cpp Wed Mar 24 15:59:23 2021 +0100 @@ -65,7 +65,7 @@ backend_.reset(new OrthancDatabases::PostgreSQLIndex(context, parameters)); /* Register the PostgreSQL index into Orthanc */ - OrthancDatabases::DatabaseBackendAdapterV2::Register(*backend_); + OrthancDatabases::IndexBackend::Register(*backend_); } catch (Orthanc::OrthancException& e) { diff -r 821d4ba83dc3 -r c2e4a909de0e SQLite/Plugins/IndexPlugin.cpp --- a/SQLite/Plugins/IndexPlugin.cpp Wed Mar 24 15:47:14 2021 +0100 +++ b/SQLite/Plugins/IndexPlugin.cpp Wed Mar 24 15:59:23 2021 +0100 @@ -66,23 +66,7 @@ backend_.reset(new OrthancDatabases::SQLiteIndex(context, "index.db")); // TODO parameter /* Register the SQLite index into Orthanc */ - - bool hasLoadedV3 = false; - -#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 -# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) - if (OrthancPluginCheckVersionAdvanced(context, 1, 9, 2) == 1) - { - OrthancDatabases::DatabaseBackendAdapterV3::Register(*backend_); - hasLoadedV3 = true; - } -# endif -#endif - - if (!hasLoadedV3) - { - OrthancDatabases::DatabaseBackendAdapterV2::Register(*backend_); - } + OrthancDatabases::IndexBackend::Register(*backend_); } catch (Orthanc::OrthancException& e) {