Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/OrthancPlugins.h @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | Plugins/Engine/OrthancPlugins.h@1d2b31fc782f |
children | 05b8fd21089c |
comparison
equal
deleted
inserted
replaced
4043:6c6239aec462 | 4044:d25f4c0fa160 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 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 General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
36 #include "PluginsErrorDictionary.h" | |
37 | |
38 #if !defined(ORTHANC_ENABLE_PLUGINS) | |
39 # error The macro ORTHANC_ENABLE_PLUGINS must be defined | |
40 #endif | |
41 | |
42 | |
43 #if ORTHANC_ENABLE_PLUGINS != 1 | |
44 | |
45 #include <boost/noncopyable.hpp> | |
46 | |
47 namespace Orthanc | |
48 { | |
49 class OrthancPlugins : public boost::noncopyable | |
50 { | |
51 }; | |
52 } | |
53 | |
54 #else | |
55 | |
56 #include "../../Core/DicomNetworking/IFindRequestHandlerFactory.h" | |
57 #include "../../Core/DicomNetworking/IMoveRequestHandlerFactory.h" | |
58 #include "../../Core/DicomNetworking/IWorklistRequestHandlerFactory.h" | |
59 #include "../../Core/DicomParsing/MemoryBufferTranscoder.h" | |
60 #include "../../Core/FileStorage/IStorageArea.h" | |
61 #include "../../Core/HttpServer/IHttpHandler.h" | |
62 #include "../../Core/HttpServer/IIncomingHttpRequestFilter.h" | |
63 #include "../../Core/JobsEngine/IJob.h" | |
64 #include "../../OrthancServer/IDicomImageDecoder.h" | |
65 #include "../../OrthancServer/IServerListener.h" | |
66 #include "../../OrthancServer/ServerJobs/IStorageCommitmentFactory.h" | |
67 #include "OrthancPluginDatabase.h" | |
68 #include "PluginsManager.h" | |
69 | |
70 #include <list> | |
71 #include <boost/shared_ptr.hpp> | |
72 | |
73 namespace Orthanc | |
74 { | |
75 class ServerContext; | |
76 | |
77 class OrthancPlugins : | |
78 public IHttpHandler, | |
79 public IPluginServiceProvider, | |
80 public IServerListener, | |
81 public IWorklistRequestHandlerFactory, | |
82 public IDicomImageDecoder, | |
83 public IIncomingHttpRequestFilter, | |
84 public IFindRequestHandlerFactory, | |
85 public IMoveRequestHandlerFactory, | |
86 public IStorageCommitmentFactory, | |
87 public MemoryBufferTranscoder | |
88 { | |
89 private: | |
90 class PImpl; | |
91 boost::shared_ptr<PImpl> pimpl_; | |
92 | |
93 class WorklistHandler; | |
94 class FindHandler; | |
95 class MoveHandler; | |
96 class HttpClientChunkedRequest; | |
97 class HttpClientChunkedAnswer; | |
98 class HttpServerChunkedReader; | |
99 class IDicomInstance; | |
100 class DicomInstanceFromCallback; | |
101 class DicomInstanceFromBuffer; | |
102 class DicomInstanceFromTranscoded; | |
103 | |
104 void RegisterRestCallback(const void* parameters, | |
105 bool lock); | |
106 | |
107 void RegisterChunkedRestCallback(const void* parameters); | |
108 | |
109 bool HandleChunkedGetDelete(HttpOutput& output, | |
110 HttpMethod method, | |
111 const UriComponents& uri, | |
112 const Arguments& headers, | |
113 const GetArguments& getArguments); | |
114 | |
115 void RegisterOnStoredInstanceCallback(const void* parameters); | |
116 | |
117 void RegisterOnChangeCallback(const void* parameters); | |
118 | |
119 void RegisterWorklistCallback(const void* parameters); | |
120 | |
121 void RegisterFindCallback(const void* parameters); | |
122 | |
123 void RegisterMoveCallback(const void* parameters); | |
124 | |
125 void RegisterDecodeImageCallback(const void* parameters); | |
126 | |
127 void RegisterTranscoderCallback(const void* parameters); | |
128 | |
129 void RegisterJobsUnserializer(const void* parameters); | |
130 | |
131 void RegisterIncomingHttpRequestFilter(const void* parameters); | |
132 | |
133 void RegisterIncomingHttpRequestFilter2(const void* parameters); | |
134 | |
135 void RegisterIncomingDicomInstanceFilter(const void* parameters); | |
136 | |
137 void RegisterRefreshMetricsCallback(const void* parameters); | |
138 | |
139 void RegisterStorageCommitmentScpCallback(const void* parameters); | |
140 | |
141 void AnswerBuffer(const void* parameters); | |
142 | |
143 void Redirect(const void* parameters); | |
144 | |
145 void CompressAndAnswerPngImage(const void* parameters); | |
146 | |
147 void CompressAndAnswerImage(const void* parameters); | |
148 | |
149 void GetDicomForInstance(const void* parameters); | |
150 | |
151 void RestApiGet(const void* parameters, | |
152 bool afterPlugins); | |
153 | |
154 void RestApiGet2(const void* parameters); | |
155 | |
156 void RestApiPostPut(bool isPost, | |
157 const void* parameters, | |
158 bool afterPlugins); | |
159 | |
160 void RestApiDelete(const void* parameters, | |
161 bool afterPlugins); | |
162 | |
163 void LookupResource(_OrthancPluginService service, | |
164 const void* parameters); | |
165 | |
166 void AccessDicomInstance(_OrthancPluginService service, | |
167 const void* parameters); | |
168 | |
169 void AccessDicomInstance2(_OrthancPluginService service, | |
170 const void* parameters); | |
171 | |
172 void SendHttpStatusCode(const void* parameters); | |
173 | |
174 void SendHttpStatus(const void* parameters); | |
175 | |
176 void SendUnauthorized(const void* parameters); | |
177 | |
178 void SendMethodNotAllowed(const void* parameters); | |
179 | |
180 void SetCookie(const void* parameters); | |
181 | |
182 void SetHttpHeader(const void* parameters); | |
183 | |
184 void SetHttpErrorDetails(const void* parameters); | |
185 | |
186 void BufferCompression(const void* parameters); | |
187 | |
188 void UncompressImage(const void* parameters); | |
189 | |
190 void CompressImage(const void* parameters); | |
191 | |
192 void ConvertPixelFormat(const void* parameters); | |
193 | |
194 void CallHttpClient(const void* parameters); | |
195 | |
196 void CallHttpClient2(const void* parameters); | |
197 | |
198 void ChunkedHttpClient(const void* parameters); | |
199 | |
200 void CallPeerApi(const void* parameters); | |
201 | |
202 void GetFontInfo(const void* parameters); | |
203 | |
204 void DrawText(const void* parameters); | |
205 | |
206 void DatabaseAnswer(const void* parameters); | |
207 | |
208 void ApplyDicomToJson(_OrthancPluginService service, | |
209 const void* parameters); | |
210 | |
211 void ApplyCreateDicom(_OrthancPluginService service, | |
212 const void* parameters); | |
213 | |
214 void ApplyCreateImage(_OrthancPluginService service, | |
215 const void* parameters); | |
216 | |
217 void ApplyLookupDictionary(const void* parameters); | |
218 | |
219 void ApplySendMultipartItem(const void* parameters); | |
220 | |
221 void ApplySendMultipartItem2(const void* parameters); | |
222 | |
223 void ComputeHash(_OrthancPluginService service, | |
224 const void* parameters); | |
225 | |
226 void GetTagName(const void* parameters); | |
227 | |
228 void SignalChangeInternal(OrthancPluginChangeType changeType, | |
229 OrthancPluginResourceType resourceType, | |
230 const char* resource); | |
231 | |
232 bool InvokeSafeService(SharedLibrary& plugin, | |
233 _OrthancPluginService service, | |
234 const void* parameters); | |
235 | |
236 bool InvokeProtectedService(SharedLibrary& plugin, | |
237 _OrthancPluginService service, | |
238 const void* parameters); | |
239 | |
240 protected: | |
241 // From "MemoryBufferTranscoder" | |
242 virtual bool TranscodeBuffer(std::string& target, | |
243 const void* buffer, | |
244 size_t size, | |
245 const std::set<DicomTransferSyntax>& allowedSyntaxes, | |
246 bool allowNewSopInstanceUid) ORTHANC_OVERRIDE; | |
247 | |
248 public: | |
249 OrthancPlugins(); | |
250 | |
251 virtual ~OrthancPlugins(); | |
252 | |
253 void SetServerContext(ServerContext& context); | |
254 | |
255 void ResetServerContext(); | |
256 | |
257 virtual bool Handle(HttpOutput& output, | |
258 RequestOrigin origin, | |
259 const char* remoteIp, | |
260 const char* username, | |
261 HttpMethod method, | |
262 const UriComponents& uri, | |
263 const Arguments& headers, | |
264 const GetArguments& getArguments, | |
265 const void* bodyData, | |
266 size_t bodySize) ORTHANC_OVERRIDE; | |
267 | |
268 virtual bool InvokeService(SharedLibrary& plugin, | |
269 _OrthancPluginService service, | |
270 const void* parameters) ORTHANC_OVERRIDE; | |
271 | |
272 virtual void SignalChange(const ServerIndexChange& change) ORTHANC_OVERRIDE; | |
273 | |
274 virtual void SignalStoredInstance(const std::string& instanceId, | |
275 const DicomInstanceToStore& instance, | |
276 const Json::Value& simplifiedTags) ORTHANC_OVERRIDE; | |
277 | |
278 virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance, | |
279 const Json::Value& simplified) ORTHANC_OVERRIDE; | |
280 | |
281 bool HasStorageArea() const; | |
282 | |
283 IStorageArea* CreateStorageArea(); // To be freed after use | |
284 | |
285 const SharedLibrary& GetStorageAreaLibrary() const; | |
286 | |
287 bool HasDatabaseBackend() const; | |
288 | |
289 IDatabaseWrapper& GetDatabaseBackend(); | |
290 | |
291 const SharedLibrary& GetDatabaseBackendLibrary() const; | |
292 | |
293 const char* GetProperty(const char* plugin, | |
294 _OrthancPluginProperty property) const; | |
295 | |
296 void SetCommandLineArguments(int argc, char* argv[]); | |
297 | |
298 PluginsManager& GetManager(); | |
299 | |
300 const PluginsManager& GetManager() const; | |
301 | |
302 PluginsErrorDictionary& GetErrorDictionary(); | |
303 | |
304 void SignalOrthancStarted() | |
305 { | |
306 SignalChangeInternal(OrthancPluginChangeType_OrthancStarted, OrthancPluginResourceType_None, NULL); | |
307 } | |
308 | |
309 void SignalOrthancStopped() | |
310 { | |
311 SignalChangeInternal(OrthancPluginChangeType_OrthancStopped, OrthancPluginResourceType_None, NULL); | |
312 } | |
313 | |
314 void SignalJobSubmitted(const std::string& jobId) | |
315 { | |
316 SignalChangeInternal(OrthancPluginChangeType_JobSubmitted, OrthancPluginResourceType_None, jobId.c_str()); | |
317 } | |
318 | |
319 void SignalJobSuccess(const std::string& jobId) | |
320 { | |
321 SignalChangeInternal(OrthancPluginChangeType_JobSuccess, OrthancPluginResourceType_None, jobId.c_str()); | |
322 } | |
323 | |
324 void SignalJobFailure(const std::string& jobId) | |
325 { | |
326 SignalChangeInternal(OrthancPluginChangeType_JobFailure, OrthancPluginResourceType_None, jobId.c_str()); | |
327 } | |
328 | |
329 void SignalUpdatedPeers() | |
330 { | |
331 SignalChangeInternal(OrthancPluginChangeType_UpdatedPeers, OrthancPluginResourceType_None, NULL); | |
332 } | |
333 | |
334 void SignalUpdatedModalities() | |
335 { | |
336 SignalChangeInternal(OrthancPluginChangeType_UpdatedModalities, OrthancPluginResourceType_None, NULL); | |
337 } | |
338 | |
339 bool HasWorklistHandler(); | |
340 | |
341 virtual IWorklistRequestHandler* ConstructWorklistRequestHandler() ORTHANC_OVERRIDE; | |
342 | |
343 bool HasCustomImageDecoder(); | |
344 | |
345 bool HasCustomTranscoder(); | |
346 | |
347 virtual ImageAccessor* Decode(const void* dicom, | |
348 size_t size, | |
349 unsigned int frame) ORTHANC_OVERRIDE; | |
350 | |
351 virtual bool IsAllowed(HttpMethod method, | |
352 const char* uri, | |
353 const char* ip, | |
354 const char* username, | |
355 const IHttpHandler::Arguments& httpHeaders, | |
356 const IHttpHandler::GetArguments& getArguments) ORTHANC_OVERRIDE; | |
357 | |
358 bool HasFindHandler(); | |
359 | |
360 virtual IFindRequestHandler* ConstructFindRequestHandler() ORTHANC_OVERRIDE; | |
361 | |
362 bool HasMoveHandler(); | |
363 | |
364 virtual IMoveRequestHandler* ConstructMoveRequestHandler() ORTHANC_OVERRIDE; | |
365 | |
366 IJob* UnserializeJob(const std::string& type, | |
367 const Json::Value& value); | |
368 | |
369 void RefreshMetrics(); | |
370 | |
371 // New in Orthanc 1.5.7 | |
372 virtual bool CreateChunkedRequestReader(std::unique_ptr<IChunkedRequestReader>& target, | |
373 RequestOrigin origin, | |
374 const char* remoteIp, | |
375 const char* username, | |
376 HttpMethod method, | |
377 const UriComponents& uri, | |
378 const Arguments& headers) ORTHANC_OVERRIDE; | |
379 | |
380 // New in Orthanc 1.6.0 | |
381 IStorageCommitmentFactory::ILookupHandler* CreateStorageCommitment( | |
382 const std::string& jobId, | |
383 const std::string& transactionUid, | |
384 const std::vector<std::string>& sopClassUids, | |
385 const std::vector<std::string>& sopInstanceUids, | |
386 const std::string& remoteAet, | |
387 const std::string& calledAet) ORTHANC_OVERRIDE; | |
388 }; | |
389 } | |
390 | |
391 #endif |