Mercurial > hg > orthanc-databases
changeset 213:c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Mar 2021 15:59:23 +0100 |
parents | 821d4ba83dc3 |
children | ab96698c73a3 |
files | Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexBackend.h Framework/Plugins/IndexUnitTests.h MySQL/Plugins/IndexPlugin.cpp PostgreSQL/Plugins/IndexPlugin.cpp SQLite/Plugins/IndexPlugin.cpp |
diffstat | 6 files changed, 34 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- 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 <Compatibility.h> // 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); + } + } }
--- 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 <OrthancException.h> @@ -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); }; }
--- 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 <Compatibility.h> // For std::unique_ptr<>
--- 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) {
--- 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) {
--- 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) {