comparison PostgreSQL/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 0217486720b3
children c0cb5d2cd696
comparison
equal deleted inserted replaced
23:b2ff1cd2907a 24:17f849b2af34
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/ 19 **/
20 20
21 21
22 #include "PostgreSQLIndex.h" 22 #include "PostgreSQLIndex.h"
23 #include "../../Framework/Plugins/PluginInitialization.h"
23 24
24 #include <Core/Logging.h> 25 #include <Core/Logging.h>
25 26
26 static std::auto_ptr<OrthancDatabases::PostgreSQLIndex> backend_; 27 static std::auto_ptr<OrthancDatabases::PostgreSQLIndex> backend_;
27 28
28 29
29
30 static bool DisplayPerformanceWarning()
31 {
32 (void) DisplayPerformanceWarning; // Disable warning about unused function
33 LOG(WARNING) << "Performance warning in PostgreSQL index: "
34 << "Non-release build, runtime debug assertions are turned on";
35 return true;
36 }
37
38
39 extern "C" 30 extern "C"
40 { 31 {
41 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) 32 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
42 { 33 {
43 Orthanc::Logging::Initialize(context); 34 if (!OrthancDatabases::InitializePlugin
44 35 (context, "PostgreSQL index",
45 assert(DisplayPerformanceWarning()); 36 "Stores the Orthanc index into a PostgreSQL database."))
46
47 /* Check the version of the Orthanc core */
48 if (OrthancPluginCheckVersion(context) == 0)
49 { 37 {
50 char info[1024];
51 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
52 context->orthancVersion,
53 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
54 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
55 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
56 OrthancPluginLogError(context, info);
57 return -1; 38 return -1;
58 } 39 }
59
60 OrthancPluginSetDescription(context, "Stores the Orthanc index into a PostgreSQL database.");
61 40
62 OrthancPlugins::OrthancConfiguration configuration(context); 41 OrthancPlugins::OrthancConfiguration configuration(context);
63 42
64 if (!configuration.IsSection("PostgreSQL")) 43 if (!configuration.IsSection("PostgreSQL"))
65 { 44 {