comparison Framework/Plugins/PluginInitialization.cpp @ 24:17f849b2af34

sharing plugin initialization code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 12 Jul 2018 12:17:39 +0200
parents
children c0cb5d2cd696
comparison
equal deleted inserted replaced
23:b2ff1cd2907a 24:17f849b2af34
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "PluginInitialization.h"
23
24 #include <Core/Logging.h>
25
26 namespace OrthancDatabases
27 {
28 static bool DisplayPerformanceWarning(const std::string& shortName)
29 {
30 (void) DisplayPerformanceWarning; // Disable warning about unused function
31 LOG(WARNING) << "Performance warning in " << shortName << ": "
32 << "Non-release build, runtime debug assertions are turned on";
33 return true;
34 }
35
36
37 bool InitializePlugin(OrthancPluginContext* context,
38 const std::string& shortName,
39 const std::string& description)
40 {
41 Orthanc::Logging::Initialize(context);
42
43 assert(DisplayPerformanceWarning(shortName));
44
45 /* Check the version of the Orthanc core */
46
47 bool useFallback = true;
48
49 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
50 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0)
51 if (OrthancPluginCheckVersionAdvanced(context, 0, 9, 5) == 0)
52 {
53 LOG(ERROR) << "Your version of Orthanc (" << context->orthancVersion
54 << ") must be above 0.9.5 to run this plugin";
55 return false;
56 }
57
58 useFallback = false;
59 # endif
60 #endif
61
62 if (useFallback &&
63 OrthancPluginCheckVersion(context) == 0)
64 {
65 LOG(ERROR) << "Your version of Orthanc ("
66 << context->orthancVersion << ") must be above "
67 << ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER << "."
68 << ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER << "."
69 << ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER
70 << " to run this plugin";
71 return false;
72 }
73
74 OrthancPluginSetDescription(context, description.c_str());
75
76 return true;
77 }
78 }