comparison MySQL/Plugins/IndexPlugin.cpp @ 24:17f849b2af34

sharing plugin initialization code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 12 Jul 2018 12:17:39 +0200
parents 17bce6a07b2b
children c0cb5d2cd696
comparison
equal deleted inserted replaced
23:b2ff1cd2907a 24:17f849b2af34
19 **/ 19 **/
20 20
21 21
22 #include "MySQLIndex.h" 22 #include "MySQLIndex.h"
23 #include "../../Framework/MySQL/MySQLDatabase.h" 23 #include "../../Framework/MySQL/MySQLDatabase.h"
24 #include "../../Framework/Plugins/PluginInitialization.h"
24 25
25 #include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
26 #include <Core/Logging.h> 26 #include <Core/Logging.h>
27 27
28 static std::auto_ptr<OrthancDatabases::MySQLIndex> backend_; 28 static std::auto_ptr<OrthancDatabases::MySQLIndex> backend_;
29
30
31 static bool DisplayPerformanceWarning()
32 {
33 (void) DisplayPerformanceWarning; // Disable warning about unused function
34 LOG(WARNING) << "Performance warning in MySQL index: "
35 << "Non-release build, runtime debug assertions are turned on";
36 return true;
37 }
38 29
39 30
40 extern "C" 31 extern "C"
41 { 32 {
42 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) 33 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
43 { 34 {
44 Orthanc::Logging::Initialize(context); 35 if (!OrthancDatabases::InitializePlugin
45 36 (context, "MySQL index",
46 assert(DisplayPerformanceWarning()); 37 "Stores the Orthanc index into a MySQL database."))
47
48 /* Check the version of the Orthanc core */
49 if (OrthancPluginCheckVersion(context) == 0)
50 { 38 {
51 char info[1024];
52 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
53 context->orthancVersion,
54 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
55 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
56 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
57 OrthancPluginLogError(context, info);
58 return -1; 39 return -1;
59 } 40 }
60
61 OrthancPluginSetDescription(context, "Stores the Orthanc index into a MySQL database.");
62 41
63 OrthancPlugins::OrthancConfiguration configuration(context); 42 OrthancPlugins::OrthancConfiguration configuration(context);
64 43
65 if (!configuration.IsSection("MySQL")) 44 if (!configuration.IsSection("MySQL"))
66 { 45 {