Mercurial > hg > orthanc-stone
comparison Framework/Oracle/GetOrthancImageCommand.h @ 746:d716bfb3e07c
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 22 May 2019 12:48:57 +0200 |
parents | |
children | 81b29bc7c3d4 2d8ab34c8c91 |
comparison
equal
deleted
inserted
replaced
745:c44c1d2d3598 | 746:d716bfb3e07c |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
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. | |
16 * | |
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 | |
24 #include "../Messages/IMessageEmitter.h" | |
25 #include "OracleCommandWithPayload.h" | |
26 | |
27 #include <Core/Images/ImageAccessor.h> | |
28 | |
29 #include <map> | |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class GetOrthancImageCommand : public OracleCommandWithPayload | |
34 { | |
35 public: | |
36 typedef std::map<std::string, std::string> HttpHeaders; | |
37 | |
38 class SuccessMessage : public OriginMessage<GetOrthancImageCommand> | |
39 { | |
40 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
41 | |
42 private: | |
43 std::auto_ptr<Orthanc::ImageAccessor> image_; | |
44 Orthanc::MimeType mime_; | |
45 | |
46 public: | |
47 SuccessMessage(const GetOrthancImageCommand& command, | |
48 Orthanc::ImageAccessor* image, // Takes ownership | |
49 Orthanc::MimeType mime); | |
50 | |
51 const Orthanc::ImageAccessor& GetImage() const | |
52 { | |
53 return *image_; | |
54 } | |
55 | |
56 Orthanc::MimeType GetMimeType() const | |
57 { | |
58 return mime_; | |
59 } | |
60 }; | |
61 | |
62 | |
63 private: | |
64 std::string uri_; | |
65 HttpHeaders headers_; | |
66 unsigned int timeout_; | |
67 bool hasExpectedFormat_; | |
68 Orthanc::PixelFormat expectedFormat_; | |
69 | |
70 public: | |
71 GetOrthancImageCommand(); | |
72 | |
73 virtual Type GetType() const | |
74 { | |
75 return Type_GetOrthancImage; | |
76 } | |
77 | |
78 void SetExpectedPixelFormat(Orthanc::PixelFormat format); | |
79 | |
80 void SetUri(const std::string& uri) | |
81 { | |
82 uri_ = uri; | |
83 } | |
84 | |
85 void SetInstanceUri(const std::string& instance, | |
86 Orthanc::PixelFormat pixelFormat); | |
87 | |
88 void SetHttpHeader(const std::string& key, | |
89 const std::string& value) | |
90 { | |
91 headers_[key] = value; | |
92 } | |
93 | |
94 const std::string& GetUri() const | |
95 { | |
96 return uri_; | |
97 } | |
98 | |
99 const HttpHeaders& GetHttpHeaders() const | |
100 { | |
101 return headers_; | |
102 } | |
103 | |
104 void SetTimeout(unsigned int seconds) | |
105 { | |
106 timeout_ = seconds; | |
107 } | |
108 | |
109 unsigned int GetTimeout() const | |
110 { | |
111 return timeout_; | |
112 } | |
113 | |
114 void ProcessHttpAnswer(IMessageEmitter& emitter, | |
115 const IObserver& receiver, | |
116 const std::string& answer, | |
117 const HttpHeaders& answerHeaders) const; | |
118 }; | |
119 } |