Mercurial > hg > orthanc-stone
annotate Framework/Oracle/GetOrthancWebViewerJpegCommand.h @ 1186:3284c3fd96ad broker
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 22 Nov 2019 09:51:47 +0100 |
parents | a0a33e5ea5bb |
children | 0ca50d275b9a |
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 | |
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 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
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 GetOrthancWebViewerJpegCommand : public OracleCommandBase |
746 | 34 { |
35 public: | |
36 typedef std::map<std::string, std::string> HttpHeaders; | |
37 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
38 class SuccessMessage : public OriginMessage<GetOrthancWebViewerJpegCommand> |
746 | 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_; |
746 | 44 |
45 public: | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
46 SuccessMessage(const GetOrthancWebViewerJpegCommand& command, |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
47 const Orthanc::ImageAccessor& image) : |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
48 OriginMessage(command), |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
49 image_(image) |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
50 { |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
51 } |
746 | 52 |
53 const Orthanc::ImageAccessor& GetImage() const | |
54 { | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
55 return image_; |
746 | 56 } |
57 }; | |
58 | |
59 private: | |
60 std::string instanceId_; | |
61 unsigned int frame_; | |
62 unsigned int quality_; | |
63 HttpHeaders headers_; | |
64 unsigned int timeout_; | |
65 Orthanc::PixelFormat expectedFormat_; | |
66 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
67 GetOrthancWebViewerJpegCommand(const GetOrthancWebViewerJpegCommand& other) : |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
68 instanceId_(other.instanceId_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
69 frame_(other.frame_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
70 quality_(other.quality_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
71 headers_(other.headers_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
72 timeout_(other.timeout_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
73 expectedFormat_(other.expectedFormat_) |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
74 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
75 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
76 |
746 | 77 public: |
78 GetOrthancWebViewerJpegCommand(); | |
79 | |
80 virtual Type GetType() const | |
81 { | |
82 return Type_GetOrthancWebViewerJpeg; | |
83 } | |
84 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
85 virtual IOracleCommand* Clone() const |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
86 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
87 return new GetOrthancWebViewerJpegCommand(*this); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
88 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
89 |
746 | 90 void SetExpectedPixelFormat(Orthanc::PixelFormat format) |
91 { | |
92 expectedFormat_ = format; | |
93 } | |
94 | |
95 void SetInstance(const std::string& instanceId) | |
96 { | |
97 instanceId_ = instanceId; | |
98 } | |
99 | |
100 void SetFrame(unsigned int frame) | |
101 { | |
102 frame_ = frame; | |
103 } | |
104 | |
105 void SetQuality(unsigned int quality); | |
106 | |
107 void SetHttpHeader(const std::string& key, | |
108 const std::string& value) | |
109 { | |
110 headers_[key] = value; | |
111 } | |
112 | |
113 Orthanc::PixelFormat GetExpectedPixelFormat() const | |
114 { | |
115 return expectedFormat_; | |
116 } | |
117 | |
118 const std::string& GetInstanceId() const | |
119 { | |
120 return instanceId_; | |
121 } | |
122 | |
123 unsigned int GetFrame() const | |
124 { | |
125 return frame_; | |
126 } | |
127 | |
128 unsigned int GetQuality() const | |
129 { | |
130 return quality_; | |
131 } | |
132 | |
133 const HttpHeaders& GetHttpHeaders() const | |
134 { | |
135 return headers_; | |
136 } | |
137 | |
138 void SetTimeout(unsigned int seconds) | |
139 { | |
140 timeout_ = seconds; | |
141 } | |
142 | |
143 unsigned int GetTimeout() const | |
144 { | |
145 return timeout_; | |
146 } | |
147 | |
148 std::string GetUri() const; | |
149 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
150 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
|
151 IMessageEmitter& emitter, |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
152 const std::string& answer) const; |
746 | 153 }; |
154 } |