changeset 4096:d633e5bb7ba3

reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Jul 2020 08:42:21 +0200
parents 1c89208fbba9
children 99e2054d1e8d
files LinuxCompilation.txt OrthancServer/CMakeLists.txt OrthancServer/Plugins/Engine/PluginsEnumerations.h OrthancServer/Sources/Search/DatabaseConstraint.cpp OrthancServer/Sources/Search/DatabaseConstraint.h OrthancServer/Sources/Search/ISqlLookupFormatter.cpp OrthancServer/Sources/Search/ISqlLookupFormatter.h OrthancServer/Sources/ServerEnumerations.h
diffstat 8 files changed, 61 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/LinuxCompilation.txt	Tue Jun 30 17:00:18 2020 +0200
+++ b/LinuxCompilation.txt	Wed Jul 01 08:42:21 2020 +0200
@@ -84,6 +84,7 @@
        	       	       libsqlite3-dev libssl-dev zlib1g-dev libdcmtk2-dev \
                        libboost-all-dev libwrap0-dev libjsoncpp-dev libpugixml-dev
 
+# cd ./Build
 # cmake -DALLOW_DOWNLOADS=ON \
 	-DUSE_SYSTEM_CIVETWEB=OFF \
         -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
@@ -105,6 +106,7 @@
 		       zlib1g-dev libdcmtk2-dev libboost-all-dev libwrap0-dev \
                        libcharls-dev libjsoncpp-dev libpugixml-dev
 
+# cd ./Build
 # cmake -DALLOW_DOWNLOADS=ON \
         -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
         -DUSE_SYSTEM_CIVETWEB=OFF \
@@ -125,6 +127,7 @@
 		       zlib1g-dev libdcmtk-dev libboost-all-dev libwrap0-dev \
                        libcharls-dev libjsoncpp-dev libpugixml-dev tzdata
 
+# cd ./Build
 # cmake -DALLOW_DOWNLOADS=ON \
         -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
         -DUSE_SYSTEM_CIVETWEB=OFF \
@@ -137,6 +140,7 @@
 NB: Instructions to use clang and ninja:
 
 # sudo apt-get install ninja-build
+# cd ./Build
 # CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G Ninja \
         -DALLOW_DOWNLOADS=ON \
         -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
@@ -156,6 +160,7 @@
 		       zlib1g-dev libdcmtk-dev libboost-all-dev libwrap0-dev \
                        libcharls-dev libjsoncpp-dev libpugixml-dev locales
 
+# cd ./Build
 # cmake -DALLOW_DOWNLOADS=ON \
         -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON \
         -DUSE_SYSTEM_CIVETWEB=OFF \
@@ -184,6 +189,7 @@
 
 # sudo yum install gflags-devel
 
+# cd ./Build
 # cmake  "-DDCMTK_LIBRARIES=CharLS" \
          -DENABLE_CIVETWEB=OFF \
          -DSYSTEM_MONGOOSE_USE_CALLBACKS=OFF \
@@ -202,6 +208,7 @@
 # pkg install jsoncpp pugixml lua51 curl googletest dcmtk cmake jpeg \
               e2fsprogs-libuuid boost-libs sqlite3 python libiconv
 
+# cd ./Build
 # cmake -DALLOW_DOWNLOADS=ON \
         -DUSE_SYSTEM_CIVETWEB=OFF \
         -DDCMTK_LIBRARIES="dcmdsig;charls;dcmjpls" \
--- a/OrthancServer/CMakeLists.txt	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/CMakeLists.txt	Wed Jul 01 08:42:21 2020 +0200
@@ -271,6 +271,7 @@
 
 add_definitions(
   -DORTHANC_BUILD_UNIT_TESTS=1
+  -DORTHANC_BUILDING_SERVER_LIBRARY=1
   
   # Macros for the plugins
   -DHAS_ORTHANC_EXCEPTION=0
--- a/OrthancServer/Plugins/Engine/PluginsEnumerations.h	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsEnumerations.h	Wed Jul 01 08:42:21 2020 +0200
@@ -42,8 +42,9 @@
  * "orthanc-databases" project.
  **/
 
+#include "../../Sources/Search/DatabaseConstraint.h"
+#include "../../Sources/ServerEnumerations.h"
 #include "../Include/orthanc/OrthancCPlugin.h"
-#include "../../Sources/Search/DatabaseConstraint.h"
 
 namespace Orthanc
 {
--- a/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.cpp	Wed Jul 01 08:42:21 2020 +0200
@@ -31,11 +31,21 @@
  **/
 
 
-#include "../PrecompiledHeadersServer.h"
+#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
+#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
+#endif
+
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../PrecompiledHeadersServer.h"
+#endif
+
 #include "DatabaseConstraint.h"
 
-#include "../../../OrthancFramework/Sources/OrthancException.h"
-
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../../../OrthancFramework/Sources/OrthancException.h"
+#else
+#  include <OrthancException.h>
+#endif
 
 namespace Orthanc
 {
--- a/OrthancServer/Sources/Search/DatabaseConstraint.h	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.h	Wed Jul 01 08:42:21 2020 +0200
@@ -33,8 +33,16 @@
 
 #pragma once
 
-#include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
-#include "../ServerEnumerations.h"
+#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
+#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
+#endif
+
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h"
+#else
+// This is for the "orthanc-databases" project to reuse this file
+#  include <DicomFormat/DicomMap.h>
+#endif
 
 #define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
 
@@ -50,6 +58,15 @@
 
 namespace Orthanc
 {
+  enum ConstraintType
+  {
+    ConstraintType_Equal,
+    ConstraintType_SmallerOrEqual,
+    ConstraintType_GreaterOrEqual,
+    ConstraintType_Wildcard,
+    ConstraintType_List
+  };
+
   namespace Plugins
   {
 #if ORTHANC_ENABLE_PLUGINS == 1
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp	Wed Jul 01 08:42:21 2020 +0200
@@ -31,10 +31,22 @@
  **/
 
 
-#include "../PrecompiledHeadersServer.h"
+#if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
+#  error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
+#endif
+
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../PrecompiledHeadersServer.h"
+#endif
+
 #include "ISqlLookupFormatter.h"
 
-#include "../../../OrthancFramework/Sources/OrthancException.h"
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../../../OrthancFramework/Sources/OrthancException.h"
+#else
+#  include <OrthancException.h>
+#endif
+
 #include "DatabaseConstraint.h"
 
 namespace Orthanc
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.h	Wed Jul 01 08:42:21 2020 +0200
@@ -33,7 +33,11 @@
 
 #pragma once
 
-#include "../../../OrthancFramework/Sources/Enumerations.h"
+#if ORTHANC_BUILDING_SERVER_LIBRARY == 1
+#  include "../../../OrthancFramework/Sources/Enumerations.h"
+#else
+#  include <Enumerations.h>
+#endif
 
 #include <boost/noncopyable.hpp>
 #include <vector>
--- a/OrthancServer/Sources/ServerEnumerations.h	Tue Jun 30 17:00:18 2020 +0200
+++ b/OrthancServer/Sources/ServerEnumerations.h	Wed Jul 01 08:42:21 2020 +0200
@@ -63,15 +63,6 @@
     DicomTagType_Generic       // Tag that is only stored in the JSON files
   };
 
-  enum ConstraintType
-  {
-    ConstraintType_Equal,
-    ConstraintType_SmallerOrEqual,
-    ConstraintType_GreaterOrEqual,
-    ConstraintType_Wildcard,
-    ConstraintType_List
-  };
-
   namespace Compatibility
   {
     enum IdentifierConstraintType