comparison Framework/Toolbox/OrthancApiClient.h @ 726:4f2416d519b4

moving layers, widgets and loaders to Deprecated namespace
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 11:43:25 +0200
parents f0008c55e5f7
children
comparison
equal deleted inserted replaced
714:d2c0e347ddc2 726:4f2416d519b4
26 26
27 #include "IWebService.h" 27 #include "IWebService.h"
28 #include "../Messages/IObservable.h" 28 #include "../Messages/IObservable.h"
29 #include "../Messages/Promise.h" 29 #include "../Messages/Promise.h"
30 30
31 namespace OrthancStone 31 namespace Deprecated
32 { 32 {
33 class OrthancApiClient : 33 class OrthancApiClient :
34 public IObservable, 34 public OrthancStone::IObservable,
35 public IObserver 35 public OrthancStone::IObserver
36 { 36 {
37 public: 37 public:
38 class JsonResponseReadyMessage : public IMessage 38 class JsonResponseReadyMessage : public OrthancStone::IMessage
39 { 39 {
40 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); 40 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
41 41
42 private: 42 private:
43 const std::string& uri_; 43 const std::string& uri_;
71 71
72 const Orthanc::IDynamicObject& GetPayload() const; 72 const Orthanc::IDynamicObject& GetPayload() const;
73 }; 73 };
74 74
75 75
76 class BinaryResponseReadyMessage : public IMessage 76 class BinaryResponseReadyMessage : public OrthancStone::IMessage
77 { 77 {
78 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); 78 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
79 79
80 private: 80 private:
81 const std::string& uri_; 81 const std::string& uri_;
117 117
118 const Orthanc::IDynamicObject& GetPayload() const; 118 const Orthanc::IDynamicObject& GetPayload() const;
119 }; 119 };
120 120
121 121
122 class EmptyResponseReadyMessage : public IMessage 122 class EmptyResponseReadyMessage : public OrthancStone::IMessage
123 { 123 {
124 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); 124 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
125 125
126 private: 126 private:
127 const std::string& uri_; 127 const std::string& uri_;
156 protected: 156 protected:
157 IWebService& web_; 157 IWebService& web_;
158 std::string baseUrl_; 158 std::string baseUrl_;
159 159
160 public: 160 public:
161 OrthancApiClient(MessageBroker& broker, 161 OrthancApiClient(OrthancStone::MessageBroker& broker,
162 IWebService& web, 162 IWebService& web,
163 const std::string& baseUrl); 163 const std::string& baseUrl);
164 164
165 virtual ~OrthancApiClient() 165 virtual ~OrthancApiClient()
166 { 166 {
168 168
169 const std::string& GetBaseUrl() const {return baseUrl_;} 169 const std::string& GetBaseUrl() const {return baseUrl_;}
170 170
171 // schedule a GET request expecting a JSON response. 171 // schedule a GET request expecting a JSON response.
172 void GetJsonAsync(const std::string& uri, 172 void GetJsonAsync(const std::string& uri,
173 MessageHandler<JsonResponseReadyMessage>* successCallback, 173 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
174 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 174 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
175 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 175 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
176 176
177 // schedule a GET request expecting a binary response. 177 // schedule a GET request expecting a binary response.
178 void GetBinaryAsync(const std::string& uri, 178 void GetBinaryAsync(const std::string& uri,
179 const std::string& contentType, 179 const std::string& contentType,
180 MessageHandler<BinaryResponseReadyMessage>* successCallback, 180 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback,
181 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 181 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
182 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 182 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
183 183
184 // schedule a GET request expecting a binary response. 184 // schedule a GET request expecting a binary response.
185 void GetBinaryAsync(const std::string& uri, 185 void GetBinaryAsync(const std::string& uri,
186 const IWebService::HttpHeaders& headers, 186 const IWebService::HttpHeaders& headers,
187 MessageHandler<BinaryResponseReadyMessage>* successCallback, 187 OrthancStone::MessageHandler<BinaryResponseReadyMessage>* successCallback,
188 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 188 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
189 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 189 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
190 190
191 // schedule a POST request expecting a JSON response. 191 // schedule a POST request expecting a JSON response.
192 void PostBinaryAsyncExpectJson(const std::string& uri, 192 void PostBinaryAsyncExpectJson(const std::string& uri,
193 const std::string& body, 193 const std::string& body,
194 MessageHandler<JsonResponseReadyMessage>* successCallback, 194 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
195 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 195 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
196 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 196 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
197 197
198 // schedule a POST request expecting a JSON response. 198 // schedule a POST request expecting a JSON response.
199 void PostJsonAsyncExpectJson(const std::string& uri, 199 void PostJsonAsyncExpectJson(const std::string& uri,
200 const Json::Value& data, 200 const Json::Value& data,
201 MessageHandler<JsonResponseReadyMessage>* successCallback, 201 OrthancStone::MessageHandler<JsonResponseReadyMessage>* successCallback,
202 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 202 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
203 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 203 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
204 204
205 // schedule a POST request and don't mind the response. 205 // schedule a POST request and don't mind the response.
206 void PostJsonAsync(const std::string& uri, 206 void PostJsonAsync(const std::string& uri,
207 const Json::Value& data); 207 const Json::Value& data);
208 208
209 // schedule a POST request and don't expect any response. 209 // schedule a POST request and don't expect any response.
210 void PostJsonAsync(const std::string& uri, 210 void PostJsonAsync(const std::string& uri,
211 const Json::Value& data, 211 const Json::Value& data,
212 MessageHandler<EmptyResponseReadyMessage>* successCallback, 212 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
213 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 213 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
214 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 214 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
215 215
216 216
217 // schedule a POST request and don't mind the response. 217 // schedule a POST request and don't mind the response.
218 void PostBinaryAsync(const std::string& uri, 218 void PostBinaryAsync(const std::string& uri,
219 const std::string& body); 219 const std::string& body);
220 220
221 // schedule a POST request and don't expect any response. 221 // schedule a POST request and don't expect any response.
222 void PostBinaryAsync(const std::string& uri, 222 void PostBinaryAsync(const std::string& uri,
223 const std::string& body, 223 const std::string& body,
224 MessageHandler<EmptyResponseReadyMessage>* successCallback, 224 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
225 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 225 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
226 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 226 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
227 227
228 // schedule a DELETE request expecting an empty response. 228 // schedule a DELETE request expecting an empty response.
229 void DeleteAsync(const std::string& uri, 229 void DeleteAsync(const std::string& uri,
230 MessageHandler<EmptyResponseReadyMessage>* successCallback, 230 OrthancStone::MessageHandler<EmptyResponseReadyMessage>* successCallback,
231 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, 231 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,
232 Orthanc::IDynamicObject* payload = NULL /* takes ownership */); 232 Orthanc::IDynamicObject* payload = NULL /* takes ownership */);
233 233
234 void NotifyHttpSuccess(const IWebService::HttpRequestSuccessMessage& message); 234 void NotifyHttpSuccess(const IWebService::HttpRequestSuccessMessage& message);
235 235
236 void NotifyHttpError(const IWebService::HttpRequestErrorMessage& message); 236 void NotifyHttpError(const IWebService::HttpRequestErrorMessage& message);