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

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