diff OrthancServer/main.cpp @ 1455:a68545767975

Initialize() and Finalize() events in Lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Jul 2015 15:17:19 +0200
parents b737acb13da5
children 27661b33f624
line wrap: on
line diff
--- a/OrthancServer/main.cpp	Thu Jul 02 12:30:55 2015 +0200
+++ b/OrthancServer/main.cpp	Thu Jul 02 15:17:19 2015 +0200
@@ -55,9 +55,6 @@
 using namespace Orthanc;
 
 
-#define ENABLE_PLUGINS  1
-
-
 class OrthancStoreRequestHandler : public IStoreRequestHandler
 {
 private:
@@ -389,9 +386,13 @@
 {
   LOG(WARNING) << "Orthanc has started";
 
+  context.GetLua().Execute("Initialize");
+
   Toolbox::ServerBarrier(restApi.ResetRequestReceivedFlag());
   bool restart = restApi.ResetRequestReceivedFlag();
 
+  context.GetLua().Execute("Finalize");
+
   if (restart)
   {
     LOG(WARNING) << "Reset request received, restarting Orthanc";
@@ -570,7 +571,7 @@
   std::auto_ptr<IDatabaseWrapper>  databasePtr;
   std::auto_ptr<IStorageArea>  storage;
 
-#if ENABLE_PLUGINS == 1
+#if ORTHANC_PLUGINS_ENABLED == 1
   OrthancPlugins plugins;
   plugins.SetCommandLineArguments(argc, argv);
   LoadPlugins(plugins);
@@ -602,12 +603,15 @@
 
   return ConfigureServerContext(*database, *storage, &plugins);
 
-#else
+#elif ORTHANC_PLUGINS_ENABLED == 0
   // The plugins are disabled
   databasePtr.reset(Configuration::CreateDatabaseWrapper());
   storage.reset(Configuration::CreateStorageArea());
 
   return ConfigureServerContext(*databasePtr, *storage, NULL);
+
+#else
+#  error The macro ORTHANC_PLUGINS_ENABLED must be set to 0 or 1
 #endif
 }