Medical Imaging Interaction Toolkit  2023.12.99-7a59bd54
Medical Imaging Interaction Toolkit
mitkRESTManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkRESTManager_h
14 #define mitkRESTManager_h
15 
16 #include <MitkRESTServiceExports.h>
17 #include <mitkIRESTManager.h>
18 #include <mitkRESTUtil.h>
19 
20 namespace mitk
21 {
30  {
31  public:
32  RESTManager();
33  ~RESTManager() override;
34 
44  pplx::task<web::json::value> SendRequest(
45  const web::uri &uri,
46  const RequestType &type = RequestType::Get,
47  const std::map<utility::string_t, utility::string_t> headers = {}) override;
48 
60  pplx::task<web::json::value> SendJSONRequest(const web::uri &uri,
61  const RequestType &type = RequestType::Get,
62  const web::json::value *body = nullptr,
63  const std::map<utility::string_t, utility::string_t> headers = {},
64  const utility::string_t &filePath = {}) override;
65 
76  pplx::task<web::json::value> SendBinaryRequest(
77  const web::uri &uri,
78  const RequestType &type = RequestType::Get,
79  const std::vector<unsigned char> *body = {},
80  const std::map<utility::string_t, utility::string_t> headers = {}) override;
81 
88  void ReceiveRequest(const web::uri &uri, IRESTObserver *observer) override;
89 
100  web::http::http_response Handle(const web::uri &uri,
101  const web::json::value &body,
102  const web::http::method &method,
103  const mitk::RESTUtil::ParamMap &headers) override;
104 
111  void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri = {}) override;
112 
116  const std::map<int, RESTServer *> &GetServerMap() override;
117  std::map<std::pair<int, utility::string_t>, IRESTObserver *> &GetObservers() override;
118 
119  private:
126  void AddObserver(const web::uri &uri, IRESTObserver *observer);
127 
134  void RequestForATakenPort(const web::uri &uri, IRESTObserver *observer);
135 
142  bool DeleteObserver(std::map<std::pair<int, utility::string_t>, IRESTObserver *>::iterator &it);
143 
144  void SetServerMap(const int port, RESTServer *server);
145  void DeleteFromServerMap(const int port);
146  void SetObservers(const std::pair<int, utility::string_t> key, IRESTObserver *observer);
147 
148  std::map<int, RESTServer *> m_ServerMap; // Map with port server pairs
149  std::map<std::pair<int, utility::string_t>, IRESTObserver *> m_Observers; // Map with all observers
150  };
151 } // namespace mitk
152 
153 #endif
mitk::IRESTManager
This is a microservice interface for managing REST requests.
Definition: mitkIRESTManager.h:34
mitk::RESTUtil::ParamMap
std::map< utility::string_t, utility::string_t > ParamMap
Definition: mitkRESTUtil.h:27
mitkIRESTManager.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::RESTServer
Definition: mitkRESTServer.h:21
mitk::ImageMappingHelper::map
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=nullptr, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
mitkRESTUtil.h
mitk::RESTManager
this is a microservice for managing REST-requests, used for non-qt applications.
Definition: mitkRESTManager.h:29
mitk::Handle
Helper Class for realizing the handles of bounding object encapsulated by a geometry data.
Definition: mitkBoundingShapeUtil.h:38
mitk::IRESTObserver
Definition: mitkIRESTObserver.h:24
MitkRESTServiceExports.h
mitk::MitkMultilabelIOMimeTypes::Get
MITKMULTILABELIO_EXPORT std::vector< CustomMimeType * > Get()
mitk::IRESTManager::RequestType
RequestType
request type for client requests by calling SendRequest
Definition: mitkIRESTManager.h:42
MITKRESTSERVICE_EXPORT
#define MITKRESTSERVICE_EXPORT
Definition: MitkRESTServiceExports.h:15