diff --git a/Modules/CppRestSdk/CMakeLists.txt b/Modules/CppRestSdk/CMakeLists.txt index ba20ff7a7e..24fe589848 100644 --- a/Modules/CppRestSdk/CMakeLists.txt +++ b/Modules/CppRestSdk/CMakeLists.txt @@ -1,15 +1,15 @@ if(MITK_USE_CppRestSdk) MITK_CREATE_MODULE( DEPENDS MitkCore CppMicroServices - WARNINGS_NO_ERRORS + #WARNINGS_NO_ERRORS AUTOLOAD_WITH MitkCore ) find_package(OpenSSL REQUIRED) target_link_libraries(${MODULE_TARGET} PRIVATE cpprestsdk::cpprest) target_link_libraries(${MODULE_TARGET} PUBLIC OpenSSL::SSL) add_subdirectory(test) endif(MITK_USE_CppRestSdk) diff --git a/Modules/CppRestSdk/include/mitkRESTManager.h b/Modules/CppRestSdk/include/mitkRESTManager.h index 5566240316..43657d5569 100644 --- a/Modules/CppRestSdk/include/mitkRESTManager.h +++ b/Modules/CppRestSdk/include/mitkRESTManager.h @@ -1,107 +1,117 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkRESTManager_h #define mitkRESTManager_h +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + #include #include #include #include namespace mitk { class MITKCPPRESTSDK_EXPORT RESTManager : public IRESTManager { public: RESTManager(); ~RESTManager() override; /** * @brief Executes a HTTP request in the mitkRESTClientMicroService 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 filePath the file path to store the request to * @return task to wait for */ pplx::task SendRequest(const web::uri &uri, const RequestType &type = get, const web::json::value &body= NULL, const utility::string_t &filePath = L"") 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 * @return the data which is modified by the notified observer */ web::json::value Handle(const web::uri &uri, web::json::value &body) 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) */ virtual void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri) override; virtual std::map GetM_ServerMap() override; virtual std::map, IRESTObserver *> GetM_Observers() override; /** * @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 ServerUnderPort(const web::uri &uri, IRESTObserver *observer); /** * @brief deletes an observer, called by HandleDeleteObserver method * * @param it the iterator comparing the observers in HandleDeleteObserver method * @param the uri for which the observer doesn't want to receive requests anymore * @return bool if there is another observer under the port */ bool DeleteObserver(std::map < std::pair, IRESTObserver *>::iterator &it, const web::uri &uri); protected: std::map m_ServerMap; // Map with port server pairs std::map, IRESTObserver *> m_Observers; // Map with all observers }; } // namespace mitk + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif // !mitkRESTManager_h diff --git a/Modules/CppRestSdkQt/CMakeLists.txt b/Modules/CppRestSdkQt/CMakeLists.txt index 457076c61f..0874d9739d 100644 --- a/Modules/CppRestSdkQt/CMakeLists.txt +++ b/Modules/CppRestSdkQt/CMakeLists.txt @@ -1,15 +1,15 @@ if(MITK_USE_CppRestSdk) MITK_CREATE_MODULE( DEPENDS MitkCore MitkQtWidgetsExt CppMicroServices MitkCppRestSdk PACKAGE_DEPENDS Qt5|Core - WARNINGS_NO_ERRORS + #WARNINGS_NO_ERRORS AUTOLOAD_WITH MitkQtWidgets ) find_package(OpenSSL REQUIRED) target_link_libraries(${MODULE_TARGET} PRIVATE cpprestsdk::cpprest) target_link_libraries(${MODULE_TARGET} PUBLIC OpenSSL::SSL) endif() diff --git a/Modules/CppRestSdkQt/include/mitkRESTManagerQt.h b/Modules/CppRestSdkQt/include/mitkRESTManagerQt.h index a3df432485..2d6b9c990b 100644 --- a/Modules/CppRestSdkQt/include/mitkRESTManagerQt.h +++ b/Modules/CppRestSdkQt/include/mitkRESTManagerQt.h @@ -1,88 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkRESTManagerQt_h #define mitkRESTManagerQt_h + #include #include #include #include #include #include #include namespace mitk { - class MITKCPPRESTSDKQT_EXPORT RESTManagerQt : public QObject, public IRESTManager, public RESTManager + class MITKCPPRESTSDKQT_EXPORT RESTManagerQt : public QObject, public RESTManager { Q_OBJECT public: RESTManagerQt(); ~RESTManagerQt() override; /** * @brief Executes a HTTP request in the mitkRESTClientMicroService 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 filePath the file path to store the request to * @return task to wait for */ pplx::task SendRequest(const web::uri &uri, const RequestType &type = get, const web::json::value &body = NULL, const utility::string_t &filePath = L"") 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 * @return the data which is modified by the notified observer */ web::json::value Handle(const web::uri &uri, web::json::value &body) 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) */ virtual void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri) override; virtual std::map GetM_ServerMap() override; virtual std::map, IRESTObserver *> GetM_Observers() override; private: //std::map m_ServerMap; // Map with port server pairs std::map m_ServerThreadMap; // Map with threads for servers //std::map, IRESTObserver *> m_Observers; // Map with all observers }; } // namespace mitk #endif // !mitkRESTManager_h \ No newline at end of file