comparison PostgreSQL/Plugins/IndexPlugin.cpp @ 161:2ccde9c7311b optimized-routes

added new optimized REST routes. this is a temporary work to try to speed up some routes (used by LRO). This way, we avoid another app to access the Orthanc DB and we skip the plugin SDK update for a very specific route
author Alain Mazy <alain@mazy.be>
date Fri, 10 Jul 2020 13:26:47 +0200
parents 275e14f57f1e
children
comparison
equal deleted inserted replaced
160:84b6fc6f6b9b 161:2ccde9c7311b
19 **/ 19 **/
20 20
21 21
22 #include "PostgreSQLIndex.h" 22 #include "PostgreSQLIndex.h"
23 #include "../../Framework/Plugins/PluginInitialization.h" 23 #include "../../Framework/Plugins/PluginInitialization.h"
24 #include "../../Framework/Plugins/OptimizedRoutes.h"
24 25
25 #include <Compatibility.h> // For std::unique_ptr<> 26 #include <Compatibility.h> // For std::unique_ptr<>
26 #include <Logging.h> 27 #include <Logging.h>
27 28
28 static std::unique_ptr<OrthancDatabases::PostgreSQLIndex> backend_; 29 static std::unique_ptr<OrthancDatabases::PostgreSQLIndex> backend_;
29 30 static std::unique_ptr<OrthancDatabases::OptimizedRoutes> optimizedRoutes_;
30 31
31 extern "C" 32 extern "C"
32 { 33 {
33 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) 34 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
34 { 35 {
64 /* Create the database back-end */ 65 /* Create the database back-end */
65 backend_.reset(new OrthancDatabases::PostgreSQLIndex(parameters)); 66 backend_.reset(new OrthancDatabases::PostgreSQLIndex(parameters));
66 67
67 /* Register the PostgreSQL index into Orthanc */ 68 /* Register the PostgreSQL index into Orthanc */
68 OrthancPlugins::DatabaseBackendAdapter::Register(context, *backend_); 69 OrthancPlugins::DatabaseBackendAdapter::Register(context, *backend_);
70
71 if (parameters.GetEnabledOptimizedRoutes())
72 {
73 OrthancDatabases::OptimizedRoutes::EnableOptimizedRoutes(backend_.get(), context);
74 }
69 } 75 }
70 catch (Orthanc::OrthancException& e) 76 catch (Orthanc::OrthancException& e)
71 { 77 {
72 LOG(ERROR) << e.What(); 78 LOG(ERROR) << e.What();
73 return -1; 79 return -1;