comparison Platforms/Wasm/WasmWebService.h @ 434:3a8bcc45c221 am-vsol-upgrade

moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
author am@osimis.io
date Mon, 03 Dec 2018 18:03:30 +0100
parents 26b90b110719
children e641d3978856
comparison
equal deleted inserted replaced
433:8999823db8b8 434:3a8bcc45c221
3 #include <Framework/Toolbox/IWebService.h> 3 #include <Framework/Toolbox/IWebService.h>
4 #include <Core/OrthancException.h> 4 #include <Core/OrthancException.h>
5 5
6 namespace OrthancStone 6 namespace OrthancStone
7 { 7 {
8 class WasmWebService : public IWebService 8 class WasmWebService : public IWebService
9 {
10 private:
11 static MessageBroker *broker_;
12
13 // Private constructor => Singleton design pattern
14 WasmWebService(MessageBroker &broker) : IWebService(broker)
9 { 15 {
10 private: 16 }
11 static MessageBroker* broker_;
12 17
13 // Private constructor => Singleton design pattern 18 public:
14 WasmWebService(MessageBroker& broker) : 19 static WasmWebService &GetInstance()
15 IWebService(broker) 20 {
21 if (broker_ == NULL)
16 { 22 {
23 printf("WasmWebService::GetInstance(): broker not initialized\n");
24 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
17 } 25 }
26 static WasmWebService instance(*broker_);
27 return instance;
28 }
18 29
19 public: 30 static void SetBroker(MessageBroker &broker)
20 static WasmWebService& GetInstance() 31 {
21 { 32 broker_ = &broker;
22 if (broker_ == NULL) 33 }
23 {
24 printf("WasmWebService::GetInstance(): broker not initialized\n");
25 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
26 }
27 static WasmWebService instance(*broker_);
28 return instance;
29 }
30 34
31 static void SetBroker(MessageBroker& broker) 35 virtual void GetAsyncInternal(const std::string &uri,
32 { 36 const HttpHeaders &headers,
33 broker_ = &broker; 37 Orthanc::IDynamicObject *payload,
34 } 38 MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
39 MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
40 unsigned int timeoutInSeconds = 60);
35 41
36 virtual void GetAsync(const std::string& uri, 42 virtual void PostAsync(const std::string &uri,
37 const HttpHeaders& headers, 43 const HttpHeaders &headers,
38 Orthanc::IDynamicObject* payload, 44 const std::string &body,
39 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, 45 Orthanc::IDynamicObject *payload,
40 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL, 46 MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
41 unsigned int timeoutInSeconds = 60); 47 MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
48 unsigned int timeoutInSeconds = 60);
42 49
43 virtual void PostAsync(const std::string& uri, 50 virtual void DeleteAsync(const std::string &uri,
44 const HttpHeaders& headers, 51 const HttpHeaders &headers,
45 const std::string& body, 52 Orthanc::IDynamicObject *payload,
46 Orthanc::IDynamicObject* payload, 53 MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
47 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, 54 MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
48 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL,
49 unsigned int timeoutInSeconds = 60); 55 unsigned int timeoutInSeconds = 60);
50 56
51 virtual void DeleteAsync(const std::string& uri, 57 // virtual void Start()
52 const HttpHeaders& headers, 58 // {
53 Orthanc::IDynamicObject* payload, 59 // }
54 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable,
55 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL,
56 unsigned int timeoutInSeconds = 60);
57 60
58 // virtual void Start() 61 // virtual void Stop()
59 // { 62 // {
60 // } 63 // }
61 64 };
62 // virtual void Stop() 65 } // namespace OrthancStone
63 // {
64 // }
65 };
66 }