comparison Framework/StoneInitialization.cpp @ 1167:ad4e21df4e40 broker

enriching OrthancStone::StoneInitialize()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Nov 2019 10:55:44 +0100
parents efc5b62b9539
children 092ec2a225ad
comparison
equal deleted inserted replaced
1165:4d97f532f1e0 1167:ad4e21df4e40
19 **/ 19 **/
20 20
21 21
22 #include "StoneInitialization.h" 22 #include "StoneInitialization.h"
23 23
24 #include <Core/OrthancException.h>
25
26 #if !defined(ORTHANC_ENABLE_SDL) 24 #if !defined(ORTHANC_ENABLE_SDL)
27 # error Macro ORTHANC_ENABLE_SDL must be defined 25 # error Macro ORTHANC_ENABLE_SDL must be defined
26 #endif
27
28 #if !defined(ORTHANC_ENABLE_SSL)
29 # error Macro ORTHANC_ENABLE_SSL must be defined
30 #endif
31
32 #if !defined(ORTHANC_ENABLE_CURL)
33 # error Macro ORTHANC_ENABLE_CURL must be defined
34 #endif
35
36 #if !defined(ORTHANC_ENABLE_DCMTK)
37 # error Macro ORTHANC_ENABLE_DCMTK must be defined
38 # if !defined(DCMTK_VERSION_NUMBER)
39 # error Macro DCMTK_VERSION_NUMBER must be defined
40 # endif
28 #endif 41 #endif
29 42
30 #if ORTHANC_ENABLE_SDL == 1 43 #if ORTHANC_ENABLE_SDL == 1
31 # include "Viewport/SdlWindow.h" 44 # include "Viewport/SdlWindow.h"
32 #endif 45 #endif
33 46
34 #if ORTHANC_ENABLE_CURL == 1 47 #if ORTHANC_ENABLE_CURL == 1
35 #include <Core/HttpClient.h> 48 # include <Core/HttpClient.h>
36 #endif 49 #endif
50
51 #if ORTHANC_ENABLE_DCMTK == 1
52 # include <Core/DicomParsing/FromDcmtkBridge.h>
53 #endif
54
55 #include "Toolbox/LinearAlgebra.h"
56
57 #include <Core/OrthancException.h>
58 #include <Core/Toolbox.h>
59
37 60
38 namespace OrthancStone 61 namespace OrthancStone
39 { 62 {
40 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 63 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1
41 void StoneInitialize(OrthancPluginContext* context) 64 void StoneInitialize(OrthancPluginContext* context)
47 Orthanc::Logging::Initialize(context); 70 Orthanc::Logging::Initialize(context);
48 #else 71 #else
49 Orthanc::Logging::Initialize(); 72 Orthanc::Logging::Initialize();
50 #endif 73 #endif
51 74
52 #if ORTHANC_ENABLE_SDL == 1 75 #if ORTHANC_ENABLE_SSL == 1
53 OrthancStone::SdlWindow::GlobalInitialize(); 76 // Must be before curl
77 Orthanc::Toolbox::InitializeOpenSsl();
54 #endif 78 #endif
55 79
56 #if ORTHANC_ENABLE_CURL == 1 80 #if ORTHANC_ENABLE_CURL == 1
57 Orthanc::HttpClient::GlobalInitialize(); 81 Orthanc::HttpClient::GlobalInitialize();
82 # if ORTHANC_ENABLE_SSL == 1
83 Orthanc::HttpClient::ConfigureSsl(false, "");
84 # endif
85 #endif
86
87 #if ORTHANC_ENABLE_DCMTK == 1
88 Orthanc::FromDcmtkBridge::InitializeDictionary(true);
89 Orthanc::FromDcmtkBridge::InitializeCodecs();
90 # if DCMTK_VERSION_NUMBER <= 360
91 OFLog::configure(OFLogger::FATAL_LOG_LEVEL);
92 # else
93 OFLog::configure(OFLogger::OFF_LOG_LEVEL);
94 # endif
95 #endif
96
97 {
98 // Run-time check of locale settings after Qt has been initialized
99 OrthancStone::Vector v;
100 if (!OrthancStone::LinearAlgebra::ParseVector(v, "1.3671875\\-1.3671875") ||
101 v.size() != 2 ||
102 !OrthancStone::LinearAlgebra::IsNear(1.3671875f, v[0]) ||
103 !OrthancStone::LinearAlgebra::IsNear(-1.3671875f, v[1]))
104 {
105 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
106 "Error in the locale settings, giving up");
107 }
108 }
109
110 #if ORTHANC_ENABLE_SDL == 1
111 OrthancStone::SdlWindow::GlobalInitialize();
58 #endif 112 #endif
59 } 113 }
114
60 115
61 void StoneFinalize() 116 void StoneFinalize()
62 { 117 {
63 #if ORTHANC_ENABLE_SDL == 1 118 #if ORTHANC_ENABLE_SDL == 1
64 OrthancStone::SdlWindow::GlobalFinalize(); 119 OrthancStone::SdlWindow::GlobalFinalize();
65 #endif 120 #endif
66 121
122 #if ORTHANC_ENABLE_DCMTK == 1
123 Orthanc::FromDcmtkBridge::FinalizeCodecs();
124 #endif
125
67 #if ORTHANC_ENABLE_CURL == 1 126 #if ORTHANC_ENABLE_CURL == 1
68 Orthanc::HttpClient::GlobalFinalize(); 127 Orthanc::HttpClient::GlobalFinalize();
128 #endif
129
130 #if ORTHANC_ENABLE_SSL == 1
131 Orthanc::Toolbox::FinalizeOpenSsl();
69 #endif 132 #endif
70 133
71 Orthanc::Logging::Finalize(); 134 Orthanc::Logging::Finalize();
72 } 135 }
73 } 136 }