diff --git a/CMake/PackageDepends/MITK_cpprestsdk_Config.cmake b/CMake/PackageDepends/MITK_cpprestsdk_Config.cmake deleted file mode 100644 index 7764cec563..0000000000 --- a/CMake/PackageDepends/MITK_cpprestsdk_Config.cmake +++ /dev/null @@ -1 +0,0 @@ -set(ALL_LIBRARIES cpprestsdk::cpprest) diff --git a/CMakeExternals/ExternalProjectList.cmake b/CMakeExternals/ExternalProjectList.cmake index dfd6ab5826..b72dc68825 100644 --- a/CMakeExternals/ExternalProjectList.cmake +++ b/CMakeExternals/ExternalProjectList.cmake @@ -1,30 +1,29 @@ mitkFunctionAddExternalProject(NAME Poco ON COMPONENTS Foundation Net Util XML Zip) mitkFunctionAddExternalProject(NAME DCMTK ON DOC "EXPERIMENTAL, superbuild only: Use DCMTK in MITK") mitkFunctionAddExternalProject(NAME tinyxml2 ON ADVANCED) mitkFunctionAddExternalProject(NAME GDCM ON ADVANCED) mitkFunctionAddExternalProject(NAME Boost ON NO_CACHE) mitkFunctionAddExternalProject(NAME ANN ON ADVANCED DOC "Use Approximate Nearest Neighbor Library") mitkFunctionAddExternalProject(NAME CppUnit ON ADVANCED DOC "Use CppUnit for unit tests") mitkFunctionAddExternalProject(NAME HDF5 ON ADVANCED) mitkFunctionAddExternalProject(NAME ITK ON NO_CACHE DEPENDS HDF5) mitkFunctionAddExternalProject(NAME VTK ON NO_CACHE) mitkFunctionAddExternalProject(NAME ZLIB OFF ADVANCED) mitkFunctionAddExternalProject(NAME lz4 ON ADVANCED) -mitkFunctionAddExternalProject(NAME cpprestsdk OFF DEPENDS Boost ZLIB ADVANCED) mitkFunctionAddExternalProject(NAME ACVD OFF DOC "Use Approximated Centroidal Voronoi Diagrams") mitkFunctionAddExternalProject(NAME CTK ON DEPENDS Qt6 DCMTK DOC "Use CTK in MITK") mitkFunctionAddExternalProject(NAME DCMQI ON DEPENDS DCMTK ITK DOC "Use dcmqi in MITK") mitkFunctionAddExternalProject(NAME MatchPoint OFF ADVANCED DEPENDS Boost ITK DOC "Use the MatchPoint translation image registration library") mitkFunctionAddExternalProject(NAME nlohmann_json ON ADVANCED) mitkFunctionAddExternalProject(NAME httplib ON DEPENDS ZLIB) if(MITK_USE_Qt6) mitkFunctionAddExternalProject(NAME Qt6Qwt6 ON ADVANCED DEPENDS Qt6) endif() if(UNIX AND NOT APPLE) mitkFunctionAddExternalProject(NAME PCRE OFF ADVANCED NO_PACKAGE) mitkFunctionAddExternalProject(NAME SWIG OFF ADVANCED NO_PACKAGE DEPENDS PCRE) elseif(WIN32) mitkFunctionAddExternalProject(NAME SWIG OFF ADVANCED NO_PACKAGE) endif() diff --git a/CMakeExternals/cpprestsdk.cmake b/CMakeExternals/cpprestsdk.cmake deleted file mode 100644 index 3c172eab55..0000000000 --- a/CMakeExternals/cpprestsdk.cmake +++ /dev/null @@ -1,41 +0,0 @@ -set(proj cpprestsdk) -set(proj_DEPENDENCIES Boost ZLIB) - -if(MITK_USE_${proj}) - set(${proj}_DEPENDS ${proj}) - - if(DEFINED ${proj}_DIR AND NOT EXISTS ${${proj}_DIR}) - message(FATAL_ERROR "${proj}_DIR variable is defined but corresponds to non-existing directory!") - endif() - - if(NOT DEFINED ${proj}_DIR) - set(cmake_cache_args - ${ep_common_cache_args} - -DBUILD_SAMPLES:BOOL=OFF - -DBUILD_TESTS:BOOL=OFF - -DWERROR:BOOL=OFF - ) - - if(OPENSSL_ROOT_DIR) - list(APPEND cmake_cache_args - -DOPENSSL_ROOT_DIR:PATH=${OPENSSL_ROOT_DIR} - ) - endif() - - ExternalProject_Add(${proj} - GIT_REPOSITORY https://github.com/MITK/cpprestsdk.git - GIT_TAG v2.10.19-patched - SOURCE_SUBDIR Release - CMAKE_ARGS - "-DBoost_DIR:PATH=${Boost_DIR}" - ${ep_common_args} - CMAKE_CACHE_ARGS ${cmake_cache_args} - CMAKE_CACHE_DEFAULT_ARGS ${ep_common_cache_default_args} - DEPENDS ${proj_DEPENDENCIES} - ) - - set(${proj}_DIR ${ep_prefix}) - else() - mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") - endif() -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index e08013f181..c6c7a03c1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1415 +1,1404 @@ #[[ When increasing the minimum required version, check if Boost_ADDITIONAL_VERSIONS in CMake/PackageDepends/MITK_Boost_Config.cmake can be removed. See the first long comment in CMakeExternals/Boost.cmake for details. ]] set(MITK_CMAKE_MINIMUM_REQUIRED_VERSION 3.18) cmake_minimum_required(VERSION ${MITK_CMAKE_MINIMUM_REQUIRED_VERSION}) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 AND CMAKE_VERSION VERSION_LESS 3.19.2) message(FATAL_ERROR "\ CMake v${CMAKE_VERSION} is defective [1]. \ Please either downgrade to v3.18 or upgrade to at least v3.19.2.\n\ [1] https://gitlab.kitware.com/cmake/cmake/-/issues/21529") endif() #----------------------------------------------------------------------------- # Policies #----------------------------------------------------------------------------- #[[ T28060 https://cmake.org/cmake/help/v3.18/policy/CMP0091.html https://cmake.org/cmake/help/v3.18/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html We pass CMP0091 to all external projects as command-line argument: -DCMAKE_POLICY_DEFAULT_CMP0091:STRING=OLD ]] cmake_policy(SET CMP0091 OLD) if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) # https://cmake.org/cmake/help/v3.24/policy/CMP0135.html endif() #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) if(MITK_USE_SUPERBUILD) project(MITK-superbuild) set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(MITK VERSION 2024.06.99) include_directories(SYSTEM ${MITK_SUPERBUILD_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # MITK Extension Feature #----------------------------------------------------------------------------- set(MITK_EXTENSION_DIRS "" CACHE STRING "") unset(MITK_ABSOLUTE_EXTENSION_DIRS) foreach(MITK_EXTENSION_DIR ${MITK_EXTENSION_DIRS}) get_filename_component(MITK_ABSOLUTE_EXTENSION_DIR "${MITK_EXTENSION_DIR}" ABSOLUTE) list(APPEND MITK_ABSOLUTE_EXTENSION_DIRS "${MITK_ABSOLUTE_EXTENSION_DIR}") endforeach() set(MITK_DIR_PLUS_EXTENSION_DIRS "${MITK_SOURCE_DIR}" ${MITK_ABSOLUTE_EXTENSION_DIRS}) #----------------------------------------------------------------------------- # Update CMake module path #----------------------------------------------------------------------------- set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake) set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR}) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_CMAKE_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake") if(EXISTS "${MITK_CMAKE_EXTENSION_DIR}") list(APPEND CMAKE_MODULE_PATH "${MITK_CMAKE_EXTENSION_DIR}") endif() endforeach() #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- # Standard CMake macros include(FeatureSummary) include(CTest) include(CMakeParseArguments) include(FindPackageHandleStandardArgs) # MITK macros include(mitkFunctionGetGccVersion) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkMacroEmptyExternalProject) include(mitkFunctionEnableBuildConfiguration) include(mitkFunctionWhitelists) include(mitkFunctionAddExternalProject) include(mitkFunctionAddLibrarySearchPaths) SUPPRESS_VC_DEPRECATED_WARNINGS() #----------------------------------------------------------------------------- # Set a default build type if none was specified #----------------------------------------------------------------------------- if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Debug' as none was specified.") set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) else() set(GCC_VERSION 0) endif() set(MITK_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS 0) set(CMAKE_CXX_STANDARD ${MITK_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED 1) # This is necessary to avoid problems with compile feature checks. # CMAKE_CXX_STANDARD seems to only set the -std=c++ flag for targets. # However, compile flag checks also need to be done with -std=c++. # The MITK_CXX_FLAG variable is also used for external projects # build during the MITK super-build. mitkFunctionCheckCompilerFlags("-std=c++${MITK_CXX_STANDARD}" MITK_CXX${MITK_CXX_STANDARD}_FLAG) #----------------------------------------------------------------------------- # Warn if source or build path is too long #----------------------------------------------------------------------------- if(WIN32) set(_src_dir_length_max 50) set(_bin_dir_length_max 50) if(MITK_USE_SUPERBUILD) set(_src_dir_length_max 34) # _src_dir_length_max - strlen(ep/src/ITK-build) set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build) endif() string(LENGTH "${MITK_SOURCE_DIR}" _src_n) string(LENGTH "${MITK_BINARY_DIR}" _bin_n) # The warnings should be converted to errors if(_src_n GREATER _src_dir_length_max) message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})." "Please move the MITK source code directory to a directory with a shorter path." ) endif() if(_bin_n GREATER _bin_dir_length_max) message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})." "Please move the MITK build directory to a directory with a shorter path." ) endif() endif() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- # ----------------------------------------- # General build options option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) option(MITK_FAST_TESTING "Disable long-running tests like packaging" OFF) option(MITK_XVFB_TESTING "Execute test drivers through xvfb-run" OFF) option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF) option(MITK_BUILD_EXAMPLES "Build the MITK Examples" OFF) mark_as_advanced( MITK_XVFB_TESTING MITK_FAST_TESTING MITK_BUILD_ALL_APPS ) #----------------------------------------------------------------------------- # Set UI testing flags #----------------------------------------------------------------------------- if(MITK_XVFB_TESTING) set(MITK_XVFB_TESTING_COMMAND "xvfb-run" "--auto-servernum" CACHE STRING "Command and options to test through Xvfb") mark_as_advanced(MITK_XVFB_TESTING_COMMAND) endif(MITK_XVFB_TESTING) # ----------------------------------------- # Other options set(MITK_CUSTOM_REVISION_DESC "" CACHE STRING "Override MITK revision description") mark_as_advanced(MITK_CUSTOM_REVISION_DESC) set_property(GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS "") include(CMakeExternals/ExternalProjectList.cmake) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_CMAKE_EXTERNALS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMakeExternals") if(EXISTS "${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake") include("${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake") endif() endforeach() # ----------------------------------------- # Other MITK_USE_* options not related to # external projects build via the # MITK superbuild option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_OpenMP "Use OpenMP" OFF) option(MITK_USE_Python3 "Use Python 3" OFF) #----------------------------------------------------------------------------- # Build configurations #----------------------------------------------------------------------------- set(_buildConfigs "Custom") file(GLOB _buildConfigFiles CMake/BuildConfigurations/*.cmake) foreach(_buildConfigFile ${_buildConfigFiles}) get_filename_component(_buildConfigFile ${_buildConfigFile} NAME_WE) list(APPEND _buildConfigs ${_buildConfigFile}) endforeach() foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) file(GLOB _extBuildConfigFiles "${MITK_EXTENSION_DIR}/CMake/BuildConfigurations/*.cmake") foreach(_extBuildConfigFile ${_extBuildConfigFiles}) get_filename_component(_extBuildConfigFile "${_extBuildConfigFile}" NAME_WE) list(APPEND _buildConfigs "${_extBuildConfigFile}") endforeach() list(REMOVE_DUPLICATES _buildConfigs) endforeach() set(MITK_BUILD_CONFIGURATION "WorkbenchRelease" CACHE STRING "Use pre-defined MITK configurations") set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS ${_buildConfigs}) mitkFunctionEnableBuildConfiguration() mitkFunctionCreateWhitelistPaths(MITK) mitkFunctionFindWhitelists(MITK) # ----------------------------------------- # Qt version related variables option(MITK_USE_Qt6 "Use Qt 6 library" ON) if(MITK_USE_Qt6) set(MITK_QT6_MINIMUM_VERSION 6.6) set(MITK_QT6_COMPONENTS Concurrent Core Core5Compat CoreTools Designer DesignerComponentsPrivate Gui Help LinguistTools Network OpenGL OpenGLWidgets Qml Sql StateMachine Svg ToolsTools UiTools WebEngineCore WebEngineWidgets Widgets Xml ) if(APPLE) list(APPEND MITK_QT6_COMPONENTS DBus) endif() # Hint at default install locations of Qt if(NOT Qt6_DIR) if(MSVC) set(_dir_candidates "C:/Qt") if(CMAKE_GENERATOR MATCHES "^Visual Studio [0-9]+ ([0-9]+)") set(_compilers "msvc${CMAKE_MATCH_1}") elseif(CMAKE_GENERATOR MATCHES "Ninja") include(mitkFunctionGetMSVCVersion) mitkFunctionGetMSVCVersion() if(VISUAL_STUDIO_PRODUCT_NAME MATCHES "^Visual Studio ([0-9]+)") set(_compilers "msvc${CMAKE_MATCH_1}") endif() endif() if(_compilers MATCHES "[0-9]+") if (CMAKE_MATCH_0 EQUAL 2022) list(APPEND _compilers "msvc2019") # Binary compatible endif() endif() else() set(_dir_candidates ~/Qt) if(APPLE) set(_compilers clang) else() list(APPEND _dir_candidates /opt/Qt) set(_compilers gcc) endif() endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) foreach(_compiler ${_compilers}) list(APPEND _compilers64 "${_compiler}_64") endforeach() set(_compilers ${_compilers64}) endif() if(APPLE) list(APPEND _compilers macos) endif() foreach(_dir_candidate ${_dir_candidates}) get_filename_component(_dir_candidate ${_dir_candidate} REALPATH) foreach(_compiler ${_compilers}) set(_glob_expression "${_dir_candidate}/6.*/${_compiler}") file(GLOB _hints ${_glob_expression}) list(SORT _hints) list(APPEND MITK_QT6_HINTS ${_hints}) endforeach() endforeach() endif() find_package(Qt6 ${MITK_QT6_MINIMUM_VERSION} COMPONENTS ${MITK_QT6_COMPONENTS} REQUIRED HINTS ${MITK_QT6_HINTS}) get_target_property(QT_QMAKE_EXECUTABLE Qt6::qmake LOCATION) get_target_property(QT_HELPGENERATOR_EXECUTABLE Qt6::qhelpgenerator LOCATION) endif() if(Qt6_DIR) list(APPEND CMAKE_PREFIX_PATH "${Qt6_DIR}/../../..") list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) endif() # ----------------------------------------- # Custom dependency logic if(WIN32 AND Qt6_DIR) set(_dir_candidate "${Qt6_DIR}/../../../../../Tools/OpenSSLv3/Win_x64") get_filename_component(_dir_candidate ${_dir_candidate} ABSOLUTE) if(EXISTS "${_dir_candidate}") set(OPENSSL_ROOT_DIR "${_dir_candidate}") endif() endif() find_package(OpenSSL 3) if(NOT OpenSSL_FOUND) find_package(OpenSSL 1.1.1) endif() option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF) set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries") -if((MITK_USE_cpprestsdk OR MITK_USE_httplib) AND NOT OpenSSL_FOUND) - set(openssl_message "Could not find OpenSSL (dependency of C++ REST SDK and cpp-httplib).\n") +if(MITK_USE_httplib AND NOT OpenSSL_FOUND) + set(openssl_message "Could not find OpenSSL (dependency of cpp-httplib).\n") if(UNIX) if(APPLE) set(openssl_message "${openssl_message}Please install it using your favorite package management " "system (i.e. Homebrew or MacPorts).\n") else() set(openssl_message "${openssl_message}Please install the dev package of OpenSSL (i.e. libssl-dev).\n") endif() else() set(openssl_message "${openssl_message}Please either install Win32 OpenSSL:\n" " https://slproweb.com/products/Win32OpenSSL.html\n" "Or use the Qt Maintenance tool to install (recommended):\n" " Developer and Designer Tools > OpenSSL Toolkit > OpenSSL 64-bit binaries\n") endif() set(openssl_message "${openssl_message}If it still cannot be found, you can hint CMake to find OpenSSL by " "adding/setting the OPENSSL_ROOT_DIR variable to the root directory of an " "OpenSSL installation. Make sure to clear variables of partly found " "versions of OpenSSL before, or they will be mixed up.") message(FATAL_ERROR ${openssl_message}) endif() -if(MITK_USE_cpprestsdk) - list(APPEND MITK_USE_Boost_LIBRARIES date_time regex system) - - if(UNIX) - list(APPEND MITK_USE_Boost_LIBRARIES atomic chrono filesystem random thread) - endif() - - list(REMOVE_DUPLICATES MITK_USE_Boost_LIBRARIES) - set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "A semi-colon separated list of required Boost libraries" FORCE) -endif() - if(MITK_USE_Python3) set(MITK_USE_ZLIB ON CACHE BOOL "" FORCE) if(APPLE) set(python3_mininum_version 3.11) else() set(python3_mininum_version 3.8) endif() find_package(Python3 ${python3_mininum_version} REQUIRED COMPONENTS Interpreter Development NumPy) if(WIN32) string(REPLACE "\\" "/" Python3_STDARCH "${Python3_STDARCH}") string(REPLACE "\\" "/" Python3_STDLIB "${Python3_STDLIB}") string(REPLACE "\\" "/" Python3_SITELIB "${Python3_SITELIB}") endif() endif() if(BUILD_TESTING AND NOT MITK_USE_CppUnit) message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON") set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE) endif() if(MITK_USE_BLUEBERRY) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() #----------------------------------------------------------------------------- # Pixel type multiplexing #----------------------------------------------------------------------------- # Customize the default pixel types for multiplex macros set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES MITK_ACCESSBYITK_DIMENSIONS ) # consistency checks if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES) set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES) set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES) set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) string(REPLACE "," ";" _integral_types ${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES}) string(REPLACE "," ";" _floating_types ${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES}) foreach(_scalar_type ${_integral_types} ${_floating_types}) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}itk::VariableLengthVector<${_scalar_type}>,") endforeach() string(LENGTH "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" _length) math(EXPR _length "${_length} - 1") string(SUBSTRING "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" 0 ${_length} MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES ${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES} CACHE STRING "List of vector pixel types used in AccessByItk and InstantiateAccessFunction macros for itk::VectorImage types" FORCE) endif() if(NOT MITK_ACCESSBYITK_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() find_package(Git REQUIRED) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") # Print configuration summary message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL) return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # Organize MITK targets in folders #----------------------------------------------------------------------------- set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(MITK_ROOT_FOLDER "MITK" CACHE STRING "") mark_as_advanced(MITK_ROOT_FOLDER) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(WriteBasicConfigVersionFile) include(CheckCXXSourceCompiles) include(GenerateExportHeader) include(mitkFunctionAddManifest) include(mitkFunctionAddCustomModuleTest) include(mitkFunctionCheckModuleDependencies) include(mitkFunctionCompileSnippets) include(mitkFunctionConfigureVisualStudioUserProjectFile) include(mitkFunctionCreateBlueBerryApplication) include(mitkFunctionCreateCommandLineApp) include(mitkFunctionCreateModule) include(mitkFunctionCreatePlugin) include(mitkFunctionCreateProvisioningFile) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionGetVersion) include(mitkFunctionGetVersionDescription) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionInstallCTKPlugin) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallThirdPartyCTKPlugins) include(mitkFunctionOrganizeSources) include(mitkFunctionUseModules) if( ${MITK_USE_MatchPoint} ) include(mitkFunctionCreateMatchPointDeployedAlgorithm) endif() include(mitkMacroConfigureItkPixelTypes) include(mitkMacroCreateExecutable) include(mitkMacroCreateModuleTests) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroMultiplexPicType) #----------------------------------------------------------------------------- # Global CMake variables #----------------------------------------------------------------------------- if(NOT DEFINED CMAKE_DEBUG_POSTFIX) # We can't do this yet because the CTK Plugin Framework # cannot cope with a postfix yet. #set(CMAKE_DEBUG_POSTFIX d) endif() #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- set(_default_LIBRARY_output_dir lib) set(_default_RUNTIME_output_dir bin) set(_default_ARCHIVE_output_dir lib) foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") endif() if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) else() set(CMAKE_${type}_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${_default_${type}_output_dir}) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY}) endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY} CACHE INTERNAL "Output directory for ${type} files.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- if(OpenSSL_FOUND AND WIN32) #[[ On Windows, CMake is able to locate the link libraries for OpenSSL but it does not look for the corresponding DLLs that we need to copy to our binary directories and include in packaging. Setting these paths manually is cumbersome so we try to use a simple heuristic to automatically set them: - Based on the link libraries (usually located in a lib folder), try to find the "../bin" binary directory. - Use the base file names of the link libraries to find corresponding DLLs like "*.dll", that usually are named like "-1_1-x64.dll" or similar. ]] set(openssl_ssl_dll "") set(openssl_crypto_dll "") if(OPENSSL_SSL_LIBRARY AND EXISTS "${OPENSSL_SSL_LIBRARY}") get_filename_component(openssl_bin_dir "${OPENSSL_SSL_LIBRARY}" DIRECTORY) get_filename_component(openssl_bin_dir "${openssl_bin_dir}" DIRECTORY) set(openssl_bin_dir "${openssl_bin_dir}/bin") if(EXISTS "${openssl_bin_dir}") get_filename_component(openssl_ssl_basename "${OPENSSL_SSL_LIBRARY}" NAME_WE) file(GLOB openssl_ssl_dll "${openssl_bin_dir}/${openssl_ssl_basename}*.dll") list(LENGTH openssl_ssl_dll num_findings) if(num_findings GREATER 1) set(openssl_ssl_dll "") endif() get_filename_component(openssl_crypto_basename "${OPENSSL_CRYPTO_LIBRARY}" NAME_WE) file(GLOB openssl_crypto_dll "${openssl_bin_dir}/${openssl_crypto_basename}*.dll") list(LENGTH openssl_crypto_dll num_findings) if(num_findings GREATER 1) set(openssl_crypto_dll "") endif() endif() endif() set(MITK_OPENSSL_SSL_DLL "${openssl_ssl_dll}" CACHE FILEPATH "") if(DEFINED CACHE{MITK_OPENSSL_SSL_DLL} AND NOT MITK_OPENSSL_SSL_DLL AND openssl_ssl_dll) set(MITK_OPENSSL_SSL_DLL "${openssl_ssl_dll}" CACHE FILEPATH "" FORCE) endif() set(MITK_OPENSSL_CRYPTO_DLL "${openssl_crypto_dll}" CACHE FILEPATH "") if(DEFINED CACHE{MITK_OPENSSL_CRYPTO_DLL} AND NOT MITK_OPENSSL_CRYPTO_DLL AND openssl_crypto_dll) set(MITK_OPENSSL_CRYPTO_DLL "${openssl_crypto_dll}" CACHE FILEPATH "" FORCE) endif() if(MITK_OPENSSL_SSL_DLL AND EXISTS "${MITK_OPENSSL_SSL_DLL}" AND MITK_OPENSSL_CRYPTO_DLL AND EXISTS "${MITK_OPENSSL_CRYPTO_DLL}") foreach(config_type ${CMAKE_CONFIGURATION_TYPES}) execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${MITK_BINARY_DIR}/bin/${config_type}") configure_file("${MITK_OPENSSL_SSL_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY) configure_file("${MITK_OPENSSL_CRYPTO_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY) endforeach() MITK_INSTALL(FILES "${MITK_OPENSSL_SSL_DLL}" "${MITK_OPENSSL_CRYPTO_DLL}" ) endif() endif() # Look for optional Doxygen package find_package(Doxygen) option(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF) mark_as_advanced(BLUEBERRY_DEBUG_SMARTPOINTER) # Ask the user to show the console window for applications option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) if(NOT MITK_FAST_TESTING) if(MITK_CTEST_SCRIPT_MODE STREQUAL "Continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "Experimental") set(MITK_FAST_TESTING ON) endif() endif() if(NOT UNIX) set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms") endif() if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() # Configure pixel types used for ITK image access multiplexing mitkMacroConfigureItkPixelTypes() # Configure module naming conventions set(MITK_MODULE_NAME_REGEX_MATCH "^[A-Z].*$") set(MITK_MODULE_NAME_REGEX_NOT_MATCH "^[Mm][Ii][Tt][Kk].*$") set(MITK_DEFAULT_MODULE_NAME_PREFIX "Mitk") set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX}) set(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME 1) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK) # MITK_VERSION set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}") if(MITK_VERSION_PATCH STREQUAL "99") set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}") endif() #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on macOS all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(MITK_USE_BLUEBERRY AND APPLE) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) list(GET target_info_list 0 app_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} Mitk${app_name}) endif() endforeach() endif() endforeach() endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # MITK C/CXX Flags #----------------------------------------------------------------------------- set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}") set(MITK_C_FLAGS_DEBUG ) set(MITK_C_FLAGS_RELEASE ) set(MITK_CXX_FLAGS "${COVERAGE_CXX_FLAGS} ${MITK_CXX${MITK_CXX_STANDARD}_FLAG}") set(MITK_CXX_FLAGS_DEBUG ) set(MITK_CXX_FLAGS_RELEASE ) set(MITK_EXE_LINKER_FLAGS ) set(MITK_SHARED_LINKER_FLAGS ) if(WIN32) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX") mitkFunctionCheckCompilerFlags("/wd4005" MITK_CXX_FLAGS) # warning C4005: macro redefinition mitkFunctionCheckCompilerFlags("/wd4231" MITK_CXX_FLAGS) # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation # the following line should be removed after fixing bug 17637 mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap mitkFunctionCheckCompilerFlags("/wd4180" MITK_CXX_FLAGS) # warning C4180: qualifier applied to function type has no meaning mitkFunctionCheckCompilerFlags("/wd4251" MITK_CXX_FLAGS) # warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' endif() if(APPLE) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DGL_SILENCE_DEPRECATION") # Apple deprecated OpenGL in macOS 10.14 endif() if(NOT MSVC_VERSION) foreach(_flag -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=gnu -Wno-error=unknown-pragmas # The strict-overflow warning is generated by ITK template code -Wno-error=strict-overflow -Woverloaded-virtual -Wstrict-null-sentinel #-Wold-style-cast #-Wsign-promo -Wno-deprecated-copy -Wno-array-bounds -Wno-cast-function-type -Wno-maybe-uninitialized -Wno-error=stringop-overread -fdiagnostics-show-option ) mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS) endforeach() endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS) set(MITK_CXX_FLAGS_RELEASE "-U_FORTIFY_SOURCES -D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}") endif() set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) #----------------------------------------------------------------------------- # MITK Packages #----------------------------------------------------------------------------- set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_PACKAGE_DEPENDS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake/PackageDepends") if(EXISTS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}") list(APPEND MODULES_PACKAGE_DEPENDS_DIRS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}") endif() endforeach() if(NOT MITK_USE_SYSTEM_Boost) set(Boost_NO_SYSTEM_PATHS 1) endif() set(Boost_USE_MULTITHREADED 1) set(Boost_USE_STATIC_LIBS 0) set(Boost_USE_STATIC_RUNTIME 0) set(Boost_ADDITIONAL_VERSIONS 1.74 1.74.0) # We need this later for a DCMTK workaround set(_dcmtk_dir_orig ${DCMTK_DIR}) # This property is populated at the top half of this file get_property(MITK_EXTERNAL_PROJECTS GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(MITK_USE_${ep} AND _package) if(_components) find_package(${_package} COMPONENTS ${_components} REQUIRED CONFIG) else() # Prefer config mode first because it finds external # Config.cmake files pointed at by _DIR variables. # Otherwise, existing Find.cmake files could fail. if(DEFINED ${_package}_DIR) #we store the information because it will be overwritten by find_package #and would get lost for all EPs that use on Find.cmake instead of config #files. set(_temp_EP_${_package}_dir ${${_package}_DIR}) endif(DEFINED ${_package}_DIR) find_package(${_package} QUIET CONFIG) string(TOUPPER "${_package}" _package_uc) if(NOT (${_package}_FOUND OR ${_package_uc}_FOUND)) if(DEFINED _temp_EP_${_package}_dir) set(${_package}_DIR ${_temp_EP_${_package}_dir} CACHE PATH "externally set dir of the package ${_package}" FORCE) endif(DEFINED _temp_EP_${_package}_dir) find_package(${_package} REQUIRED) endif() endif() endif() endforeach() # Ensure that the MITK CMake module path comes first set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) if(MITK_USE_DCMTK) if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*") # Help our FindDCMTK.cmake script find our super-build DCMTK set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) else() # Use the original value set(DCMTK_DIR ${_dcmtk_dir_orig}) endif() endif() if(MITK_USE_DCMQI) # Due to the preferred CONFIG mode in find_package calls above, # the DCMQIConfig.cmake file is read, which does not provide useful # package information. We explicitly need MODULE mode to find DCMQI. # Help our FindDCMQI.cmake script find our super-build DCMQI set(DCMQI_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) find_package(DCMQI REQUIRED) endif() if(MITK_USE_OpenMP) find_package(OpenMP REQUIRED COMPONENTS CXX) else() find_package(OpenMP QUIET COMPONENTS CXX) if(OpenMP_FOUND) set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE) elseif(APPLE AND OpenMP_libomp_LIBRARY AND NOT OpenMP_CXX_LIB_NAMES) set(OpenMP_CXX_LIB_NAMES libomp CACHE STRING "" FORCE) get_filename_component(openmp_lib_dir "${OpenMP_libomp_LIBRARY}" DIRECTORY) set(openmp_include_dir "${openmp_lib_dir}/../include") if(EXISTS "${openmp_include_dir}") get_filename_component(openmp_include_dir "${openmp_include_dir}" REALPATH) set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${openmp_include_dir}" CACHE STRING "" FORCE) find_package(OpenMP QUIET COMPONENTS CXX) if(OpenMP_FOUND) set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE) endif() endif() endif() endif() # Qt support if(MITK_USE_Qt6) if(MITK_USE_BLUEBERRY) option(BLUEBERRY_USE_QT_HELP "Enable support for integrating plugin documentation into Qt Help" ${DOXYGEN_FOUND}) mark_as_advanced(BLUEBERRY_USE_QT_HELP) # Sanity checks for in-application BlueBerry plug-in help generation if(BLUEBERRY_USE_QT_HELP) set(_force_blueberry_use_qt_help_to_off 0) if(NOT DOXYGEN_FOUND) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen was not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.7) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT QT_HELPGENERATOR_EXECUTABLE) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because QT_HELPGENERATOR_EXECUTABLE is empty.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT MITK_USE_Qt6) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because MITK_USE_Qt6 is OFF.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(_force_blueberry_use_qt_help_to_off) set(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating plugin documentation into Qt Help" FORCE) endif() endif() if(BLUEBERRY_QT_HELP_REQUIRED AND NOT BLUEBERRY_USE_QT_HELP) message(FATAL_ERROR "BLUEBERRY_USE_QT_HELP is required to be set to ON") endif() endif() endif() #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch (const std::exception& e) { fprintf(stderr, \"%s\\n\", e.what()); return EXIT_FAILURE; } catch (...) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; }") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() # Test the package target include(mitkPackageTest) endif() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) #----------------------------------------------------------------------------- # MITK_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild. # In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR) set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Set C/CXX and linker flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}") #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- add_subdirectory(Utilities) add_subdirectory(Modules) include("${CMAKE_CURRENT_SOURCE_DIR}/Modules/ModuleList.cmake") mitkFunctionWhitelistModules(MITK MITK_MODULES) set(MITK_ROOT_FOLDER_BACKUP "${MITK_ROOT_FOLDER}") foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) get_filename_component(MITK_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME) set(MITK_MODULES_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Modules") if(EXISTS "${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake") set(MITK_MODULES "") include("${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake") foreach(mitk_module ${MITK_MODULES}) add_subdirectory("${MITK_MODULES_EXTENSION_DIR}/${mitk_module}" "Modules/${mitk_module}") endforeach() endif() set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX}) endforeach() set(MITK_ROOT_FOLDER "${MITK_ROOT_FOLDER_BACKUP}") add_subdirectory(Wrapping) set(MITK_DOXYGEN_OUTPUT_DIR "${PROJECT_BINARY_DIR}/Documentation/Doxygen" CACHE PATH "Output directory for doxygen generated documentation.") if(MITK_USE_BLUEBERRY) include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") mitkFunctionWhitelistPlugins(MITK MITK_PLUGINS) set(mitk_plugins_fullpath "") foreach(mitk_plugin ${MITK_PLUGINS}) list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin}) endforeach() set(MITK_PLUGIN_REGEX_LIST "") foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_PLUGINS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Plugins") if(EXISTS "${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake") set(MITK_PLUGINS "") include("${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake") foreach(mitk_plugin ${MITK_PLUGINS}) list(APPEND mitk_plugins_fullpath "${MITK_PLUGINS_EXTENSION_DIR}/${mitk_plugin}") endforeach() endif() endforeach() if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake) include(${MITK_PRIVATE_MODULES}/PluginList.cmake) foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS}) list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin}) endforeach() endif() if(MITK_BUILD_EXAMPLES) include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake") set(mitk_example_plugins_fullpath ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) endforeach() endif() # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$") set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb MITK_PLUGIN_REGEX_LIST OUTPUT_VARIABLE ${varname}) endmacro() # Get infos about application directories and build options set(mitk_apps_fullpath "") foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 directory_name) list(GET target_info_list 1 option_name) if(${option_name}) list(APPEND mitk_apps_fullpath "${MITK_APPLICATIONS_EXTENSION_DIR}/${directory_name}^^${option_name}") endif() endforeach() endif() endforeach() if (mitk_plugins_fullpath) ctkMacroSetupPlugins(${mitk_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ APPS ${mitk_apps_fullpath} BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) endif() set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake") if(${PROJECT_NAME}_PLUGIN_LIBRARIES) ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE}) else() file(REMOVE ${MITK_PLUGIN_USE_FILE}) set(MITK_PLUGIN_USE_FILE ) endif() endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS) set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS) set(MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS "${MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS} \"${MITK_EXTENSION_DIR}\"") set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS "${MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS} \"${MITK_EXTENSION_DIR}\"") # MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS should be modified by MITK extensions as needed endforeach() if(DOXYGEN_FOUND) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_DOCUMENTATION_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Documentation") file(GLOB MITK_DOCUMENTATION_EXTENSION_FILES CONFIGURE_DEPENDS "${MITK_DOCUMENTATION_EXTENSION_DIR}/*.cmake") foreach(doc_file ${MITK_DOCUMENTATION_EXTENSION_FILES}) include("${doc_file}") endforeach() endforeach() # Transform list of example paths into space-separated string of quoted paths unset(example_paths) foreach(example_path ${MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS}) set(example_paths "${example_paths} \"${example_path}\"") endforeach() set(MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS "${example_paths}") add_subdirectory(Documentation) endif() #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables # These are the default variables, which can be overwritten ( see below ) include(mitkSetupCPack) set(use_default_config ON) set(ALL_MITK_APPS "") set(activated_apps_no 0) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 directory_name) list(GET target_info_list 1 option_name) list(GET target_info_list 2 executable_name) list(APPEND ALL_MITK_APPS "${MITK_EXTENSION_DIR}/Applications/${directory_name}^^${option_name}^^${executable_name}") if(${option_name} OR MITK_BUILD_ALL_APPS) MATH(EXPR activated_apps_no "${activated_apps_no} + 1") endif() endforeach() endif() endforeach() list(LENGTH ALL_MITK_APPS app_count) if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS)) # Corner case if there is only one app in total set(use_project_cpack ON) elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS) # Only one app is enabled (no "build all" flag set) set(use_project_cpack ON) else() # Less or more then one app is enabled set(use_project_cpack OFF) endif() foreach(mitk_app ${ALL_MITK_APPS}) # extract target_dir and option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 target_dir) list(GET target_info_list 1 option_name) list(GET target_info_list 2 executable_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) # check whether application specific configuration files will be used if(use_project_cpack) # use files if they exist if(EXISTS "${target_dir}/CPackOptions.cmake") include("${target_dir}/CPackOptions.cmake") endif() if(EXISTS "${target_dir}/CPackConfig.cmake.in") set(CPACK_PROJECT_CONFIG_FILE "${target_dir}/CPackConfig.cmake") configure_file(${target_dir}/CPackConfig.cmake.in ${CPACK_PROJECT_CONFIG_FILE} @ONLY) set(use_default_config OFF) endif() endif() # add link to the list list(APPEND CPACK_CREATE_DESKTOP_LINKS "${executable_name}") endif() endforeach() # if no application specific configuration file was used, use default if(use_default_config) configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") endif() # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- # ---------------- Export targets ----------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) set(targets_to_export) get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS) if(module_targets) list(APPEND targets_to_export ${module_targets}) endif() if(MITK_USE_BLUEBERRY) if(MITK_PLUGIN_LIBRARIES) list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES}) endif() endif() export(TARGETS ${targets_to_export} APPEND FILE ${MITK_EXPORTS_FILE}) set(MITK_EXPORTED_TARGET_PROPERTIES ) foreach(target_to_export ${targets_to_export}) get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS) if(autoload_targets) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")") endif() get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY) if(autoload_dir) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")") endif() get_target_property(deprecated_module ${target_to_export} MITK_MODULE_DEPRECATED_SINCE) if(deprecated_module) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_MODULE_DEPRECATED_SINCE \"${deprecated_module}\")") endif() endforeach() # ---------------- External projects ----------------- get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) set(MITK_CONFIG_EXTERNAL_PROJECTS ) #string(REPLACE "^^" ";" _mitk_external_projects ${MITK_EXTERNAL_PROJECTS}) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} set(MITK_USE_${ep} ${MITK_USE_${ep}}) set(MITK_${ep}_DIR \"${${ep}_DIR}\") set(MITK_${ep}_COMPONENTS ${_components}) ") endforeach() foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(_components) set(_components_arg COMPONENTS \${_components}) else() set(_components_arg) endif() if(_package) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} if(MITK_USE_${ep}) set(${ep}_DIR \${MITK_${ep}_DIR}) if(MITK_${ep}_COMPONENTS) mitkMacroFindDependency(${_package} COMPONENTS \${MITK_${ep}_COMPONENTS}) else() mitkMacroFindDependency(${_package}) endif() endif()") endif() endforeach() # ---------------- Tools ----------------- configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) # ---------------- Configure files ----------------- configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion) #----------------------------------------------------------------------------- # MITK Applications #----------------------------------------------------------------------------- # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Applications) if(MSVC AND TARGET MitkWorkbench) set_directory_properties(PROPERTIES VS_STARTUP_PROJECT MitkWorkbench) endif() foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/CMakeLists.txt") add_subdirectory("${MITK_APPLICATIONS_EXTENSION_DIR}" "Applications") endif() endforeach() #----------------------------------------------------------------------------- # MITK Examples #----------------------------------------------------------------------------- if(MITK_BUILD_EXAMPLES) # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Examples) endif() #----------------------------------------------------------------------------- # Print configuration summary #----------------------------------------------------------------------------- message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL ) diff --git a/Documentation/Doxygen/3-DeveloperManual/MITKModuleManualsList.dox b/Documentation/Doxygen/3-DeveloperManual/MITKModuleManualsList.dox index 81e21568b8..e5b9cb45b2 100644 --- a/Documentation/Doxygen/3-DeveloperManual/MITKModuleManualsList.dox +++ b/Documentation/Doxygen/3-DeveloperManual/MITKModuleManualsList.dox @@ -1,11 +1,10 @@ /** \page MITKModuleManualsList List of Module Manuals \li \subpage AnnotationModulePage \li \subpage ChartModule \li \subpage LegacyGLModule \li \subpage mitkPython_Overview - \li \subpage RESTModule */ diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox index 1a2190b2e0..b383f62666 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox @@ -1,95 +1,95 @@ /** \page thirdpartylibs Third-party libraries The following third-party libraries can be used with MITK by default and can, in part, be automatically downloaded during superbuild. \par ACVD https://www.creatis.insa-lyon.fr/~valette/public/project/acvd/ \par ANN https://www.cs.umd.edu/~mount/ANN/ \par Boost https://www.boost.org/ -\par C++ REST SDK +\par cpp-httplib -https://github.com/Microsoft/cpprestsdk/ +https://github.com/yhirose/cpp-httplib \par CppUnit https://sourceforge.net/projects/cppunit/ \par CTK https://commontk.org/ \par DCMTK https://dicom.offis.de/dcmtk \par GDCM https://gdcm.sourceforge.net/ \par HDF5 https://support.hdfgroup.org/HDF5/ \par ITK https://itk.org/ \par JSON for Modern C++ https://github.com/nlohmann/json \par lz4 https://github.com/lz4/lz4 \par MatchPoint https://www.dkfz.de/en/sidt/projects/MatchPoint/info.html \par PCRE https://www.pcre.org/ \par POCO https://pocoproject.org/ \par Python https://www.python.org/ \par Qt https://www.qt.io/ \par Qwt https://qwt.sourceforge.io/ \par SWIG https://www.swig.org/ \par TinyXML-2 https://www.grinninglizard.com/tinyxml2/ \par VTK https://vtk.org/ \par zlib https://zlib.net/ For copyright information on any of the above toolkits see the corresponding home page or the corresponding source folder. */ diff --git a/Documentation/Doxygen/3-DeveloperManual/Toolkit/ModuleManuals/MITKModuleManualsList.dox b/Documentation/Doxygen/3-DeveloperManual/Toolkit/ModuleManuals/MITKModuleManualsList.dox index d30358657b..b8cafb4a07 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Toolkit/ModuleManuals/MITKModuleManualsList.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Toolkit/ModuleManuals/MITKModuleManualsList.dox @@ -1,29 +1,28 @@ /** \page MITKModuleManualsListPage MITK Module Manuals Overview The modules are shared libraries that provide functionality that can be used by developers. \subpage MITKModuleManualsList List of Module Manuals
  • \ref AnnotationModulePage
  • \ref ChartModule
  • \ref LegacyGLModule
  • \ref mitkPython_Overview -
  • \ref RESTModule
\subpage MITKModuleManualsListPageAdditionalInformation Additional Information on Certain Modules
  • \ref PlanarPropertiesPage
\subpage MITKMigrationGuides Migration Guides
  • \ref GeometryMigration
  • \ref InteractionMigration
  • \ref OverlayMigration
*/ diff --git a/Modules/DICOMweb/CMakeLists.txt b/Modules/DICOMweb/CMakeLists.txt deleted file mode 100644 index 75c9941b05..0000000000 --- a/Modules/DICOMweb/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -mitk_create_module(DEPENDS MitkCore - MitkREST) - diff --git a/Modules/DICOMweb/files.cmake b/Modules/DICOMweb/files.cmake deleted file mode 100644 index adba99da21..0000000000 --- a/Modules/DICOMweb/files.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CPP_FILES - mitkDICOMweb.cpp -) diff --git a/Modules/DICOMweb/include/mitkDICOMweb.h b/Modules/DICOMweb/include/mitkDICOMweb.h deleted file mode 100644 index 2b3d02f30c..0000000000 --- a/Modules/DICOMweb/include/mitkDICOMweb.h +++ /dev/null @@ -1,137 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkDICOMweb_h -#define mitkDICOMweb_h - -#include - -#include "cpprest/asyncrt_utils.h" -#include "cpprest/http_client.h" -#include -#include -#include -#include - -#include -#include - -/** - * @brief This class represents the implementation of the RESTful DICOMweb standard - * (https://dicom.nema.org/medical/dicom/current/output/html/part18.html). It is used to communicate DICOM data over HTTP - * to a DICOMweb enabled PACS server. - * - * @author Tobias Stein - */ - -namespace mitk -{ - - class MITKDICOMWEB_EXPORT DICOMweb - { - public: - typedef web::http::uri_builder MitkUriBuilder; - typedef web::http::http_request MitkRequest; - typedef web::http::http_response MitkResponse; - typedef web::http::methods MitkRESTMethods; - - DICOMweb(); - - /** - * @brief Creates a DICOMweb service instance which allow basic DICOM operations on the given base URI. - * - * @param baseURI the uri for the PACS server: for example a dcm4chee - * https:///dcm4chee-arc/aets/DCM4CHEE/ - */ - DICOMweb(utility::string_t baseURI); - - /** - * @brief Sends a STOW request with the file in the given path to the study given bei its UID. - * - * @param filePath the path to a valid DICOM file which should be send - * @param studyUID the DICOM study uid - * @return the task to wait for - */ - pplx::task SendSTOW(utility::string_t filePath, utility::string_t studyUID); - - /** - * @brief Sends a WADO request for an DICOM object instance matching the given uid parameters and stores it at the - * given file path. - * - * @param filePath the path at which the retrieved DICOM object instance will be stored - * @param studyUID the DICOM study uid - * @param seriesUID the DICOM series uid - * @param instanceUID the DICOM instance uid - * @return the task to wait for, which unfolds no value when finished - */ - pplx::task SendWADO(utility::string_t filePath, - utility::string_t studyUID, - utility::string_t seriesUID, - utility::string_t instanceUID); - - /** - * @brief Sends a WADO request for an DICOM object series matching the given uid parameters and stores all the - * containing instances at the given folder path. - * - * @param folderPath the path at which the retrieved DICOM object instances of the retrieved series will be stored - * @param studyUID the DICOM study uid - * @param seriesUID the DICOM series uid - * @return the task to wait for, which unfolds the name of the first DICOM object file within the folder path - */ - pplx::task SendWADO(utility::string_t folderPath, - utility::string_t studyUID, - utility::string_t seriesUID); - - /** - * @brief Sends a QIDO request containing the given parameters to filter the query. - * - * Example Map: - * - * mitk::RESTUtil::ParamMap seriesInstancesParams; - * seriesInstancesParams.insert(mitk::RESTUtil::ParamMap::value_type(U("limit"), U("1"))); - * - * - * @param map the map of parameters to filter the query - * @return the task to wait for, which unfolds the result JSON response for the request when finished - */ - pplx::task SendQIDO(mitk::RESTUtil::ParamMap map); - - private: - /** - * @brief Creates a QIDO request URI with the given parameter map - */ - utility::string_t CreateQIDOUri(mitk::RESTUtil::ParamMap map); - - /** - * @brief Creates a WADO request URI with the given parameter - */ - utility::string_t CreateWADOUri(utility::string_t studyUID, - utility::string_t seriesUID, - utility::string_t instanceUID); - - /** - * @brief Creates a STOW request URI with the study uid - */ - utility::string_t CreateSTOWUri(utility::string_t studyUID); - - /** - * @brief Initializes the rest manager for this service instance. Should be called in constructor to make sure the - * public API can work properly. - */ - void InitializeRESTManager(); - - utility::string_t m_BaseURI; - mitk::IRESTManager *m_RESTManager; - }; -} - -#endif diff --git a/Modules/DICOMweb/src/mitkDICOMweb.cpp b/Modules/DICOMweb/src/mitkDICOMweb.cpp deleted file mode 100644 index d58a294b0c..0000000000 --- a/Modules/DICOMweb/src/mitkDICOMweb.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkDICOMweb.h" - -mitk::DICOMweb::DICOMweb() {} - -mitk::DICOMweb::DICOMweb(utility::string_t baseURI) : m_BaseURI(baseURI) -{ - MITK_INFO << "base uri: " << mitk::RESTUtil::convertToUtf8(m_BaseURI); - InitializeRESTManager(); -} - -utility::string_t mitk::DICOMweb::CreateQIDOUri(mitk::RESTUtil::ParamMap map) -{ - MitkUriBuilder queryBuilder(m_BaseURI + U("rs/instances")); - - for (auto const &element : map) - { - queryBuilder.append_query(element.first, element.second); - } - - return queryBuilder.to_string(); -} - -utility::string_t mitk::DICOMweb::CreateWADOUri(utility::string_t studyUID, - utility::string_t seriesUID, - utility::string_t instanceUID) -{ - MitkUriBuilder builder(m_BaseURI + U("wado")); - builder.append_query(U("requestType"), U("WADO")); - builder.append_query(U("studyUID"), studyUID); - builder.append_query(U("seriesUID"), seriesUID); - builder.append_query(U("objectUID"), instanceUID); - builder.append_query(U("contentType"), U("application/dicom")); - - return builder.to_string(); -} - -utility::string_t mitk::DICOMweb::CreateSTOWUri(utility::string_t studyUID) -{ - MitkUriBuilder builder(m_BaseURI + U("rs/studies")); - builder.append_path(studyUID); - return builder.to_string(); -} - -pplx::task mitk::DICOMweb::SendSTOW(utility::string_t filePath, utility::string_t studyUID) -{ - auto uri = CreateSTOWUri(studyUID); - - // this is the working stow-rs request which supports just one dicom file packed into a multipart message - std::ifstream input(filePath, std::ios::binary); - if (!input) - { - MITK_WARN << "could not read file to POST"; - return pplx::task(); - } - - std::vector result; - std::vector buffer; - - // Stop eating new lines in binary mode!!! - input.unsetf(std::ios::skipws); - - input.seekg(0, std::ios::end); - const std::streampos fileSize = input.tellg(); - input.seekg(0, std::ios::beg); - - MITK_INFO << fileSize << " bytes will be sent."; - buffer.reserve(fileSize); // file size - std::copy( - std::istream_iterator(input), std::istream_iterator(), std::back_inserter(buffer)); - - // in future more than one file should also be supported.. - std::string head = ""; - head += "\r\n--boundary"; - head += "\r\nContent-Type: " + mitk::RESTUtil::convertToUtf8(U("application/dicom")) + "\r\n\r\n"; - - std::vector bodyVector(head.begin(), head.end()); - - std::string tail = ""; - tail += "\r\n--boundary--"; - - result.insert(result.end(), bodyVector.begin(), bodyVector.end()); - result.insert(result.end(), buffer.begin(), buffer.end()); - result.insert(result.end(), tail.begin(), tail.end()); - - mitk::RESTUtil::ParamMap headers; - headers.insert(mitk::RESTUtil::ParamMap::value_type( - U("Content-Type"), U("multipart/related; type=\"application/dicom\"; boundary=boundary"))); - - try - { - return m_RESTManager->SendBinaryRequest(uri, mitk::IRESTManager::RequestType::Post, &result, headers) - .then([=](web::json::value result) { - MITK_INFO << "after send"; - MITK_INFO << mitk::RESTUtil::convertToUtf8(result.serialize()); - result.is_null(); - }); - } - catch (std::exception &e) - { - MITK_WARN << e.what(); - } - - return pplx::task(); -} - -pplx::task mitk::DICOMweb::SendWADO(utility::string_t filePath, - utility::string_t studyUID, - utility::string_t seriesUID, - utility::string_t instanceUID) -{ - auto uri = CreateWADOUri(studyUID, seriesUID, instanceUID); - - // don't want return something - try - { - return m_RESTManager->SendJSONRequest(uri, mitk::IRESTManager::RequestType::Get, nullptr, {}, filePath) - .then([=](web::json::value result) { result.is_null(); }); - } - catch (const mitk::Exception &e) - { - mitkThrow() << e.what(); - } -} - -pplx::task mitk::DICOMweb::SendWADO(utility::string_t folderPath, - utility::string_t studyUID, - utility::string_t seriesUID) -{ - mitk::RESTUtil::ParamMap seriesInstances; - seriesInstances.insert(mitk::RESTUtil::ParamMap::value_type(U("StudyInstanceUID"), studyUID)); - seriesInstances.insert(mitk::RESTUtil::ParamMap::value_type(U("SeriesInstanceUID"), seriesUID)); - - return SendQIDO(seriesInstances).then([=](web::json::value jsonResult) -> pplx::task { - auto jsonListResult = jsonResult; - auto resultArray = jsonListResult.as_array(); - - auto firstFileName = std::string(); - - std::vector> tasks; - - for (unsigned short i = 0; i < resultArray.size(); i++) - { - try - { - auto firstResult = resultArray[i]; - auto sopInstanceUIDKey = firstResult.at(U("00080018")); - auto sopInstanceObject = sopInstanceUIDKey.as_object(); - auto valueKey = sopInstanceObject.at(U("Value")); - auto valueArray = valueKey.as_array(); - auto sopInstanceUID = valueArray[0].as_string(); - - auto fileName = utility::string_t(sopInstanceUID).append(U(".dcm")); - - // save first file name as result to load series - if (i == 0) - { - firstFileName = utility::conversions::to_utf8string(fileName); - } - - auto filePath = utility::string_t(folderPath).append(fileName); - auto task = SendWADO(filePath, studyUID, seriesUID, sopInstanceUID); - tasks.push_back(task); - } - catch (const web::json::json_exception &e) - { - MITK_ERROR << e.what(); - mitkThrow() << e.what(); - } - } - - auto joinTask = pplx::when_all(begin(tasks), end(tasks)); - - auto returnTask = joinTask.then([=](void) -> std::string { - auto folderPathUtf8 = utility::conversions::to_utf8string(folderPath); - auto result = folderPathUtf8 + firstFileName; - - return result; - }); - - return returnTask; - }); -} - -pplx::task mitk::DICOMweb::SendQIDO(mitk::RESTUtil::ParamMap map) -{ - auto uri = CreateQIDOUri(map); - - mitk::RESTUtil::ParamMap headers; - headers.insert(mitk::RESTUtil::ParamMap::value_type(U("Accept"), U("application/json"))); - return m_RESTManager->SendJSONRequest(uri, mitk::IRESTManager::RequestType::Get, nullptr, headers); -} - -void mitk::DICOMweb::InitializeRESTManager() -{ - auto *context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - m_RESTManager = managerService; - } - } -} diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 117970cb92..54ad857bcd 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,62 +1,59 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(MITK_MODULES Log Core CommandLine CoreCmdApps AppUtil LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOM DICOMQI DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel Chart ImageStatistics ContourModel SurfaceInterpolation BoundingShape Segmentation QtWidgets QtWidgetsExt ImageStatisticsUI SegmentationUI MatchPointRegistration MatchPointRegistrationUI Classification QtOverlays DICOMUI Remeshing Python QtPython Persistence RT RTUI IOExt XNAT RenderWindowManagerUI CEST BasicImageProcessing ModelFit ModelFitUI Pharmacokinetics PharmacokineticsUI DICOMPM - REST - RESTService - DICOMweb ROI ) diff --git a/Modules/REST/CMakeLists.txt b/Modules/REST/CMakeLists.txt deleted file mode 100644 index 61b6633c19..0000000000 --- a/Modules/REST/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -set(boost_depends "Boost|date_time+regex+system") - -if(UNIX) - set(boost_depends "${boost_depends}+atomic+chrono+filesystem+random+thread") -endif() - -mitk_create_module( - DEPENDS MitkCore - PACKAGE_DEPENDS PUBLIC cpprestsdk OpenSSL|SSL ${boost_depends} -) - -if(TARGET ${MODULE_TARGET}) - if(MSVC) - #[[ Compiler warnings/errors because of C++ REST SDK's http_msg.h on Visual Studio 2022 version 17.8: - - 'stdext::checked_array_iterator': warning STL4043: stdext::checked_array_iterator, - stdext::unchecked_array_iterator, and related factory functions are non-Standard extensions - and will be removed in the future. std::span (since C++20) and gsl::span can be used instead. - You can define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING or _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS - to suppress this warning. - ]] - target_compile_definitions(${MODULE_TARGET} PUBLIC _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) - endif() - - add_subdirectory(test) -endif() diff --git a/Modules/REST/documentation/REST.dox b/Modules/REST/documentation/REST.dox deleted file mode 100644 index 9f49f002a1..0000000000 --- a/Modules/REST/documentation/REST.dox +++ /dev/null @@ -1,194 +0,0 @@ -/** - -\page RESTModule REST Module - -\tableofcontents - -\section REST_brief Description -The MITK REST Module is able to manage REST requests. The main class is the RESTManager. -It is a MicroServices which can be accessed via -\code{.cpp} -auto *context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - //call the function you need from the service - } - } -\endcode - -\subsection REST_Technical Technical background - - The module uses the Microsoft C++ REST SDK for REST mechanisms as well as JSON conversion and asynchronic programming. - -\section Use_REST How to use the REST Module - -You can use the REST module from two different perspectives in MITK: - -
    -
  1. The Server view (receive requests from clients) -
  2. The Client view (send requests to servers) -
