comparison PostgreSQL/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 9e419261f1c9
children c0cb5d2cd696
comparison
equal deleted inserted replaced
23:b2ff1cd2907a 24:17f849b2af34
17 * You should have received a copy of the GNU Affero General Public License 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/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/ 19 **/
20 20
21 21
22 #include "../../Framework/Plugins/StorageBackend.h"
23 #include "PostgreSQLStorageArea.h" 22 #include "PostgreSQLStorageArea.h"
23 #include "../../Framework/Plugins/PluginInitialization.h"
24 24
25 #include <Core/Logging.h> 25 #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 PostgreSQL storage area: "
32 << "Non-release build, runtime debug assertions are turned on";
33 return true;
34 }
35
36 26
37 extern "C" 27 extern "C"
38 { 28 {
39 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) 29 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
40 { 30 {
41 Orthanc::Logging::Initialize(context); 31 if (!OrthancDatabases::InitializePlugin
42 32 (context, "PostgreSQL storage area",
43 assert(DisplayPerformanceWarning()); 33 "Stores the Orthanc storage area into a PostgreSQL database."))
44
45 /* Check the version of the Orthanc core */
46 if (OrthancPluginCheckVersion(context) == 0)
47 { 34 {
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; 35 return -1;
56 } 36 }
57
58 OrthancPluginSetDescription(context, "Stores the Orthanc storage area into a PostgreSQL database.");
59 37
60 OrthancPlugins::OrthancConfiguration configuration(context); 38 OrthancPlugins::OrthancConfiguration configuration(context);
61 39
62 if (!configuration.IsSection("PostgreSQL")) 40 if (!configuration.IsSection("PostgreSQL"))
63 { 41 {