Mercurial > hg > orthanc-databases
diff PostgreSQL/Plugins/IndexPlugin.cpp @ 2:17bce6a07b2b
storage plugin skeletons
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 05 Jul 2018 15:06:32 +0200 |
parents | 7cea966b6829 |
children | 3686ba3f9cdb |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/IndexPlugin.cpp Wed Jul 04 18:05:24 2018 +0200 +++ b/PostgreSQL/Plugins/IndexPlugin.cpp Thu Jul 05 15:06:32 2018 +0200 @@ -21,10 +21,8 @@ #include "PostgreSQLIndex.h" -#include <Plugins/Samples/Common/OrthancPluginCppWrapper.h> #include <Core/Logging.h> -static OrthancPluginContext* context_ = NULL; static std::auto_ptr<OrthancDatabases::PostgreSQLIndex> backend_; @@ -32,8 +30,8 @@ static bool DisplayPerformanceWarning() { (void) DisplayPerformanceWarning; // Disable warning about unused function - OrthancPluginLogWarning(context_, "Performance warning in PostgreSQL index: " - "Non-release build, runtime debug assertions are turned on"); + LOG(WARNING) << "Performance warning in PostgreSQL index: " + << "Non-release build, runtime debug assertions are turned on"; return true; } @@ -44,23 +42,22 @@ { Orthanc::Logging::Initialize(context); - context_ = context; assert(DisplayPerformanceWarning()); /* Check the version of the Orthanc core */ - if (OrthancPluginCheckVersion(context_) == 0) + if (OrthancPluginCheckVersion(context) == 0) { char info[1024]; sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", - context_->orthancVersion, + context->orthancVersion, ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); - OrthancPluginLogError(context_, info); + OrthancPluginLogError(context, info); return -1; } - OrthancPluginSetDescription(context_, "Stores the Orthanc index into a PostgreSQL database."); + OrthancPluginSetDescription(context, "Stores the Orthanc index into a PostgreSQL database."); OrthancPlugins::OrthancConfiguration configuration(context); @@ -90,11 +87,16 @@ backend_.reset(new OrthancDatabases::PostgreSQLIndex(parameters)); /* Register the PostgreSQL index into Orthanc */ - OrthancPlugins::DatabaseBackendAdapter::Register(context_, *backend_); + OrthancPlugins::DatabaseBackendAdapter::Register(context, *backend_); } - catch (std::runtime_error& e) + catch (Orthanc::OrthancException& e) { - OrthancPluginLogError(context_, e.what()); + LOG(ERROR) << e.What(); + return -1; + } + catch (...) + { + LOG(ERROR) << "Native exception while initializing the plugin"; return -1; } @@ -104,7 +106,7 @@ ORTHANC_PLUGINS_API void OrthancPluginFinalize() { - OrthancPluginLogWarning(context_, "PostgreSQL index is finalizing"); + LOG(WARNING) << "PostgreSQL storage area is finalizing"; backend_.reset(NULL); }