- -The following sections will give you an introduction on how to use which of those roles: - -\subsection Server_Use Use from a Server perspective -To act as a server, you need to implement the IRESTObserver, which has a Notify() method that has to be implemented. -In this Notify() method you specify how you want to react to incoming requests and with which data you want to respond to the requests. - -You can then start listening for requests from clients as shown below: - -\code{.cpp} -auto *context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - managerService->ReceiveRequests(uri /*specify your uri which you want to receive requests for*/, this); - } - } -\endcode - -If a client sends a request, the Notify method is called and a response is sent. By now, only GET-requests from clients are supported. - -If you want to stop listening for requests you can do this by calling - -\code{.cpp} -auto *context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - managerService->HandleDeleteObserver(this, uri); - } - } -\endcode - -You don't have to specify a uri in the HandleDeleteObserver method, if you only call managerService->HandleDeleteObserver(this);, all uris you receive requests for are deleted and you aren't listening to any requests anymore. - -\subsection Client_Use Use from a Client perspective - -The following example shows how to send requests from a client perspective: - -\code{.cpp} - //Get the microservice - auto *context = us::ModuleRegistry::GetModule(1)->GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - //Call the send request method which starts the actual request - managerService - ->SendRequest(U("https://jsonplaceholder.typicode.com/posts/1")) - .then([=](pplx::task resultTask)/*It is important to use task-based continuation*/ { - try - { - //Get the result of the request - //This will throw an exception if the ascendent task threw an exception (e.g. invalid URI) - web::json::value result = resultTask.get(); - //Do something with the result (e.g. convert it to a QString to update an UI element) - utility::string_t stringT = result.to_string(); - std::string stringStd(stringT.begin(), stringT.end()); - QString stringQ = QString::fromStdString(stringStd); - //Note: if you want to update your UI, do this by using signals and slots. - //The UI can't be updated from a Thread different to the Qt main thread - emit UpdateLabel(stringQ); - } - catch (const mitk::Exception &exception) - { - //Exceptions from ascendent tasks are catched here - MITK_ERROR << exception.what(); - return; - } - }); - } - } -\endcode - -The steps you need to make are the following: -
    -
  1. Get the microservice. You can get the microservice via the module context. If you want to use the microservice within a plug-in, you need to get the module context from the us::ModuleRegistry. -
  2. Call the SendRequest method. This will start the request itself and is performed asynchronously. As soon as the response is sent by the server, the .then(...) block is executed. -
  3. Choose parameters for .then(...) block. For exception handling, it is important to choose pplx::task . This is a task-based continuation. - For more information, visit https://docs.microsoft.com/en-us/cpp/parallel/concrt/exception-handling-in-the-concurrency-runtime?view=vs-2017. -
  4. Get the result of the request. You can get the JSON-value of the result by callint .get(). At this point, an exception is thrown if something in the previous tasks threw an exception. -
  5. Do something with the result. - \note If you want to modify GUI elements within the .then(...) block, you need to do this by using signals and slots because GUI elements can only be modified by th Qt Main Thread. - For more information, visit https://doc.qt.io/qt-6/thread-basics.html#gui-thread-and-worker-thread -
  6. Exception handling. Here you can define the behaviour if an exception is thrown, exceptions from ascendent tasks are also catched here. -
