changeset 388:6aa19614ca20 db-protobuf

implemented protobuf for odbc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Apr 2023 11:14:10 +0200
parents 0fed785e974e
children eb80f7c5e7d8
files Odbc/CMakeLists.txt Odbc/NEWS Odbc/Plugins/IndexPlugin.cpp
diffstat 3 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Odbc/CMakeLists.txt	Mon Apr 03 17:11:24 2023 +0200
+++ b/Odbc/CMakeLists.txt	Wed Apr 05 11:14:10 2023 +0200
@@ -24,14 +24,14 @@
 set(ORTHANC_PLUGIN_VERSION "mainline")
 
 set(ORTHANC_OPTIMAL_VERSION_MAJOR    1)
-set(ORTHANC_OPTIMAL_VERSION_MINOR    9)
-set(ORTHANC_OPTIMAL_VERSION_REVISION 2)
+set(ORTHANC_OPTIMAL_VERSION_MINOR    12)
+set(ORTHANC_OPTIMAL_VERSION_REVISION 0)
 
 if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
   set(ORTHANC_FRAMEWORK_VERSION "mainline")
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
 else()
-  set(ORTHANC_FRAMEWORK_VERSION "1.9.6")
+  set(ORTHANC_FRAMEWORK_VERSION "1.12.0")
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
 endif()
 
@@ -79,6 +79,23 @@
   ODBC_PREPARE_STORAGE  ${CMAKE_SOURCE_DIR}/Plugins/PrepareStorage.sql
   )
 
+if (EXISTS ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto)
+  add_custom_command(
+    COMMAND
+    ${PROTOC_EXECUTABLE} ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto --cpp_out=${AUTOGENERATED_DIR} -I${ORTHANC_SDK_ROOT}/orthanc/
+    DEPENDS
+    ProtobufCompiler
+    ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto
+    OUTPUT
+    ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
+    ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.h
+    )
+
+  list(APPEND AUTOGENERATED_SOURCES
+    ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
+    )
+endif()
+
 add_custom_target(
   AutogeneratedTarget
   DEPENDS 
--- a/Odbc/NEWS	Mon Apr 03 17:11:24 2023 +0200
+++ b/Odbc/NEWS	Wed Apr 05 11:14:10 2023 +0200
@@ -1,6 +1,9 @@
 Pending changes in the mainline
 ===============================
 
+* Compatibility with Orthanc SDK 1.12.0 (communications between the
+  Orthanc core and the database plugin using Google Protocol Buffers)
+
 
 Release 1.1 (2021-12-06)
 ========================
--- a/Odbc/Plugins/IndexPlugin.cpp	Mon Apr 03 17:11:24 2023 +0200
+++ b/Odbc/Plugins/IndexPlugin.cpp	Wed Apr 05 11:14:10 2023 +0200
@@ -42,6 +42,9 @@
 #endif
 
 
+#include <google/protobuf/any.h>
+
+
 static const char* const KEY_ODBC = "Odbc";
 
 
@@ -54,6 +57,8 @@
   
   ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
   {
+    GOOGLE_PROTOBUF_VERIFY_VERSION;
+
     if (!OrthancDatabases::InitializePlugin(context, "ODBC", true))
     {
       return -1;
@@ -130,6 +135,7 @@
   {
     LOG(WARNING) << "ODBC index is finalizing";
     OrthancDatabases::IndexBackend::Finalize();
+    google::protobuf::ShutdownProtobufLibrary();
   }