Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.h @ 2130:ed2c704b1119 StoneWebViewer-2.1
closing StoneWebViewer-2.1
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 17:08:23 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
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 | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
746 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
746 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
746 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../Messages/IMessageEmitter.h" | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
26 #include "OracleCommandBase.h" |
746 | 27 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
28 #include <Images/ImageAccessor.h> |
746 | 29 |
30 #include <map> | |
31 | |
32 namespace OrthancStone | |
33 { | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
34 class GetOrthancWebViewerJpegCommand : public OracleCommandBase |
746 | 35 { |
36 public: | |
37 typedef std::map<std::string, std::string> HttpHeaders; | |
38 | |
39 class SuccessMessage : public OriginMessage<GetOrthancWebViewerJpegCommand> | |
40 { | |
41 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
42 | |
43 private: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
44 const Orthanc::ImageAccessor& image_; |
746 | 45 |
46 public: | |
47 SuccessMessage(const GetOrthancWebViewerJpegCommand& 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) : |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
49 OriginMessage(command), |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
50 image_(image) |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
51 { |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
52 } |
746 | 53 |
54 const Orthanc::ImageAccessor& GetImage() const | |
55 { | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
56 return image_; |
746 | 57 } |
58 }; | |
59 | |
60 private: | |
61 std::string instanceId_; | |
62 unsigned int frame_; | |
63 unsigned int quality_; | |
64 HttpHeaders headers_; | |
65 unsigned int timeout_; | |
66 Orthanc::PixelFormat expectedFormat_; | |
67 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
68 GetOrthancWebViewerJpegCommand(const GetOrthancWebViewerJpegCommand& other) : |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
69 instanceId_(other.instanceId_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
70 frame_(other.frame_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
71 quality_(other.quality_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
72 headers_(other.headers_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
73 timeout_(other.timeout_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
74 expectedFormat_(other.expectedFormat_) |
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 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
77 |
746 | 78 public: |
79 GetOrthancWebViewerJpegCommand(); | |
80 | |
1571 | 81 virtual Type GetType() const ORTHANC_OVERRIDE |
746 | 82 { |
83 return Type_GetOrthancWebViewerJpeg; | |
84 } | |
85 | |
1571 | 86 virtual IOracleCommand* Clone() const ORTHANC_OVERRIDE |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
87 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
88 return new GetOrthancWebViewerJpegCommand(*this); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
89 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
90 |
746 | 91 void SetExpectedPixelFormat(Orthanc::PixelFormat format) |
92 { | |
93 expectedFormat_ = format; | |
94 } | |
95 | |
96 void SetInstance(const std::string& instanceId) | |
97 { | |
98 instanceId_ = instanceId; | |
99 } | |
100 | |
101 void SetFrame(unsigned int frame) | |
102 { | |
103 frame_ = frame; | |
104 } | |
105 | |
106 void SetQuality(unsigned int quality); | |
107 | |
108 void SetHttpHeader(const std::string& key, | |
109 const std::string& value) | |
110 { | |
111 headers_[key] = value; | |
112 } | |
113 | |
114 Orthanc::PixelFormat GetExpectedPixelFormat() const | |
115 { | |
116 return expectedFormat_; | |
117 } | |
118 | |
119 const std::string& GetInstanceId() const | |
120 { | |
121 return instanceId_; | |
122 } | |
123 | |
124 unsigned int GetFrame() const | |
125 { | |
126 return frame_; | |
127 } | |
128 | |
129 unsigned int GetQuality() const | |
130 { | |
131 return quality_; | |
132 } | |
133 | |
134 const HttpHeaders& GetHttpHeaders() const | |
135 { | |
136 return headers_; | |
137 } | |
138 | |
139 void SetTimeout(unsigned int seconds) | |
140 { | |
141 timeout_ = seconds; | |
142 } | |
143 | |
144 unsigned int GetTimeout() const | |
145 { | |
146 return timeout_; | |
147 } | |
148 | |
149 std::string GetUri() const; | |
150 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
151 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
|
152 IMessageEmitter& emitter, |
746 | 153 const std::string& answer) const; |
154 }; | |
155 } |