- -Code, which is followed by this codeblock shown above will be performed asynchronously while waiting for the result. -Besides Get-Requests, you can also perform Put or Post requests by specifying a RequestType in the SendRequest method. - -The following example shows, how you can perform multiple tasks, encapsulated to one joined task. The steps are based on the example for one request and only the specific steps for encapsulation are described. - -\code{.cpp} - //Get the microservice - //Get microservice - auto *context = us::ModuleRegistry::GetModule(1)->GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto managerService = context->GetService(managerRef); - if (managerService) - { - //Create multiple tasks e.g. as shown below - std::vector> tasks; - for (int i = 0; i < 20; i++) - { - pplx::task singleTask = managerService->SendRequest(L"https://jsonplaceholder.typicode.com/posts/1") - .then([=](pplx::task resultTask) { - //Do something when a single task is done - try - { - resultTask.get(); - emit UpdateProgressBar(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }); - tasks.emplace_back(singleTask); - } - //Create a joinTask which includes all tasks you've created - auto joinTask = pplx::when_all(begin(tasks), end(tasks)); - //Run asynchonously - joinTask.then([=](pplx::task resultTask) { - //Do something when all tasks are finished - try - { - resultTask.get(); - emit UpdateLabel("All tasks finished"); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }); - } -\endcode - -The steps you need to make are the following: -
    -
  1. Get the microservice. See example above. -
  2. Create multiple tasks. In this example, 20 identical tasks are created and are saved into a vector. In general, it is possible to place any tasks in that vector. -
  3. Do something when a single task is done. Here, an action is performed if a single tasks is finished. In this example, a progress bar is loaded by a specific number of percent. -
  4. Create a joinTask. Here, all small tasks are encapsulated in one big task. -
  5. Run joinTask asynchonously. The then(...) of the joinTask is performed when all single tasks are finished. -
  6. Do something when all tasks are finished. The handling of the end of a joinTask is equivalent to the end of a single tasks. -
