Mercurial > hg > orthanc-stone
annotate Framework/Oracle/GetOrthancImageCommand.h @ 1303:83af7e562b45 broker
IGeometryProvider interface for deprecated loaders (required for AB testing in older app)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 04 Mar 2020 09:44:09 +0100 |
parents | 7ec8fea061b9 |
children | 257f2c9a02ac |
rev | line source |
---|---|
746 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
746
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
746 | 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" | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
25 #include "OracleCommandBase.h" |
746 | 26 |
27 #include <Core/Images/ImageAccessor.h> | |
28 | |
29 #include <map> | |
30 | |
31 namespace OrthancStone | |
32 { | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
33 class GetOrthancImageCommand : public OracleCommandBase |
746 | 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: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
43 const Orthanc::ImageAccessor& image_; |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
44 Orthanc::MimeType mime_; |
746 | 45 |
46 public: | |
47 SuccessMessage(const GetOrthancImageCommand& command, | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
48 const Orthanc::ImageAccessor& image, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
49 Orthanc::MimeType mime) : |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
50 OriginMessage(command), |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
51 image_(image), |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
52 mime_(mime) |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
53 { |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
54 } |
746 | 55 |
56 const Orthanc::ImageAccessor& GetImage() const | |
57 { | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
58 return image_; |
746 | 59 } |
60 | |
61 Orthanc::MimeType GetMimeType() const | |
62 { | |
63 return mime_; | |
64 } | |
65 }; | |
66 | |
67 | |
68 private: | |
69 std::string uri_; | |
70 HttpHeaders headers_; | |
71 unsigned int timeout_; | |
72 bool hasExpectedFormat_; | |
73 Orthanc::PixelFormat expectedFormat_; | |
74 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
75 GetOrthancImageCommand(const GetOrthancImageCommand& other) : |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
76 uri_(other.uri_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
77 headers_(other.headers_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
78 timeout_(other.timeout_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
79 hasExpectedFormat_(other.hasExpectedFormat_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
80 expectedFormat_(other.expectedFormat_) |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
81 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
82 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
83 |
746 | 84 public: |
85 GetOrthancImageCommand(); | |
86 | |
87 virtual Type GetType() const | |
88 { | |
89 return Type_GetOrthancImage; | |
90 } | |
91 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
92 virtual IOracleCommand* Clone() const |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
93 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
94 return new GetOrthancImageCommand(*this); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
95 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
96 |
746 | 97 void SetExpectedPixelFormat(Orthanc::PixelFormat format); |
98 | |
99 void SetUri(const std::string& uri) | |
100 { | |
101 uri_ = uri; | |
102 } | |
103 | |
104 void SetInstanceUri(const std::string& instance, | |
105 Orthanc::PixelFormat pixelFormat); | |
106 | |
1152
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
107 void SetFrameUri(const std::string& instance, |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
108 unsigned int frame, |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
109 Orthanc::PixelFormat pixelFormat); |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
110 |
746 | 111 void SetHttpHeader(const std::string& key, |
112 const std::string& value) | |
113 { | |
114 headers_[key] = value; | |
115 } | |
116 | |
117 const std::string& GetUri() const | |
118 { | |
119 return uri_; | |
120 } | |
121 | |
122 const HttpHeaders& GetHttpHeaders() const | |
123 { | |
124 return headers_; | |
125 } | |
126 | |
127 void SetTimeout(unsigned int seconds) | |
128 { | |
129 timeout_ = seconds; | |
130 } | |
131 | |
132 unsigned int GetTimeout() const | |
133 { | |
134 return timeout_; | |
135 } | |
136 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
137 void ProcessHttpAnswer(boost::weak_ptr<IObserver> receiver, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
138 IMessageEmitter& emitter, |
746 | 139 const std::string& answer, |
140 const HttpHeaders& answerHeaders) const; | |
141 }; | |
142 } |