comparison 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
comparison
equal deleted inserted replaced
1454:9de4fa64e29c 1455:a68545767975
53 #include "FromDcmtkBridge.h" 53 #include "FromDcmtkBridge.h"
54 54
55 using namespace Orthanc; 55 using namespace Orthanc;
56 56
57 57
58 #define ENABLE_PLUGINS 1
59
60
61 class OrthancStoreRequestHandler : public IStoreRequestHandler 58 class OrthancStoreRequestHandler : public IStoreRequestHandler
62 { 59 {
63 private: 60 private:
64 ServerContext& server_; 61 ServerContext& server_;
65 62
387 static bool WaitForExit(ServerContext& context, 384 static bool WaitForExit(ServerContext& context,
388 OrthancRestApi& restApi) 385 OrthancRestApi& restApi)
389 { 386 {
390 LOG(WARNING) << "Orthanc has started"; 387 LOG(WARNING) << "Orthanc has started";
391 388
389 context.GetLua().Execute("Initialize");
390
392 Toolbox::ServerBarrier(restApi.ResetRequestReceivedFlag()); 391 Toolbox::ServerBarrier(restApi.ResetRequestReceivedFlag());
393 bool restart = restApi.ResetRequestReceivedFlag(); 392 bool restart = restApi.ResetRequestReceivedFlag();
393
394 context.GetLua().Execute("Finalize");
394 395
395 if (restart) 396 if (restart)
396 { 397 {
397 LOG(WARNING) << "Reset request received, restarting Orthanc"; 398 LOG(WARNING) << "Reset request received, restarting Orthanc";
398 } 399 }
568 char* argv[]) 569 char* argv[])
569 { 570 {
570 std::auto_ptr<IDatabaseWrapper> databasePtr; 571 std::auto_ptr<IDatabaseWrapper> databasePtr;
571 std::auto_ptr<IStorageArea> storage; 572 std::auto_ptr<IStorageArea> storage;
572 573
573 #if ENABLE_PLUGINS == 1 574 #if ORTHANC_PLUGINS_ENABLED == 1
574 OrthancPlugins plugins; 575 OrthancPlugins plugins;
575 plugins.SetCommandLineArguments(argc, argv); 576 plugins.SetCommandLineArguments(argc, argv);
576 LoadPlugins(plugins); 577 LoadPlugins(plugins);
577 578
578 IDatabaseWrapper* database = NULL; 579 IDatabaseWrapper* database = NULL;
600 assert(database != NULL); 601 assert(database != NULL);
601 assert(storage.get() != NULL); 602 assert(storage.get() != NULL);
602 603
603 return ConfigureServerContext(*database, *storage, &plugins); 604 return ConfigureServerContext(*database, *storage, &plugins);
604 605
605 #else 606 #elif ORTHANC_PLUGINS_ENABLED == 0
606 // The plugins are disabled 607 // The plugins are disabled
607 databasePtr.reset(Configuration::CreateDatabaseWrapper()); 608 databasePtr.reset(Configuration::CreateDatabaseWrapper());
608 storage.reset(Configuration::CreateStorageArea()); 609 storage.reset(Configuration::CreateStorageArea());
609 610
610 return ConfigureServerContext(*databasePtr, *storage, NULL); 611 return ConfigureServerContext(*databasePtr, *storage, NULL);
612
613 #else
614 # error The macro ORTHANC_PLUGINS_ENABLED must be set to 0 or 1
611 #endif 615 #endif
612 } 616 }
613 617
614 618
615 static bool StartOrthanc(int argc, char* argv[]) 619 static bool StartOrthanc(int argc, char* argv[])