comparison Framework/Plugins/PluginInitialization.cpp @ 569:f18e46d7dbf8 attach-custom-data

merged find-refactoring -> attach-custom-data
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 15:04:21 +0200
parents 51a78b3f96bb
children
comparison
equal deleted inserted replaced
368:82f73188b58d 569:f18e46d7dbf8
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
6 * 8 *
7 * This program is free software: you can redistribute it and/or 9 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License 10 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of 11 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
40 return true; 42 return true;
41 } 43 }
42 44
43 45
44 bool InitializePlugin(OrthancPluginContext* context, 46 bool InitializePlugin(OrthancPluginContext* context,
47 const std::string& pluginName,
45 const std::string& dbms, 48 const std::string& dbms,
46 bool isIndex) 49 bool isIndex)
47 { 50 {
48 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2) 51 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4)
52 Orthanc::Logging::InitializePluginContext(context, pluginName);
53 #elif ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2)
49 Orthanc::Logging::InitializePluginContext(context); 54 Orthanc::Logging::InitializePluginContext(context);
50 #else 55 #else
51 Orthanc::Logging::Initialize(context); 56 Orthanc::Logging::Initialize(context);
52 #endif 57 #endif
53 58
56 ImplicitTransaction::SetErrorOnDoubleExecution(false); 61 ImplicitTransaction::SetErrorOnDoubleExecution(false);
57 62
58 assert(DisplayPerformanceWarning(dbms, isIndex)); 63 assert(DisplayPerformanceWarning(dbms, isIndex));
59 64
60 /* Check the version of the Orthanc core */ 65 /* Check the version of the Orthanc core */
66 if (OrthancPluginCheckVersion(context) == 0)
67 {
68 LOG(ERROR) << "Your version of Orthanc ("
69 << context->orthancVersion << ") must be above "
70 << ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER << "."
71 << ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER << "."
72 << ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER
73 << " to run this plugin";
74 return false;
75 }
76
77
78 /* Warn the user if the Orthanc runtime has not an optimal version */
61 79
62 bool useFallback = true; 80 bool useFallback = true;
63 bool isOptimal = false; 81 bool isOptimal = false;
64 82
65 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 83 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
85 } 103 }
86 104
87 useFallback = false; 105 useFallback = false;
88 # endif 106 # endif
89 #endif 107 #endif
90
91 if (useFallback &&
92 OrthancPluginCheckVersion(context) == 0)
93 {
94 LOG(ERROR) << "Your version of Orthanc ("
95 << context->orthancVersion << ") must be above "
96 << ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER << "."
97 << ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER << "."
98 << ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER
99 << " to run this plugin";
100 return false;
101 }
102 108
103 if (useFallback) 109 if (useFallback)
104 { 110 {
105 std::string v(context->orthancVersion); 111 std::string v(context->orthancVersion);
106 112
147 153
148 std::string description = ("Stores the Orthanc " + 154 std::string description = ("Stores the Orthanc " +
149 std::string(isIndex ? "index" : "storage area") + 155 std::string(isIndex ? "index" : "storage area") +
150 " into a " + dbms + " database"); 156 " into a " + dbms + " database");
151 157
152 OrthancPluginSetDescription(context, description.c_str()); 158 OrthancPlugins::SetDescription(pluginName, description.c_str());
153 159
154 return true; 160 return true;
155 } 161 }
156 } 162 }