Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Toolbox/IWebService.h @ 988:4c9b4c4de814 toa2019090901
Fixed bug in DicomStructureSet that prevented points from being added to polygons
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 09 Sep 2019 16:15:28 +0200 |
parents | 861c080ef47b |
children | f6be9412e42a |
rev | line source |
---|---|
57 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
57 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
16 * |
57 | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
24 #include "../../Messages/IObserver.h" |
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
25 #include "../../Messages/ICallable.h" |
377 | 26 |
27 #include <Core/IDynamicObject.h> | |
28 #include <Core/Logging.h> | |
29 | |
57 | 30 #include <string> |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
31 #include <map> |
57 | 32 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
33 namespace Deprecated |
57 | 34 { |
288 | 35 // The IWebService performs HTTP requests. |
36 // Since applications can run in native or WASM environment and, since | |
37 // in a WASM environment, the WebService is asynchronous, the IWebservice | |
38 // also implements an asynchronous interface: you must schedule a request | |
39 // and you'll be notified when the response/error is ready. | |
377 | 40 class IWebService : public boost::noncopyable |
269 | 41 { |
42 protected: | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
43 OrthancStone::MessageBroker& broker_; |
377 | 44 |
269 | 45 public: |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
46 typedef std::map<std::string, std::string> HttpHeaders; |
257 | 47 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
48 class HttpRequestSuccessMessage : public OrthancStone::IMessage |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
49 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
50 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
51 |
377 | 52 private: |
53 const std::string& uri_; | |
54 const void* answer_; | |
55 size_t answerSize_; | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
56 const HttpHeaders& answerHeaders_; |
377 | 57 const Orthanc::IDynamicObject* payload_; |
58 | |
59 public: | |
301 | 60 HttpRequestSuccessMessage(const std::string& uri, |
309 | 61 const void* answer, |
62 size_t answerSize, | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
63 const HttpHeaders& answerHeaders, |
377 | 64 const Orthanc::IDynamicObject* payload) : |
65 uri_(uri), | |
66 answer_(answer), | |
67 answerSize_(answerSize), | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
68 answerHeaders_(answerHeaders), |
377 | 69 payload_(payload) |
70 { | |
71 } | |
72 | |
73 const std::string& GetUri() const | |
74 { | |
75 return uri_; | |
76 } | |
77 | |
78 const void* GetAnswer() const | |
79 { | |
80 return answer_; | |
81 } | |
82 | |
83 size_t GetAnswerSize() const | |
84 { | |
85 return answerSize_; | |
86 } | |
87 | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
88 const HttpHeaders& GetAnswerHttpHeaders() const |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
89 { |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
90 return answerHeaders_; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
91 } |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
92 |
377 | 93 bool HasPayload() const |
94 { | |
95 return payload_ != NULL; | |
96 } | |
97 | |
98 const Orthanc::IDynamicObject& GetPayload() const; | |
99 }; | |
100 | |
101 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
102 class HttpRequestErrorMessage : public OrthancStone::IMessage |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
103 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
104 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
105 |
377 | 106 private: |
107 const std::string& uri_; | |
108 const Orthanc::IDynamicObject* payload_; | |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
109 Orthanc::HttpStatus httpStatus_; |
377 | 110 |
111 public: | |
301 | 112 HttpRequestErrorMessage(const std::string& uri, |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
113 Orthanc::HttpStatus httpStatus, |
377 | 114 const Orthanc::IDynamicObject* payload) : |
115 uri_(uri), | |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
116 payload_(payload), |
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
117 httpStatus_(httpStatus) |
377 | 118 { |
119 } | |
120 | |
121 const std::string& GetUri() const | |
122 { | |
123 return uri_; | |
124 } | |
125 | |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
126 Orthanc::HttpStatus GetHttpStatus() const |
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
127 { |
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
128 return httpStatus_; |
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
129 } |
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
732
diff
changeset
|
130 |
377 | 131 bool HasPayload() const |
132 { | |
133 return payload_ != NULL; | |
134 } | |
135 | |
136 const Orthanc::IDynamicObject& GetPayload() const; | |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
137 }; |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
138 |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
139 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
140 IWebService(OrthancStone::MessageBroker& broker) : |
377 | 141 broker_(broker) |
142 { | |
143 } | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
144 |
377 | 145 |
269 | 146 virtual ~IWebService() |
147 { | |
148 } | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
149 |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
417
diff
changeset
|
150 virtual void EnableCache(bool enable) = 0; |
377 | 151 |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
152 virtual void GetAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
153 const HttpHeaders& headers, |
377 | 154 Orthanc::IDynamicObject* payload /* takes ownership */, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
155 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
156 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, |
309 | 157 unsigned int timeoutInSeconds = 60) = 0; |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
158 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
159 virtual void PostAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
160 const HttpHeaders& headers, |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
161 const std::string& body, |
377 | 162 Orthanc::IDynamicObject* payload /* takes ownership */, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
163 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
164 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, |
309 | 165 unsigned int timeoutInSeconds = 60) = 0; |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
288
diff
changeset
|
166 |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
167 virtual void DeleteAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
383
diff
changeset
|
168 const HttpHeaders& headers, |
377 | 169 Orthanc::IDynamicObject* payload /* takes ownership */, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
170 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
171 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
172 unsigned int timeoutInSeconds = 60) = 0; |
269 | 173 }; |
57 | 174 } |