- -*/ diff --git a/Modules/REST/files.cmake b/Modules/REST/files.cmake deleted file mode 100644 index cdb6da57a4..0000000000 --- a/Modules/REST/files.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(CPP_FILES - mitkRESTClient.cpp - mitkRESTServer.cpp - mitkIRESTManager.cpp - mitkIRESTObserver.cpp -) diff --git a/Modules/REST/include/mitkIRESTManager.h b/Modules/REST/include/mitkIRESTManager.h deleted file mode 100644 index 609779776e..0000000000 --- a/Modules/REST/include/mitkIRESTManager.h +++ /dev/null @@ -1,133 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkIRESTManager_h -#define mitkIRESTManager_h - -#include - -#include -#include - -#include -#include -#include - -namespace mitk -{ - class IRESTObserver; - class RESTServer; - - /** - * @class IRESTManager - * @brief This is a microservice interface for managing REST requests. - */ - class MITKREST_EXPORT IRESTManager - { - public: - virtual ~IRESTManager(); - - /** - * @brief request type for client requests by calling SendRequest - */ - enum class RequestType - { - Get, - Post, - Put - }; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @throw mitk::Exception if RequestType is not supported - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param headers the headers for the request (optional) - * @return task to wait for - */ - virtual pplx::task SendRequest( - const web::uri &uri, - const RequestType &type = RequestType::Get, - const std::map headers = {}) = 0; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param body the body for the request (optional) - * @param headers the headers for the request (optional) - * @param filePath the file path to store the request to (optional) - * @return task to wait for - */ - virtual pplx::task SendJSONRequest( - const web::uri &uri, - const RequestType &type = RequestType::Get, - const web::json::value *body = nullptr, - const std::map headers = {}, - const utility::string_t &filePath = {} - ) = 0; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param body the body for the request (optional) - * @param headers the headers for the request (optional) - * @return task to wait for - */ - virtual pplx::task SendBinaryRequest(const web::uri &uri, - const RequestType &type = RequestType::Get, - const std::vector *body = {}, - const std::map headers = {}) = 0; - - /** - * @brief starts listening for requests if there isn't another observer listening and the port is free - * - * @param uri defines the URI for which incoming requests should be send to the observer - * @param observer the observer which handles the incoming requests - */ - virtual void ReceiveRequest(const web::uri &uri, IRESTObserver *observer) = 0; - - /** - * @brief Handles incoming requests by notifying the observer which should receive it - * - * @param uri defines the URI of the request - * @param body the body of the request - * @param method the http method of the request - * @param headers the http headers of the request - * @return the response - */ - virtual web::http::http_response Handle(const web::uri &uri, - const web::json::value &body, - const web::http::method &method, - const mitk::RESTUtil::ParamMap &headers) = 0; - - /** - * @brief Handles the deletion of an observer for all or a specific uri - * - * @param observer the observer which shouldn't receive requests anymore - * @param uri the uri for which the observer doesn't handle requests anymore (optional) - */ - virtual void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri = {}) = 0; - - virtual const std::map& GetServerMap() = 0; - virtual const std::map, IRESTObserver *>& GetObservers() = 0; - - }; -} - -MITK_DECLARE_SERVICE_INTERFACE(mitk::IRESTManager, "org.mitk.IRESTManager") - -#endif diff --git a/Modules/REST/include/mitkIRESTObserver.h b/Modules/REST/include/mitkIRESTObserver.h deleted file mode 100644 index db3330d055..0000000000 --- a/Modules/REST/include/mitkIRESTObserver.h +++ /dev/null @@ -1,53 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkIRESTObserver_h -#define mitkIRESTObserver_h - -#include -#include -#include -#include -#include - -namespace mitk -{ - class MITKREST_EXPORT IRESTObserver - { - public: - /** - * @brief Deletes an observer and calls HandleDeleteObserver() in RESTManager class - * - * @see HandleDeleteObserver() - */ - virtual ~IRESTObserver(); - - /** - * @brief Called if there's an incoming request for the observer, observer implements how to handle request - * - * @param uri - * @param data the data of the incoming request - * @param method the http method of the incoming request - * @param headers - * @return the modified data - */ - virtual web::http::http_response Notify(const web::uri &uri, - const web::json::value &data, - const web::http::method &method, - const mitk::RESTUtil::ParamMap &headers) = 0; - - - private: - }; -} - -#endif diff --git a/Modules/REST/include/mitkRESTClient.h b/Modules/REST/include/mitkRESTClient.h deleted file mode 100644 index 075e826924..0000000000 --- a/Modules/REST/include/mitkRESTClient.h +++ /dev/null @@ -1,105 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkRESTClient_h -#define mitkRESTClient_h - -#include -#include - -namespace mitk -{ - class MITKREST_EXPORT RESTClient - { - public: - using http_request = web::http::http_request; - RESTClient(); - ~RESTClient(); - - /** - * @brief Executes a HTTP GET request with the given uri and returns a task waiting for a json object - * - * @throw mitk::Exception if request went wrong - * @param uri the URI resulting the target of the HTTP request - * @param headers the additional headers to be set to the HTTP request - * @return task to wait for with resulting json object - */ - pplx::task Get(const web::uri &uri, const std::map headers); - - /** - * @brief Executes a HTTP GET request with the given uri and and stores the byte stream in a file given by the - * filePath - * - * @throw mitk::Exception if request went wrong - * @param uri the URI resulting the target of the HTTP request - * @param filePath - * @param headers the additional headers to be set to the HTTP request - * @return task to wait for returning an empty json object - */ - pplx::task Get(const web::uri &uri, - const utility::string_t &filePath, - const std::map headers); - - /** - * @brief Executes a HTTP PUT request with given uri and the content given as json - * - * @throw mitk::Exception if request went wrong - * @param uri defines the URI resulting the target of the HTTP request - * @param content the content as json value which should be the body of the request and thus the content of the - * created resources - * @return task to wait for with resulting json object - */ - pplx::task Put(const web::uri &uri, const web::json::value *content); - - /** - * @brief Executes a HTTP POST request with given uri and the content given as json - * - * @throw mitk::Exception if request went wrong - * @param uri defines the URI resulting the target of the HTTP request - * @param content the content as json value which should be the body of the request and thus the content of the - * created resource - * @param headers the additional headers to be set to the HTTP request - * @return task to wait for with resulting json object - */ - pplx::task Post(const web::uri &uri, - const web::json::value *content, - const std::map headers); - - /** - * @brief Executes a HTTP POST request with given uri and the content given as json - * - * @throw mitk::Exception if request went wrong - * @param uri defines the URI resulting the target of the HTTP request - * @param content the content as json value which should be the body of the request and thus the content of the - * created resource - * @param headers the additional headers to be set to the HTTP request - * @return task to wait for with resulting json object - */ - pplx::task Post(const web::uri &uri, - const std::vector *content, - const std::map headers); - - private: - /** - * @brief Use this to create and init a new request with the given headers. If needed, set the body on the resulting - * request object to avoid an automatic change of the content type header when setting the body first. - */ - http_request InitRequest(const std::map headers); - - void CheckResponseContentType(web::http::http_response &response); - - pplx::task ExecutePost(const web::uri &uri, http_request request); - web::http::client::http_client_config m_ClientConfig; - }; -} // namespace mitk - -#endif diff --git a/Modules/REST/include/mitkRESTServer.h b/Modules/REST/include/mitkRESTServer.h deleted file mode 100644 index 429f0b687d..0000000000 --- a/Modules/REST/include/mitkRESTServer.h +++ /dev/null @@ -1,54 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkRESTServer_h -#define mitkRESTServer_h - -#include -#include - -namespace mitk -{ - class MITKREST_EXPORT RESTServer - { - public: - /** - * @brief Creates an server listening to the given URI - * - * @param uri the URI at which the server is listening for requests - */ - RESTServer(const web::uri &uri); - ~RESTServer(); - - web::uri GetUri(); - - /** - * @brief Opens the listener and starts the listening process - */ - void OpenListener(); - - /** - * @brief Closes the listener and stops the listening process - */ - void CloseListener(); - private: - /** - * @brief Handle for incoming GET requests - * - * @param MitkRequest incoming request object - */ - class Impl; - std::unique_ptr m_Impl; - }; -} - -#endif diff --git a/Modules/REST/include/mitkRESTUtil.h b/Modules/REST/include/mitkRESTUtil.h deleted file mode 100644 index 22b0fed593..0000000000 --- a/Modules/REST/include/mitkRESTUtil.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkRESTUtil_h -#define mitkRESTUtil_h - -#include -#include -#include - - -namespace mitk -{ - class MITKREST_EXPORT RESTUtil - { - public: - - typedef std::map ParamMap; - - /** - * @brief Converts the given std::wstring into a std::string representation - */ - static std::string convertToUtf8(const utility::string_t &string) - { - return utility::conversions::to_utf8string(string); - } - - /** - * @brief Converts the given std::string into a std::wstring representation - */ - static utility::string_t convertToTString(const std::string &string) - { - return utility::conversions::to_string_t(string); - } - }; -} - -#endif diff --git a/Modules/REST/src/mitkIRESTManager.cpp b/Modules/REST/src/mitkIRESTManager.cpp deleted file mode 100644 index b26b7dc1b0..0000000000 --- a/Modules/REST/src/mitkIRESTManager.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include - -mitk::IRESTManager::~IRESTManager() -{ -} diff --git a/Modules/REST/src/mitkIRESTObserver.cpp b/Modules/REST/src/mitkIRESTObserver.cpp deleted file mode 100644 index c60342304f..0000000000 --- a/Modules/REST/src/mitkIRESTObserver.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include - -#include -#include - -mitk::IRESTObserver::~IRESTObserver() -{ - auto context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - if (managerRef) - { - auto manager = context->GetService(managerRef); - if (manager) - manager->HandleDeleteObserver(this); - } -} diff --git a/Modules/REST/src/mitkRESTClient.cpp b/Modules/REST/src/mitkRESTClient.cpp deleted file mode 100644 index 11c66a519f..0000000000 --- a/Modules/REST/src/mitkRESTClient.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include -#include - -#include -#include - -using http_client = web::http::client::http_client; -using http_request = web::http::http_request; -using http_response = web::http::http_response; -using methods = web::http::methods; -using status_codes = web::http::status_codes; -using file_buffer = concurrency::streams::file_buffer; -using streambuf = concurrency::streams::streambuf; - -mitk::RESTClient::RESTClient() -{ - m_ClientConfig.set_validate_certificates(false); -} - -mitk::RESTClient::~RESTClient() {} - -void mitk::RESTClient::CheckResponseContentType(web::http::http_response &response) -{ - auto status = response.status_code(); - - if (status_codes::OK != status) - { - MITK_WARN << "Status: " << status; - MITK_WARN << "Response: " << mitk::RESTUtil::convertToUtf8(response.to_string()); - mitkThrow() << mitk::RESTUtil::convertToUtf8(response.to_string()); - } - - auto requestContentType = response.headers().content_type(); - MITK_DEBUG << "Content Type: " << mitk::RESTUtil::convertToUtf8(requestContentType); - MITK_DEBUG << "Body: " << mitk::RESTUtil::convertToUtf8(response.to_string()); - if (requestContentType.find(U("json")) != std::wstring::npos) - { - MITK_DEBUG << "Caution! The given response content type was '" << mitk::RESTUtil::convertToUtf8(requestContentType) - << "' but contains 'json'. So we awesome the answer actually contains a JSON message."; - response.headers().set_content_type(U("application/json")); - } -} - -pplx::task mitk::RESTClient::Get(const web::uri &uri, - const std::map headers) -{ - auto client = new http_client(uri, m_ClientConfig); - http_request request; - - for (auto param : headers) - { - request.headers().add(param.first, param.second); - } - - return client->request(request).then([=](pplx::task responseTask) { - try - { - auto response = responseTask.get(); - - CheckResponseContentType(response); - - return response.extract_json().get(); - } - catch (const std::exception &e) - { - MITK_INFO << e.what(); - mitkThrow() << "Getting response went wrong: " << e.what(); - } - }); -} - -pplx::task mitk::RESTClient::Get(const web::uri &uri, - const utility::string_t &filePath, - const std::map headers) -{ - auto client = new http_client(uri, m_ClientConfig); - auto fileBuffer = std::make_shared>(); - http_request request; - - for (auto param : headers) - { - request.headers().add(param.first, param.second); - } - - // Open file stream for the specified file path - return file_buffer::open(filePath, std::ios::out) - .then([=](streambuf outFile) -> pplx::task { - *fileBuffer = outFile; - return client->request(methods::GET); - }) - // Write the response body into the file buffer - .then([=](http_response response) -> pplx::task { - auto status = response.status_code(); - - if (status_codes::OK != status) - { - MITK_INFO << status; - MITK_INFO << mitk::RESTUtil::convertToUtf8(response.to_string()); - mitkThrow() << mitk::RESTUtil::convertToUtf8(response.to_string()); - } - - return response.body().read_to_end(*fileBuffer); - }) - // Close the file buffer - .then([=](size_t) { return fileBuffer->close(); }) - // Return empty JSON object - .then([=]() { return web::json::value(); }); -} - -pplx::task mitk::RESTClient::Put(const web::uri &uri, const web::json::value *content) -{ - auto client = new http_client(uri, m_ClientConfig); - http_request request(methods::PUT); - - if (nullptr != content) - request.set_body(*content); - - return client->request(request).then([=](pplx::task responseTask) { - try - { - auto response = responseTask.get(); - - CheckResponseContentType(response); - - return response.extract_json().get(); - } - catch (std::exception &e) - { - MITK_INFO << e.what(); - mitkThrow() << "Getting response went wrong"; - } - }); -} - -pplx::task mitk::RESTClient::Post(const web::uri &uri, - const std::vector *content, - const std::map headers) -{ - auto request = InitRequest(headers); - request.set_method(methods::POST); - - if (nullptr != content) - request.set_body(*content); - - return ExecutePost(uri, request); -} - -pplx::task mitk::RESTClient::Post(const web::uri &uri, - const web::json::value *content, - const std::map headers) -{ - auto request = InitRequest(headers); - request.set_method(methods::POST); - - if (nullptr != content) - request.set_body(*content); - - return ExecutePost(uri, request); -} - -http_request mitk::RESTClient::InitRequest(const std::map headers) -{ - http_request request; - - for (auto param : headers) - { - request.headers().add(param.first, param.second); - } - return request; -} - -pplx::task mitk::RESTClient::ExecutePost(const web::uri &uri, http_request request) -{ - auto client = new http_client(uri, m_ClientConfig); - return client->request(request).then([=](pplx::task responseTask) { - try - { - auto response = responseTask.get(); - - CheckResponseContentType(response); - - return response.extract_json().get(); - } - catch (std::exception &e) - { - MITK_INFO << e.what(); - mitkThrow() << "Getting response went wrong"; - } - }); -} diff --git a/Modules/REST/src/mitkRESTServer.cpp b/Modules/REST/src/mitkRESTServer.cpp deleted file mode 100644 index 64e94fdb89..0000000000 --- a/Modules/REST/src/mitkRESTServer.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include - -#include -#include - -#include - -using namespace std::placeholders; - -using http_listener = web::http::experimental::listener::http_listener; -using http_request = web::http::http_request; -using http_response = web::http::http_response; -using methods = web::http::methods; -using status_codes = web::http::status_codes; - -namespace mitk -{ - class RESTServer::Impl - { - public: - Impl(const web::uri &uri); - ~Impl(); - - void HandleRequest(const http_request &request); - - web::http::experimental::listener::http_listener listener; - web::uri uri; - }; - - RESTServer::Impl::Impl(const web::uri &uri) : uri{uri} {} - - RESTServer::Impl::~Impl() {} - - void RESTServer::Impl::HandleRequest(const http_request &request) - { - web::uri_builder builder(this->listener.uri()); - builder.append(request.absolute_uri()); - - auto uriString = builder.to_uri().to_string(); - - http_response response(status_codes::InternalError); - response.set_body(U("There went something wrong after receiving the request.")); - - auto context = us::GetModuleContext(); - auto managerRef = context->GetServiceReference(); - - if (managerRef) - { - auto manager = context->GetService(managerRef); - if (manager) - { - // not every request contains JSON data - web::json::value data = {}; - if (request.headers().content_type() == U("application/json")) - { - data = request.extract_json().get(); - } - - mitk::RESTUtil::ParamMap headers; - auto begin = request.headers().begin(); - auto end = request.headers().end(); - - for (; begin != end; ++begin) - { - headers.insert(mitk::RESTUtil::ParamMap::value_type(begin->first, begin->second)); - } - - response = manager->Handle(builder.to_uri(), data, request.method(), headers); - } - } - - request.reply(response); - } -} // namespace mitk - -mitk::RESTServer::RESTServer(const web::uri &uri) : m_Impl{std::make_unique(uri)} {} - -mitk::RESTServer::~RESTServer() {} - -void mitk::RESTServer::OpenListener() -{ - m_Impl->listener = http_listener(m_Impl->uri); - m_Impl->listener.support(std::bind(&Impl::HandleRequest, m_Impl.get(), _1)); - m_Impl->listener.support(methods::OPTIONS, std::bind(&Impl::HandleRequest, m_Impl.get(), _1)); - m_Impl->listener.open().wait(); -} - -void mitk::RESTServer::CloseListener() -{ - m_Impl->listener.close().wait(); -} - -web::uri mitk::RESTServer::GetUri() -{ - return m_Impl->uri; -} diff --git a/Modules/REST/test/CMakeLists.txt b/Modules/REST/test/CMakeLists.txt deleted file mode 100644 index 2e7b24b2f7..0000000000 --- a/Modules/REST/test/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -mitk_create_module_tests() -set_tests_properties(mitkRESTClientTest mitkRESTServerTest mitkRESTServerHttpLibTest PROPERTIES RUN_SERIAL TRUE) diff --git a/Modules/REST/test/files.cmake b/Modules/REST/test/files.cmake deleted file mode 100644 index 57628aaee3..0000000000 --- a/Modules/REST/test/files.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(MODULE_TESTS - mitkRESTServerHttpLibTest.cpp - mitkRESTClientTest.cpp - mitkRESTServerTest.cpp -) \ No newline at end of file diff --git a/Modules/REST/test/mitkRESTClientTest.cpp b/Modules/REST/test/mitkRESTClientTest.cpp deleted file mode 100644 index 7acdbc44b3..0000000000 --- a/Modules/REST/test/mitkRESTClientTest.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -class mitkRESTClientTestSuite : public mitk::TestFixture, mitk::IRESTObserver -{ - CPPUNIT_TEST_SUITE(mitkRESTClientTestSuite); - // MITK_TEST(GetRequestValidURI_ReturnsExpectedJSON); GET requests do not support content yet? - MITK_TEST(MultipleGetRequestValidURI_AllTasksFinish); - // MITK_TEST(PutRequestValidURI_ReturnsExpectedJSON); Does not work reliably on dart clients - // MITK_TEST(PostRequestValidURI_ReturnsExpectedJSON); -- " -- - MITK_TEST(GetRequestInvalidURI_ThrowsException); - MITK_TEST(PutRequestInvalidURI_ThrowsException); - MITK_TEST(PostRequestInvalidURI_ThrowsException); - CPPUNIT_TEST_SUITE_END(); - -public: - mitk::IRESTManager *m_Service; - web::json::value m_Data; - - web::http::http_response Notify(const web::uri &, - const web::json::value &, - const web::http::method &, - const mitk::RESTUtil::ParamMap &) override - { - auto response = web::http::http_response(); - response.set_body(m_Data); - response.set_status_code(web::http::status_codes::OK); - - return response; - } - - /** - * @brief Setup Always call this method before each Test-case to ensure correct and new initialization of the used - * members for a new test case. (If the members are not used in a test, the method does not need to be called). - */ - void setUp() override - { - m_Data = web::json::value(); - m_Data[U("userId")] = web::json::value(1); - m_Data[U("id")] = web::json::value(1); - m_Data[U("title")] = web::json::value(U("this is a title")); - m_Data[U("body")] = web::json::value(U("this is a body")); - - us::ServiceReference serviceRef = - us::GetModuleContext()->GetServiceReference(); - if (serviceRef) - { - m_Service = us::GetModuleContext()->GetService(serviceRef); - } - - if (!m_Service) - { - CPPUNIT_FAIL("Getting Service in setUp() failed"); - } - - m_Service->ReceiveRequest(U("http://localhost:8080/clienttest"), this); - } - - void tearDown() override { m_Service->HandleDeleteObserver(this); } - - void GetRequestValidURI_ReturnsExpectedJSON() - { - web::json::value result; - - m_Service->SendRequest(U("http://localhost:8080/clienttest")) - .then([&](pplx::task resultTask) { - try - { - result = resultTask.get(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }) - .wait(); - - CPPUNIT_ASSERT_MESSAGE("Result is the expected JSON value", result == m_Data); - } - - void MultipleGetRequestValidURI_AllTasksFinish() - { - std::atomic count {0}; - - // Create multiple tasks e.g. as shown below - std::vector> tasks; - for (int i = 0; i < 20; ++i) - { - pplx::task singleTask = m_Service->SendRequest(U("http://localhost:8080/clienttest")) - .then([&](pplx::task resultTask) { - // Do something when a single task is done - try - { - resultTask.get(); - count += 1; - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }); - tasks.emplace_back(singleTask); - } - // Create a joinTask which includes all tasks you've created - auto joinTask = pplx::when_all(begin(tasks), end(tasks)); - // Run asynchonously - joinTask - .then([&](pplx::task resultTask) { - // Do something when all tasks are finished - try - { - resultTask.get(); - count += 1; - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }) - .wait(); - - CPPUNIT_ASSERT_MESSAGE("Multiple Requests", 21 == count); - } - - void PutRequestValidURI_ReturnsExpectedJSON() - { - // optional: link might get invalid or content is changed - web::json::value result; - - m_Service - ->SendJSONRequest( - U("https://jsonplaceholder.typicode.com/posts/1"), mitk::IRESTManager::RequestType::Put) - .then([&](pplx::task resultTask) { - try - { - result = resultTask.get(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }) - .wait(); - - CPPUNIT_ASSERT_MESSAGE( - "Result is the expected JSON value, check if the link is still valid since this is an optional test", - result == m_Data); - } - - void PostRequestValidURI_ReturnsExpectedJSON() - { - // optional: link might get invalid or content is changed - web::json::value result; - web::json::value data; - - data[U("userId")] = m_Data[U("userId")]; - data[U("title")] = m_Data[U("title")]; - data[U("body")] = m_Data[U("body")]; - - m_Service - ->SendJSONRequest(U("https://jsonplaceholder.typicode.com/posts"), mitk::IRESTManager::RequestType::Post, &data) - .then([&](pplx::task resultTask) { - try - { - result = resultTask.get(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }) - .wait(); - - data[U("id")] = web::json::value(101); - CPPUNIT_ASSERT_MESSAGE( - "Result is the expected JSON value, check if the link is still valid since this is an optional test", - result == data); - } - - void PostRequestHeaders_Success() - { - mitk::RESTUtil::ParamMap headers; - headers.insert(mitk::RESTUtil::ParamMap::value_type( - U("Content-Type"), U("multipart/related; type=\"application/dicom\"; boundary=boundary"))); - - m_Service->SendRequest(U("http://localhost:8080/clienttest")).then([&](pplx::task resultTask) { - // Do something when a single task is done - try - { - resultTask.get(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }); - } - - void GetException() - { - // Method which makes a get request to an invalid uri - web::json::value result; - - m_Service->SendRequest(U("http://localhost:1234/invalid")) - .then([&](pplx::task resultTask) { result = resultTask.get(); }) - .wait(); - } - void GetRequestInvalidURI_ThrowsException() { CPPUNIT_ASSERT_THROW(GetException(), mitk::Exception); } - - void PutException() - { - // Method which makes a put request to an invalid uri - web::json::value result; - - m_Service->SendJSONRequest(U("http://localhost:1234/invalid"), mitk::IRESTManager::RequestType::Put, &m_Data) - .then([&](pplx::task resultTask) { result = resultTask.get(); }) - .wait(); - } - void PutRequestInvalidURI_ThrowsException() { CPPUNIT_ASSERT_THROW(PutException(), mitk::Exception); } - - void PostException() - { - // Method which makes a post request to an invalid uri - web::json::value result; - - m_Service->SendJSONRequest(U("http://localhost:1234/invalid"), mitk::IRESTManager::RequestType::Post, &m_Data) - .then([&](pplx::task resultTask) { result = resultTask.get(); }) - .wait(); - } - void PostRequestInvalidURI_ThrowsException() { CPPUNIT_ASSERT_THROW(PostException(), mitk::Exception); } -}; - -MITK_TEST_SUITE_REGISTRATION(mitkRESTClient) diff --git a/Modules/REST/test/mitkRESTServerHttpLibTest.cpp b/Modules/REST/test/mitkRESTServerHttpLibTest.cpp deleted file mode 100644 index 8d0f63f3e2..0000000000 --- a/Modules/REST/test/mitkRESTServerHttpLibTest.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::chrono_literals; - -class mitkRESTServerHttpLibTestSuite : public mitk::TestFixture -{ - CPPUNIT_TEST_SUITE(mitkRESTServerHttpLibTestSuite); - MITK_TEST(OpenListener_Succeed); - MITK_TEST(OpenListenerGetRequestSamePath_ReturnExpectedJSON); - CPPUNIT_TEST_SUITE_END(); - std::vector> m_ft; - -public: - void OpenListener_Succeed() - { - httplib::Server svr; - svr.Get("/get", - [](const httplib::Request &, httplib::Response &res) - { res.set_content("Hello World from MITK!", "text/plain"); }); - std::future ft = std::async(std::launch::async, [&]() { svr.listen("localhost", 8080); }); - while (!svr.is_running()) - { - std::this_thread::sleep_for(100ms); - } - CPPUNIT_ASSERT_MESSAGE("Server is running", svr.is_running()); - svr.stop(); - } - - void OpenListenerGetRequestSamePath_ReturnExpectedJSON() - { - httplib::Server svr; - std::map msgdb; - msgdb[0] = "hello_MITK"; - - svr.Get(R"(/msg/(\d+))", - [&](const httplib::Request &req, httplib::Response &res) - { - auto n = req.matches[1]; - nlohmann::json jRes; - try - { - jRes["id"] = std::stoi(n); - jRes["msg"] = msgdb[std::stoi(n)]; - - res.set_content(jRes.dump(), "application/json"); - } - catch (const std::exception &) - { - res.set_content("Cannot find the requested message.", "text/plain"); - } - }); - std::future ft = std::async(std::launch::async, [&]() { svr.listen("localhost", 8080); }); - while (!svr.is_running()) - { - std::this_thread::sleep_for(100ms); - } - httplib::Client cli("http://localhost:8080"); - try - { - if (auto response = cli.Get("/msg/0")) - { - if (response->status == 200) - { - auto js = nlohmann::json::parse(response->body); - std::string msg = js["msg"]; - CPPUNIT_ASSERT_MESSAGE("Result is the expected JSON value", msg == msgdb[0]); - } - else - { - CPPUNIT_ASSERT_MESSAGE("A connection cannot be established", false); - } - } - else - { - CPPUNIT_ASSERT_MESSAGE("A connection cannot be established", false); - } - } - catch (const std::exception &e) - { - svr.stop(); - CPPUNIT_ASSERT_MESSAGE(e.what(), false); - } - svr.stop(); - } -}; - -MITK_TEST_SUITE_REGISTRATION(mitkRESTServerHttpLib) diff --git a/Modules/REST/test/mitkRESTServerTest.cpp b/Modules/REST/test/mitkRESTServerTest.cpp deleted file mode 100644 index 22f1fe65cf..0000000000 --- a/Modules/REST/test/mitkRESTServerTest.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifdef _WIN32 -#include -#endif - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -class mitkRESTServerTestSuite : public mitk::TestFixture, mitk::IRESTObserver -{ - CPPUNIT_TEST_SUITE(mitkRESTServerTestSuite); - MITK_TEST(OpenListener_Succeed); - MITK_TEST(TwoListenerSameHostSamePort_OnlyOneOpened); - MITK_TEST(CloseListener_Succeed); - MITK_TEST(OpenMultipleListenerCloseOne_Succeed); - MITK_TEST(OpenMultipleListenerCloseAll_Succeed); - // MITK_TEST(OpenListenerGetRequestSamePath_ReturnExpectedJSON); GET requests do not support content yet? - MITK_TEST(CloseListener_NoRequestPossible); - MITK_TEST(OpenListenerGetRequestDifferentPath_ReturnNotFound); - MITK_TEST(OpenListenerCloseAndReopen_Succeed); - MITK_TEST(HandleHeader_Succeed); - CPPUNIT_TEST_SUITE_END(); - -public: - mitk::IRESTManager *m_Service; - web::json::value m_Data; - - web::http::http_response Notify(const web::uri &, - const web::json::value &, - const web::http::method &, - const mitk::RESTUtil::ParamMap &headers) override - { - auto response = web::http::http_response(); - response.set_body(m_Data); - mitk::RESTUtil::ParamMap::const_iterator contentTypePos = headers.find(U("Content-Type")); - if (contentTypePos != headers.end() && contentTypePos->second == U("awesome/type")) - { - m_Data[U("result")] = web::json::value(U("awesome/type")); - } - - return response; - } - - /** - * @brief Setup Always call this method before each Test-case to ensure correct and new initialization of the used - * members for a new test case. (If the members are not used in a test, the method does not need to be called). - */ - void setUp() override - { - m_Data = web::json::value(); - m_Data[U("userId")] = web::json::value(1); - m_Data[U("id")] = web::json::value(1); - m_Data[U("title")] = web::json::value(U("this is a title")); - m_Data[U("body")] = web::json::value(U("this is a body")); - - auto serviceRef = us::GetModuleContext()->GetServiceReference(); - - if (serviceRef) - m_Service = us::GetModuleContext()->GetService(serviceRef); - - if (!m_Service) - CPPUNIT_FAIL("Getting Service in setUp() failed"); - } - - void tearDown() override { m_Service->HandleDeleteObserver(this); } - - void OpenListener_Succeed() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - CPPUNIT_ASSERT_MESSAGE("Open one listener, observer map size is one", 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open one listener, server map size is one", 1 == m_Service->GetServerMap().size()); - } - - void TwoListenerSameHostSamePort_OnlyOneOpened() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - m_Service->ReceiveRequest(U("http://localhost:8080/serverexample"), this); - - CPPUNIT_ASSERT_MESSAGE("Open two listener with a different path,same host, same port, observer map size is two", - 2 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open two listener with a different path,same host, same port, server map size is one", - 1 == m_Service->GetServerMap().size()); - } - - void CloseListener_Succeed() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - CPPUNIT_ASSERT_MESSAGE("Open one listener, observer map size is one", 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open one listener, server map size is one", 1 == m_Service->GetServerMap().size()); - - m_Service->HandleDeleteObserver(this); - - CPPUNIT_ASSERT_MESSAGE("Closed listener, observer map is empty", 0 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Closed listener, server map is empty", 0 == m_Service->GetServerMap().size()); - } - - void OpenMultipleListenerCloseOne_Succeed() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - m_Service->ReceiveRequest(U("http://localhost:8090/serverexample"), this); - - CPPUNIT_ASSERT_MESSAGE("Open two listener, observer map size is two", 2 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open two listener, server map size is two", 2 == m_Service->GetServerMap().size()); - - m_Service->HandleDeleteObserver(this, U("http://localhost:8080/servertest")); - - CPPUNIT_ASSERT_MESSAGE("Closed one of two listeners, observer map is size is one", - 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Closed one of two listener, server map size is one", 1 == m_Service->GetServerMap().size()); - } - - void OpenMultipleListenerCloseAll_Succeed() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - m_Service->ReceiveRequest(U("http://localhost:8090/serverexample"), this); - - CPPUNIT_ASSERT_MESSAGE("Open two listener, observer map size is two", 2 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open two listener, server map size is two", 2 == m_Service->GetServerMap().size()); - - m_Service->HandleDeleteObserver(this); - - CPPUNIT_ASSERT_MESSAGE("Closed all listeners, observer map is empty", 0 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Closed all listeners, server map is empty", 0 == m_Service->GetServerMap().size()); - } - - void OpenListenerGetRequestSamePath_ReturnExpectedJSON() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - web::json::value result; - auto body = web::json::value(); - m_Service->SendRequest(U("http://localhost:8080/servertest")) - .then([&](pplx::task resultTask) { - try - { - result = resultTask.get(); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }) - .wait(); - - CPPUNIT_ASSERT_MESSAGE("Opened listener and send request to same uri, returned expected JSON", result == m_Data); - } - - void RequestToClosedListener() - { - web::json::value result; - - m_Service->SendRequest(U("http://localhost:8080/servertest")) - .then([&](pplx::task resultTask) { result = resultTask.get(); }) - .wait(); - } - - void CloseListener_NoRequestPossible() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - CPPUNIT_ASSERT_MESSAGE("Open one listener, observer map size is one", 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open one listener, server map size is one", 1 == m_Service->GetServerMap().size()); - - m_Service->HandleDeleteObserver(this); - - CPPUNIT_ASSERT_MESSAGE("Closed listener, observer map is empty", 0 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Closed listener, server map is empty", 0 == m_Service->GetServerMap().size()); - - CPPUNIT_ASSERT_THROW(RequestToClosedListener(), mitk::Exception); - } - - void RequestToDifferentPathNotFound() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - web::json::value result; - - m_Service->SendRequest(U("http://localhost:8080/serverexample")) - .then([&](pplx::task resultTask) { result = resultTask.get(); }) - .wait(); - } - - void OpenListenerGetRequestDifferentPath_ReturnNotFound() - { - CPPUNIT_ASSERT_THROW(RequestToDifferentPathNotFound(), mitk::Exception); - } - - void OpenListenerCloseAndReopen_Succeed() - { - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - CPPUNIT_ASSERT_MESSAGE("Open one listener, observer map size is one", 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Open one listener, server map size is one", 1 == m_Service->GetServerMap().size()); - - m_Service->HandleDeleteObserver(this); - - CPPUNIT_ASSERT_MESSAGE("Closed listener, observer map is empty", 0 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Closed listener, server map is empty", 0 == m_Service->GetServerMap().size()); - - m_Service->ReceiveRequest(U("http://localhost:8080/servertest"), this); - - CPPUNIT_ASSERT_MESSAGE("Reopened listener, observer map size is one", 1 == m_Service->GetObservers().size()); - CPPUNIT_ASSERT_MESSAGE("Reopened listener, server map size is one", 1 == m_Service->GetServerMap().size()); - } - - void HandleHeader_Succeed() - { - mitk::RESTUtil::ParamMap headers; - headers.insert(mitk::RESTUtil::ParamMap::value_type(U("Content-Type"), U("awesome/type"))); - - m_Service->SendRequest(U("http://localhost:8080/clienttest")).then([&](pplx::task resultTask) { - // Do something when a single task is done - try - { - auto result = resultTask.get(); - CPPUNIT_ASSERT_MESSAGE("Sent Header is not successful transferred to server", - result[U("result")].as_string() == U("awesome/type")); - } - catch (const mitk::Exception &exception) - { - MITK_ERROR << exception.what(); - return; - } - }); - } -}; - -MITK_TEST_SUITE_REGISTRATION(mitkRESTServer) diff --git a/Modules/RESTService/CMakeLists.txt b/Modules/RESTService/CMakeLists.txt deleted file mode 100644 index 7a43698da8..0000000000 --- a/Modules/RESTService/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -if(MITK_USE_cpprestsdk) - - mitk_create_module( - DEPENDS MitkREST - AUTOLOAD_WITH MitkCore - ) - -endif() diff --git a/Modules/RESTService/files.cmake b/Modules/RESTService/files.cmake deleted file mode 100644 index df7a46d0bc..0000000000 --- a/Modules/RESTService/files.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CPP_FILES - mitkRESTServiceActivator.cpp - mitkRESTManager.cpp -) diff --git a/Modules/RESTService/include/mitkRESTManager.h b/Modules/RESTService/include/mitkRESTManager.h deleted file mode 100644 index 2e62c12ea7..0000000000 --- a/Modules/RESTService/include/mitkRESTManager.h +++ /dev/null @@ -1,153 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkRESTManager_h -#define mitkRESTManager_h - -#include -#include -#include - -namespace mitk -{ - /** - * @class RESTManager - * @brief this is a microservice for managing REST-requests, used for non-qt applications. - * - * RESTManagerQt in the CppRestSdkQt module inherits from this class and is the equivalent microservice - * used for Qt applications. - */ - class MITKRESTSERVICE_EXPORT RESTManager : public IRESTManager - { - public: - RESTManager(); - ~RESTManager() override; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @throw mitk::Exception if RequestType is not supported - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param headers the headers for the request (optional) - * @return task to wait for - */ - pplx::task SendRequest( - const web::uri &uri, - const RequestType &type = RequestType::Get, - const std::map headers = {}) override; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @throw mitk::Exception if RequestType is not supported - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param body the body for the request (optional) - * @param headers the headers for the request (optional) - * @param filePath the file path to store the request to (optional) - * @return task to wait for - */ - pplx::task SendJSONRequest(const web::uri &uri, - const RequestType &type = RequestType::Get, - const web::json::value *body = nullptr, - const std::map headers = {}, - const utility::string_t &filePath = {}) override; - - /** - * @brief Executes a HTTP request in the mitkRESTClient class - * - * @throw mitk::Exception if RequestType is not supported - * @param uri defines the URI the request is send to - * @param type the RequestType of the HTTP request (optional) - * @param body the body for the request (optional) - * @param headers the headers for the request (optional) - * @return task to wait for - */ - pplx::task SendBinaryRequest( - const web::uri &uri, - const RequestType &type = RequestType::Get, - const std::vector *body = {}, - const std::map headers = {}) override; - - /** - * @brief starts listening for requests if there isn't another observer listening and the port is free - * - * @param uri defines the URI for which incoming requests should be send to the observer - * @param observer the observer which handles the incoming requests - */ - void ReceiveRequest(const web::uri &uri, IRESTObserver *observer) override; - - /** - * @brief Handles incoming requests by notifying the observer which should receive it - * - * @param uri defines the URI of the request - * @param body the body of the request - * @param method the http method of the request - * @param headers the http headers of the request - * @return the response - */ - - web::http::http_response Handle(const web::uri &uri, - const web::json::value &body, - const web::http::method &method, - const mitk::RESTUtil::ParamMap &headers) override; - - /** - * @brief Handles the deletion of an observer for all or a specific uri - * - * @param observer the observer which shouldn't receive requests anymore - * @param uri the uri for which the observer doesn't handle requests anymore (optional) - */ - void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri = {}) override; - - /** - * @brief internal use only - */ - const std::map &GetServerMap() override; - std::map, IRESTObserver *> &GetObservers() override; - - private: - /** - * @brief adds an observer if a port is free, called by ReceiveRequest method - * - * @param uri the uri which builds the key for the observer map - * @param observer the observer which is added - */ - void AddObserver(const web::uri &uri, IRESTObserver *observer); - - /** - * @brief handles server management if there is already a server under a port, called by ReceiveRequest method - * - * @param uri the uri which which is requested to be added - * @param observer the observer which proceeds the request - */ - void RequestForATakenPort(const web::uri &uri, IRESTObserver *observer); - - /** - * @brief deletes an observer, called by HandleDeleteObserver method - * - * @param it the iterator comparing the observers in HandleDeleteObserver method - * @return bool if there is another observer under the port - */ - bool DeleteObserver(std::map, IRESTObserver *>::iterator &it); - - void SetServerMap(const int port, RESTServer *server); - void DeleteFromServerMap(const int port); - void SetObservers(const std::pair key, IRESTObserver *observer); - - std::map m_ServerMap; // Map with port server pairs - std::map, IRESTObserver *> m_Observers; // Map with all observers - }; -} // namespace mitk - -#endif diff --git a/Modules/RESTService/src/mitkRESTManager.cpp b/Modules/RESTService/src/mitkRESTManager.cpp deleted file mode 100644 index d619170369..0000000000 --- a/Modules/RESTService/src/mitkRESTManager.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include -#include -#include - -#include -#include - -mitk::RESTManager::RESTManager() {} - -mitk::RESTManager::~RESTManager() {} - -pplx::task mitk::RESTManager::SendRequest( - const web::uri &uri, const RequestType &type, const std::map headers) -{ - pplx::task answer; - auto client = new RESTClient; - - switch (type) - { - case RequestType::Get: - answer = client->Get(uri, headers); - break; - - default: - mitkThrow() << "Request Type not supported"; - } - - return answer; -} - -pplx::task mitk::RESTManager::SendBinaryRequest( - const web::uri &uri, - const RequestType &type, - const std::vector *content, - const std::map headers) -{ - pplx::task answer; - auto client = new RESTClient; - - switch (type) - { - case RequestType::Post: - if (nullptr == content) - MITK_WARN << "Content for post is empty, this will create an empty resource"; - - answer = client->Post(uri, content, headers); - break; - - default: - mitkThrow() << "Request Type not supported for binary data"; - } - - return answer; -} - -pplx::task mitk::RESTManager::SendJSONRequest( - const web::uri &uri, - const RequestType &type, - const web::json::value *content, - const std::map headers, - const utility::string_t &filePath) -{ - pplx::task answer; - auto client = new RESTClient; - - switch (type) - { - case RequestType::Get: - answer = !filePath.empty() ? client->Get(uri, filePath, headers) : client->Get(uri, headers); - break; - - case RequestType::Post: - if (nullptr == content) - MITK_WARN << "Content for post is empty, this will create an empty resource"; - - answer = client->Post(uri, content, headers); - break; - - case RequestType::Put: - - if (nullptr == content) - MITK_WARN << "Content for put is empty, this will empty the resource"; - - answer = client->Put(uri, content); - break; - - default: - mitkThrow() << "Request Type not supported"; - } - - return answer; -} - -void mitk::RESTManager::ReceiveRequest(const web::uri &uri, mitk::IRESTObserver *observer) -{ - // New instance of RESTServer in m_ServerMap, key is port of the request - auto port = uri.port(); - - // Checking if port is free to add a new Server - if (0 == m_ServerMap.count(port)) - { - this->AddObserver(uri, observer); - // creating server instance - auto server = new RESTServer(uri.authority()); - // add reference to server instance to map - m_ServerMap[port] = server; - // start Server - server->OpenListener(); - } - // If there is already a server under this port - else - { - this->RequestForATakenPort(uri, observer); - } -} - -web::http::http_response mitk::RESTManager::Handle(const web::uri &uri, - const web::json::value &body, - const web::http::method &method, - const mitk::RESTUtil::ParamMap &headers) -{ - // Checking if there is an observer for the port and path - auto key = std::make_pair(uri.port(), uri.path()); - if (0 != m_Observers.count(key)) - { - return m_Observers[key]->Notify(uri, body, method, headers); - } - // No observer under this port, return null which results in status code 404 (s. RESTServer) - else - { - MITK_WARN << "No Observer can handle the data"; - web::http::http_response response(web::http::status_codes::BadGateway); - response.set_body(U("No one can handle the request under the given port.")); - return response; - } -} - -void mitk::RESTManager::HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri) -{ - for (auto it = m_Observers.begin(); it != m_Observers.end();) - { - mitk::IRESTObserver *obsMap = it->second; - // Check whether observer is at this place in map - if (observer == obsMap) - { - // Check whether it is the right uri to be deleted - if (uri.is_empty() || uri.path() == it->first.second) - { - int port = it->first.first; - bool noObserverForPort = this->DeleteObserver(it); - if (noObserverForPort) - { - // there isn't an observer at this port, delete m_ServerMap entry for this port - // close listener - m_ServerMap[port]->CloseListener(); - delete m_ServerMap[port]; - // delete server from map - m_ServerMap.erase(port); - } - } - else - { - ++it; - } - } - else - { - ++it; - } - } -} - -const std::map &mitk::RESTManager::GetServerMap() -{ - return m_ServerMap; -} - -std::map, mitk::IRESTObserver *> &mitk::RESTManager::GetObservers() -{ - return m_Observers; -} - -void mitk::RESTManager::AddObserver(const web::uri &uri, IRESTObserver *observer) -{ - // new observer has to be added - std::pair key(uri.port(), uri.path()); - m_Observers[key] = observer; -} - -void mitk::RESTManager::RequestForATakenPort(const web::uri &uri, IRESTObserver *observer) -{ - // Same host, means new observer but not a new server instance - if (uri.authority() == m_ServerMap[uri.port()]->GetUri()) - { - // new observer has to be added - std::pair key(uri.port(), uri.path()); - // only add a new observer if there isn't already an observer for this uri - if (0 == m_Observers.count(key)) - { - this->AddObserver(uri, observer); - } - else - { - MITK_ERROR << "There is already an observer handling this data"; - } - } - // Error, since another server can't be added under this port - else - { - MITK_ERROR << "There is already another server listening under this port"; - } -} - -bool mitk::RESTManager::DeleteObserver(std::map, IRESTObserver *>::iterator &it) -{ - int port = it->first.first; - - it = m_Observers.erase(it); - - for (auto observer : m_Observers) - { - if (port == observer.first.first) - { - // there still exists an observer for this port - return false; - } - } - - return true; -} - -void mitk::RESTManager::SetServerMap(const int port, RESTServer *server) -{ - m_ServerMap[port] = server; -} - -void mitk::RESTManager::DeleteFromServerMap(const int port) -{ - m_ServerMap.erase(port); -} - -void mitk::RESTManager::SetObservers(const std::pair key, IRESTObserver *observer) -{ - m_Observers[key] = observer; -} diff --git a/Modules/RESTService/src/mitkRESTServiceActivator.cpp b/Modules/RESTService/src/mitkRESTServiceActivator.cpp deleted file mode 100644 index 5128dd40a1..0000000000 --- a/Modules/RESTService/src/mitkRESTServiceActivator.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkRESTServiceActivator.h" -#include - -void MitkRESTServiceActivator::Load(us::ModuleContext *context) -{ - m_RESTManager.reset(new mitk::RESTManager); - context->RegisterService(m_RESTManager.get()); -} - -void MitkRESTServiceActivator::Unload(us::ModuleContext *) -{ -} - -US_EXPORT_MODULE_ACTIVATOR(MitkRESTServiceActivator) diff --git a/Modules/RESTService/src/mitkRESTServiceActivator.h b/Modules/RESTService/src/mitkRESTServiceActivator.h deleted file mode 100644 index 2029536e64..0000000000 --- a/Modules/RESTService/src/mitkRESTServiceActivator.h +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkRESTServiceActivator_h -#define mitkRESTServiceActivator_h - -#include -#include - -class MitkRESTServiceActivator : public us::ModuleActivator -{ -public: - void Load(us::ModuleContext *context) override; - void Unload(us::ModuleContext *context) override; - -private: - std::unique_ptr m_RESTManager; -}; - -#endif