Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/GetOrthancImageCommand.h @ 2087:51c8b21b81e4
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 18:11:13 +0100 |
parents | 07964689cb0b |
children | c23eef785569 |
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 | |
2077
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
746 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
746 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
746 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "../Messages/IMessageEmitter.h" | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
27 #include "OracleCommandBase.h" |
746 | 28 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
29 #include <Images/ImageAccessor.h> |
746 | 30 |
31 #include <map> | |
32 | |
33 namespace OrthancStone | |
34 { | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1098
diff
changeset
|
35 class GetOrthancImageCommand : public OracleCommandBase |
746 | 36 { |
37 public: | |
38 typedef std::map<std::string, std::string> HttpHeaders; | |
39 | |
40 class SuccessMessage : public OriginMessage<GetOrthancImageCommand> | |
41 { | |
42 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
43 | |
44 private: | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
45 const Orthanc::ImageAccessor& image_; |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
46 Orthanc::MimeType mime_; |
746 | 47 |
48 public: | |
49 SuccessMessage(const GetOrthancImageCommand& command, | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
50 const Orthanc::ImageAccessor& image, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
51 Orthanc::MimeType mime) : |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
52 OriginMessage(command), |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
53 image_(image), |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
54 mime_(mime) |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
55 { |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
56 } |
746 | 57 |
58 const Orthanc::ImageAccessor& GetImage() const | |
59 { | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
60 return image_; |
746 | 61 } |
62 | |
63 Orthanc::MimeType GetMimeType() const | |
64 { | |
65 return mime_; | |
66 } | |
67 }; | |
68 | |
69 | |
70 private: | |
71 std::string uri_; | |
72 HttpHeaders headers_; | |
73 unsigned int timeout_; | |
74 bool hasExpectedFormat_; | |
75 Orthanc::PixelFormat expectedFormat_; | |
76 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
77 GetOrthancImageCommand(const GetOrthancImageCommand& other) : |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
78 uri_(other.uri_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
79 headers_(other.headers_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
80 timeout_(other.timeout_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
81 hasExpectedFormat_(other.hasExpectedFormat_), |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
82 expectedFormat_(other.expectedFormat_) |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
83 { |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
84 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
85 |
746 | 86 public: |
87 GetOrthancImageCommand(); | |
88 | |
1571 | 89 virtual Type GetType() const ORTHANC_OVERRIDE |
746 | 90 { |
91 return Type_GetOrthancImage; | |
92 } | |
93 | |
1571 | 94 virtual IOracleCommand* Clone() const ORTHANC_OVERRIDE |
1135
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 return new GetOrthancImageCommand(*this); |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
97 } |
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
98 |
746 | 99 void SetExpectedPixelFormat(Orthanc::PixelFormat format); |
100 | |
101 void SetUri(const std::string& uri) | |
102 { | |
103 uri_ = uri; | |
104 } | |
105 | |
106 void SetInstanceUri(const std::string& instance, | |
107 Orthanc::PixelFormat pixelFormat); | |
108 | |
1152
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
109 void SetFrameUri(const std::string& instance, |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
110 unsigned int frame, |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
111 Orthanc::PixelFormat pixelFormat); |
78b8bfe154bc
GetOrthancImageCommand::SetFrameUri()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
112 |
746 | 113 void SetHttpHeader(const std::string& key, |
114 const std::string& value) | |
115 { | |
116 headers_[key] = value; | |
117 } | |
118 | |
119 const std::string& GetUri() const | |
120 { | |
121 return uri_; | |
122 } | |
123 | |
124 const HttpHeaders& GetHttpHeaders() const | |
125 { | |
126 return headers_; | |
127 } | |
128 | |
129 void SetTimeout(unsigned int seconds) | |
130 { | |
131 timeout_ = seconds; | |
132 } | |
133 | |
134 unsigned int GetTimeout() const | |
135 { | |
136 return timeout_; | |
137 } | |
138 | |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
139 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
|
140 IMessageEmitter& emitter, |
746 | 141 const std::string& answer, |
142 const HttpHeaders& answerHeaders) const; | |
143 }; | |
144 } |