comparison Framework/Plugins/PluginInitialization.cpp @ 28:c0cb5d2cd696

checks depending on Orthanc version
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jul 2018 14:48:43 +0200
parents 17f849b2af34
children eedd082355f9
comparison
equal deleted inserted replaced
27:173176f8cef2 28:c0cb5d2cd696
19 **/ 19 **/
20 20
21 21
22 #include "PluginInitialization.h" 22 #include "PluginInitialization.h"
23 23
24 #include "../Common/ImplicitTransaction.h"
25
24 #include <Core/Logging.h> 26 #include <Core/Logging.h>
25 27
26 namespace OrthancDatabases 28 namespace OrthancDatabases
27 { 29 {
28 static bool DisplayPerformanceWarning(const std::string& shortName) 30 static bool DisplayPerformanceWarning(const std::string& dbms,
31 bool isIndex)
29 { 32 {
30 (void) DisplayPerformanceWarning; // Disable warning about unused function 33 (void) DisplayPerformanceWarning; // Disable warning about unused function
31 LOG(WARNING) << "Performance warning in " << shortName << ": " 34 LOG(WARNING) << "Performance warning in " << dbms
32 << "Non-release build, runtime debug assertions are turned on"; 35 << (isIndex ? " index" : " storage area")
36 << ": Non-release build, runtime debug assertions are turned on";
33 return true; 37 return true;
34 } 38 }
35 39
36 40
37 bool InitializePlugin(OrthancPluginContext* context, 41 bool InitializePlugin(OrthancPluginContext* context,
38 const std::string& shortName, 42 const std::string& dbms,
39 const std::string& description) 43 bool isIndex)
40 { 44 {
41 Orthanc::Logging::Initialize(context); 45 Orthanc::Logging::Initialize(context);
46 ImplicitTransaction::SetErrorOnDoubleExecution(false);
42 47
43 assert(DisplayPerformanceWarning(shortName)); 48 assert(DisplayPerformanceWarning(dbms, isIndex));
44 49
45 /* Check the version of the Orthanc core */ 50 /* Check the version of the Orthanc core */
46 51
47 bool useFallback = true; 52 bool useFallback = true;
53 bool isOptimal = false;
48 54
49 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 55 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
50 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0) 56 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0)
51 if (OrthancPluginCheckVersionAdvanced(context, 0, 9, 5) == 0) 57 if (OrthancPluginCheckVersionAdvanced(context, 0, 9, 5) == 0)
52 { 58 {
53 LOG(ERROR) << "Your version of Orthanc (" << context->orthancVersion 59 LOG(ERROR) << "Your version of Orthanc (" << context->orthancVersion
54 << ") must be above 0.9.5 to run this plugin"; 60 << ") must be above 0.9.5 to run this plugin";
55 return false; 61 return false;
62 }
63
64 if (OrthancPluginCheckVersionAdvanced(context, 1, 4, 0) == 1)
65 {
66 ImplicitTransaction::SetErrorOnDoubleExecution(true);
67 isOptimal = true;
56 } 68 }
57 69
58 useFallback = false; 70 useFallback = false;
59 # endif 71 # endif
60 #endif 72 #endif
69 << ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 81 << ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER
70 << " to run this plugin"; 82 << " to run this plugin";
71 return false; 83 return false;
72 } 84 }
73 85
86 if (!isOptimal &&
87 isIndex)
88 {
89 LOG(WARNING) << "Performance warning in " << dbms
90 << " index: Your version of Orthanc ("
91 << context->orthancVersion << ") should be upgraded to 1.4.0 "
92 << "to benefit from best performance";
93 }
94
95
96 std::string description = ("Stores the Orthanc " +
97 std::string(isIndex ? "index" : "storage area") +
98 " into a " + dbms + " database");
99
74 OrthancPluginSetDescription(context, description.c_str()); 100 OrthancPluginSetDescription(context, description.c_str());
75 101
76 return true; 102 return true;
77 } 103 }
78 } 104 }