changeset 372:b5e2c1e48828 db-protobuf

created branch db-protobuf to take advantage of OrthancPluginRegisterDatabaseBackendV4()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Mar 2023 11:40:07 +0200
parents c1fe28de1bf6
children be7de633695c
files Framework/Plugins/IndexBackend.cpp MySQL/CMakeLists.txt MySQL/NEWS PostgreSQL/CMakeLists.txt PostgreSQL/NEWS Resources/CMake/DatabasesFrameworkParameters.cmake Resources/CMake/DatabasesPluginConfiguration.cmake Resources/CMake/DatabasesPluginParameters.cmake SQLite/CMakeLists.txt
diffstat 9 files changed, 100 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/IndexBackend.cpp	Tue Mar 14 09:08:45 2023 +0100
+++ b/Framework/Plugins/IndexBackend.cpp	Tue Mar 28 11:40:07 2023 +0200
@@ -35,6 +35,13 @@
 #include <OrthancException.h>
 
 
+#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
+#  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0)
+#    include "OrthancDatabasePlugin.pb.h"   // Include protobuf messages
+#  endif
+#endif
+
+
 namespace OrthancDatabases
 {
   static std::string ConvertWildcardToLike(const std::string& query)
@@ -2610,8 +2617,6 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
     }
     
-    bool hasLoadedV3 = false;
-      
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
     if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1)
@@ -2620,16 +2625,13 @@
                    << "and will retry up to " << maxDatabaseRetries << " time(s) in the case of a collision";
       
       OrthancDatabases::DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries);
-      hasLoadedV3 = true;
+      return;
     }
 #  endif
 #endif
 
-    if (!hasLoadedV3)
-    {
-      LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers";
-      OrthancDatabases::DatabaseBackendAdapterV2::Register(backend);
-    }
+    LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers";
+    OrthancDatabases::DatabaseBackendAdapterV2::Register(backend);
   }
 
 
--- a/MySQL/CMakeLists.txt	Tue Mar 14 09:08:45 2023 +0100
+++ b/MySQL/CMakeLists.txt	Tue Mar 28 11:40:07 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()
 
@@ -81,6 +81,24 @@
   MYSQL_CREATE_INSTANCE        ${CMAKE_SOURCE_DIR}/Plugins/CreateInstance.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/MySQL/NEWS	Tue Mar 14 09:08:45 2023 +0100
+++ b/MySQL/NEWS	Tue Mar 28 11:40:07 2023 +0200
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* Compatibility with Orthanc SDK 1.12.0
 * Upgraded dependencies for static builds (notably on Windows and LSB):
   - openssl 3.0.1
 
--- a/PostgreSQL/CMakeLists.txt	Tue Mar 14 09:08:45 2023 +0100
+++ b/PostgreSQL/CMakeLists.txt	Tue Mar 28 11:40:07 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()
 
@@ -84,6 +84,25 @@
   POSTGRESQL_GET_LAST_CHANGE_INDEX  ${CMAKE_SOURCE_DIR}/Plugins/GetLastChangeIndex.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/PostgreSQL/NEWS	Tue Mar 14 09:08:45 2023 +0100
+++ b/PostgreSQL/NEWS	Tue Mar 28 11:40:07 2023 +0200
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* Compatibility with Orthanc SDK 1.12.0
 * Upgraded dependencies for static builds (notably on Windows and LSB):
   - openssl 3.0.1
 
--- a/Resources/CMake/DatabasesFrameworkParameters.cmake	Tue Mar 14 09:08:45 2023 +0100
+++ b/Resources/CMake/DatabasesFrameworkParameters.cmake	Tue Mar 28 11:40:07 2023 +0200
@@ -52,3 +52,7 @@
 set(ENABLE_ODBC_BACKEND OFF)
 set(ENABLE_POSTGRESQL_BACKEND OFF)
 set(ENABLE_SQLITE_BACKEND OFF)
+
+# Interfacing with Orthanc 1.12.0
+set(ENABLE_PROTOBUF ON)
+set(ENABLE_PROTOBUF_COMPILER ON)
--- a/Resources/CMake/DatabasesPluginConfiguration.cmake	Tue Mar 14 09:08:45 2023 +0100
+++ b/Resources/CMake/DatabasesPluginConfiguration.cmake	Tue Mar 28 11:40:07 2023 +0200
@@ -23,35 +23,47 @@
 include(${CMAKE_CURRENT_LIST_DIR}/../Orthanc/CMake/AutoGeneratedCode.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/../Orthanc/Plugins/OrthancPluginsExports.cmake)
 
-
 if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
   if (ORTHANC_SDK_VERSION STREQUAL "0.9.5")
-    include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-0.9.5)
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-0.9.5)
   elseif (ORTHANC_SDK_VERSION STREQUAL "1.4.0")
-    include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.4.0)
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.4.0)
   elseif (ORTHANC_SDK_VERSION STREQUAL "1.5.2")
-    include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.2)
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.2)
   elseif (ORTHANC_SDK_VERSION STREQUAL "1.5.4")
-    include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.4)
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.4)
   elseif (ORTHANC_SDK_VERSION STREQUAL "1.9.2")
-    include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.9.2)
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.9.2)
+  elseif (ORTHANC_SDK_VERSION STREQUAL "1.12.0")
+    set(ORTHANC_SDK_ROOT ${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.12.0)
   elseif (ORTHANC_SDK_VERSION STREQUAL "framework")
     set(tmp ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include/)
     message(${tmp})
     if (NOT EXISTS ${tmp}/orthanc/OrthancCDatabasePlugin.h)
       message(FATAL_ERROR "Your copy of the Orthanc framework doesn't contain the Orthanc plugin SDK")
     endif()    
-    include_directories(${tmp})
+    set(ORTHANC_SDK_ROOT ${tmp})
   else()
     message(FATAL_ERROR "Unsupported version of the Orthanc plugin SDK: ${ORTHANC_SDK_VERSION}")
   endif()
 else ()
-  CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCDatabasePlugin.h HAVE_ORTHANC_H)
+  find_path(ORTHANC_SDK_ROOT orthanc/OrthancCDatabasePlugin.h
+    /usr/include
+    /usr/local/include
+    )
+
+  if (NOT ORTHANC_SDK_ROOT)
+    message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
+  endif()
+  
+  check_include_file(${ORTHANC_SDK_ROOT}/orthanc/OrthancCDatabasePlugin.h HAVE_ORTHANC_H)
   if (NOT HAVE_ORTHANC_H)
     message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
   endif()
 endif()
 
+include_directories(${ORTHANC_SDK_ROOT})
+
 
 if (NOT DEFINED ORTHANC_OPTIMAL_VERSION_MAJOR)
   message(FATAL_ERROR "ORTHANC_OPTIMAL_VERSION_MAJOR is not defined")
--- a/Resources/CMake/DatabasesPluginParameters.cmake	Tue Mar 14 09:08:45 2023 +0100
+++ b/Resources/CMake/DatabasesPluginParameters.cmake	Tue Mar 28 11:40:07 2023 +0200
@@ -26,7 +26,7 @@
 
 # Advanced parameters to fine-tune linking against system libraries
 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
-set(ORTHANC_SDK_VERSION "1.9.2" CACHE STRING "Version of the Orthanc plugin SDK to use, if not using the system version (can be \"0.9.5\", \"1.4.0\", \"1.5.2\", \"1.5.4\", \"1.9.2\" or \"framework\")")
+set(ORTHANC_SDK_VERSION "1.12.0" CACHE STRING "Version of the Orthanc plugin SDK to use, if not using the system version (can be \"0.9.5\", \"1.4.0\", \"1.5.2\", \"1.5.4\", \"1.9.2\", \"1.12.0\" or \"framework\")")
 
 include(${CMAKE_CURRENT_LIST_DIR}/DatabasesFrameworkParameters.cmake)
 
--- a/SQLite/CMakeLists.txt	Tue Mar 14 09:08:45 2023 +0100
+++ b/SQLite/CMakeLists.txt	Tue Mar 28 11:40:07 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()
 
@@ -45,6 +45,23 @@
   SQLITE_PREPARE_INDEX ${CMAKE_SOURCE_DIR}/Plugins/PrepareIndex.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