Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/PluginsEnumerations.cpp @ 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/PluginsEnumerations.cpp@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 #include "../../OrthancServer/PrecompiledHeadersServer.h" | |
35 #include "PluginsEnumerations.h" | |
36 | |
37 #if ORTHANC_ENABLE_PLUGINS != 1 | |
38 #error The plugin support is disabled | |
39 #endif | |
40 | |
41 | |
42 #include "../../Core/OrthancException.h" | |
43 | |
44 namespace Orthanc | |
45 { | |
46 namespace Compatibility | |
47 { | |
48 OrthancPluginIdentifierConstraint Convert(IdentifierConstraintType constraint) | |
49 { | |
50 switch (constraint) | |
51 { | |
52 case Compatibility::IdentifierConstraintType_Equal: | |
53 return OrthancPluginIdentifierConstraint_Equal; | |
54 | |
55 case Compatibility::IdentifierConstraintType_GreaterOrEqual: | |
56 return OrthancPluginIdentifierConstraint_GreaterOrEqual; | |
57 | |
58 case Compatibility::IdentifierConstraintType_SmallerOrEqual: | |
59 return OrthancPluginIdentifierConstraint_SmallerOrEqual; | |
60 | |
61 case Compatibility::IdentifierConstraintType_Wildcard: | |
62 return OrthancPluginIdentifierConstraint_Wildcard; | |
63 | |
64 default: | |
65 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
66 } | |
67 } | |
68 | |
69 | |
70 IdentifierConstraintType Convert(OrthancPluginIdentifierConstraint constraint) | |
71 { | |
72 switch (constraint) | |
73 { | |
74 case OrthancPluginIdentifierConstraint_Equal: | |
75 return Compatibility::IdentifierConstraintType_Equal; | |
76 | |
77 case OrthancPluginIdentifierConstraint_GreaterOrEqual: | |
78 return Compatibility::IdentifierConstraintType_GreaterOrEqual; | |
79 | |
80 case OrthancPluginIdentifierConstraint_SmallerOrEqual: | |
81 return Compatibility::IdentifierConstraintType_SmallerOrEqual; | |
82 | |
83 case OrthancPluginIdentifierConstraint_Wildcard: | |
84 return Compatibility::IdentifierConstraintType_Wildcard; | |
85 | |
86 default: | |
87 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
88 } | |
89 } | |
90 } | |
91 | |
92 | |
93 namespace Plugins | |
94 { | |
95 OrthancPluginChangeType Convert(ChangeType type) | |
96 { | |
97 switch (type) | |
98 { | |
99 case ChangeType_CompletedSeries: | |
100 return OrthancPluginChangeType_CompletedSeries; | |
101 | |
102 case ChangeType_Deleted: | |
103 return OrthancPluginChangeType_Deleted; | |
104 | |
105 case ChangeType_NewChildInstance: | |
106 return OrthancPluginChangeType_NewChildInstance; | |
107 | |
108 case ChangeType_NewInstance: | |
109 return OrthancPluginChangeType_NewInstance; | |
110 | |
111 case ChangeType_NewPatient: | |
112 return OrthancPluginChangeType_NewPatient; | |
113 | |
114 case ChangeType_NewSeries: | |
115 return OrthancPluginChangeType_NewSeries; | |
116 | |
117 case ChangeType_NewStudy: | |
118 return OrthancPluginChangeType_NewStudy; | |
119 | |
120 case ChangeType_StablePatient: | |
121 return OrthancPluginChangeType_StablePatient; | |
122 | |
123 case ChangeType_StableSeries: | |
124 return OrthancPluginChangeType_StableSeries; | |
125 | |
126 case ChangeType_StableStudy: | |
127 return OrthancPluginChangeType_StableStudy; | |
128 | |
129 case ChangeType_UpdatedAttachment: | |
130 return OrthancPluginChangeType_UpdatedAttachment; | |
131 | |
132 case ChangeType_UpdatedMetadata: | |
133 return OrthancPluginChangeType_UpdatedMetadata; | |
134 | |
135 default: | |
136 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
137 } | |
138 } | |
139 | |
140 | |
141 OrthancPluginPixelFormat Convert(PixelFormat format) | |
142 { | |
143 switch (format) | |
144 { | |
145 case PixelFormat_BGRA32: | |
146 return OrthancPluginPixelFormat_BGRA32; | |
147 | |
148 case PixelFormat_Float32: | |
149 return OrthancPluginPixelFormat_Float32; | |
150 | |
151 case PixelFormat_Grayscale16: | |
152 return OrthancPluginPixelFormat_Grayscale16; | |
153 | |
154 case PixelFormat_Grayscale32: | |
155 return OrthancPluginPixelFormat_Grayscale32; | |
156 | |
157 case PixelFormat_Grayscale64: | |
158 return OrthancPluginPixelFormat_Grayscale64; | |
159 | |
160 case PixelFormat_Grayscale8: | |
161 return OrthancPluginPixelFormat_Grayscale8; | |
162 | |
163 case PixelFormat_RGB24: | |
164 return OrthancPluginPixelFormat_RGB24; | |
165 | |
166 case PixelFormat_RGB48: | |
167 return OrthancPluginPixelFormat_RGB48; | |
168 | |
169 case PixelFormat_RGBA32: | |
170 return OrthancPluginPixelFormat_RGBA32; | |
171 | |
172 case PixelFormat_SignedGrayscale16: | |
173 return OrthancPluginPixelFormat_SignedGrayscale16; | |
174 | |
175 default: | |
176 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
177 } | |
178 } | |
179 | |
180 | |
181 PixelFormat Convert(OrthancPluginPixelFormat format) | |
182 { | |
183 switch (format) | |
184 { | |
185 case OrthancPluginPixelFormat_BGRA32: | |
186 return PixelFormat_BGRA32; | |
187 | |
188 case OrthancPluginPixelFormat_Float32: | |
189 return PixelFormat_Float32; | |
190 | |
191 case OrthancPluginPixelFormat_Grayscale16: | |
192 return PixelFormat_Grayscale16; | |
193 | |
194 case OrthancPluginPixelFormat_Grayscale32: | |
195 return PixelFormat_Grayscale32; | |
196 | |
197 case OrthancPluginPixelFormat_Grayscale64: | |
198 return PixelFormat_Grayscale64; | |
199 | |
200 case OrthancPluginPixelFormat_Grayscale8: | |
201 return PixelFormat_Grayscale8; | |
202 | |
203 case OrthancPluginPixelFormat_RGB24: | |
204 return PixelFormat_RGB24; | |
205 | |
206 case OrthancPluginPixelFormat_RGB48: | |
207 return PixelFormat_RGB48; | |
208 | |
209 case OrthancPluginPixelFormat_RGBA32: | |
210 return PixelFormat_RGBA32; | |
211 | |
212 case OrthancPluginPixelFormat_SignedGrayscale16: | |
213 return PixelFormat_SignedGrayscale16; | |
214 | |
215 default: | |
216 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
217 } | |
218 } | |
219 | |
220 | |
221 OrthancPluginContentType Convert(FileContentType type) | |
222 { | |
223 switch (type) | |
224 { | |
225 case FileContentType_Dicom: | |
226 return OrthancPluginContentType_Dicom; | |
227 | |
228 case FileContentType_DicomAsJson: | |
229 return OrthancPluginContentType_DicomAsJson; | |
230 | |
231 default: | |
232 return OrthancPluginContentType_Unknown; | |
233 } | |
234 } | |
235 | |
236 | |
237 FileContentType Convert(OrthancPluginContentType type) | |
238 { | |
239 switch (type) | |
240 { | |
241 case OrthancPluginContentType_Dicom: | |
242 return FileContentType_Dicom; | |
243 | |
244 case OrthancPluginContentType_DicomAsJson: | |
245 return FileContentType_DicomAsJson; | |
246 | |
247 default: | |
248 return FileContentType_Unknown; | |
249 } | |
250 } | |
251 | |
252 | |
253 DicomToJsonFormat Convert(OrthancPluginDicomToJsonFormat format) | |
254 { | |
255 switch (format) | |
256 { | |
257 case OrthancPluginDicomToJsonFormat_Full: | |
258 return DicomToJsonFormat_Full; | |
259 | |
260 case OrthancPluginDicomToJsonFormat_Short: | |
261 return DicomToJsonFormat_Short; | |
262 | |
263 case OrthancPluginDicomToJsonFormat_Human: | |
264 return DicomToJsonFormat_Human; | |
265 | |
266 default: | |
267 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
268 } | |
269 } | |
270 | |
271 | |
272 OrthancPluginInstanceOrigin Convert(RequestOrigin origin) | |
273 { | |
274 switch (origin) | |
275 { | |
276 case RequestOrigin_DicomProtocol: | |
277 return OrthancPluginInstanceOrigin_DicomProtocol; | |
278 | |
279 case RequestOrigin_RestApi: | |
280 return OrthancPluginInstanceOrigin_RestApi; | |
281 | |
282 case RequestOrigin_Lua: | |
283 return OrthancPluginInstanceOrigin_Lua; | |
284 | |
285 case RequestOrigin_Plugins: | |
286 return OrthancPluginInstanceOrigin_Plugin; | |
287 | |
288 case RequestOrigin_Unknown: | |
289 return OrthancPluginInstanceOrigin_Unknown; | |
290 | |
291 default: | |
292 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
293 } | |
294 } | |
295 | |
296 | |
297 OrthancPluginHttpMethod Convert(HttpMethod method) | |
298 { | |
299 switch (method) | |
300 { | |
301 case HttpMethod_Get: | |
302 return OrthancPluginHttpMethod_Get; | |
303 | |
304 case HttpMethod_Post: | |
305 return OrthancPluginHttpMethod_Post; | |
306 | |
307 case HttpMethod_Put: | |
308 return OrthancPluginHttpMethod_Put; | |
309 | |
310 case HttpMethod_Delete: | |
311 return OrthancPluginHttpMethod_Delete; | |
312 | |
313 default: | |
314 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
315 } | |
316 } | |
317 | |
318 | |
319 ValueRepresentation Convert(OrthancPluginValueRepresentation vr) | |
320 { | |
321 switch (vr) | |
322 { | |
323 case OrthancPluginValueRepresentation_AE: | |
324 return ValueRepresentation_ApplicationEntity; | |
325 | |
326 case OrthancPluginValueRepresentation_AS: | |
327 return ValueRepresentation_AgeString; | |
328 | |
329 case OrthancPluginValueRepresentation_AT: | |
330 return ValueRepresentation_AttributeTag; | |
331 | |
332 case OrthancPluginValueRepresentation_CS: | |
333 return ValueRepresentation_CodeString; | |
334 | |
335 case OrthancPluginValueRepresentation_DA: | |
336 return ValueRepresentation_Date; | |
337 | |
338 case OrthancPluginValueRepresentation_DS: | |
339 return ValueRepresentation_DecimalString; | |
340 | |
341 case OrthancPluginValueRepresentation_DT: | |
342 return ValueRepresentation_DateTime; | |
343 | |
344 case OrthancPluginValueRepresentation_FD: | |
345 return ValueRepresentation_FloatingPointDouble; | |
346 | |
347 case OrthancPluginValueRepresentation_FL: | |
348 return ValueRepresentation_FloatingPointSingle; | |
349 | |
350 case OrthancPluginValueRepresentation_IS: | |
351 return ValueRepresentation_IntegerString; | |
352 | |
353 case OrthancPluginValueRepresentation_LO: | |
354 return ValueRepresentation_LongString; | |
355 | |
356 case OrthancPluginValueRepresentation_LT: | |
357 return ValueRepresentation_LongText; | |
358 | |
359 case OrthancPluginValueRepresentation_OB: | |
360 return ValueRepresentation_OtherByte; | |
361 | |
362 case OrthancPluginValueRepresentation_OF: | |
363 return ValueRepresentation_OtherFloat; | |
364 | |
365 case OrthancPluginValueRepresentation_OW: | |
366 return ValueRepresentation_OtherWord; | |
367 | |
368 case OrthancPluginValueRepresentation_PN: | |
369 return ValueRepresentation_PersonName; | |
370 | |
371 case OrthancPluginValueRepresentation_SH: | |
372 return ValueRepresentation_ShortString; | |
373 | |
374 case OrthancPluginValueRepresentation_SL: | |
375 return ValueRepresentation_SignedLong; | |
376 | |
377 case OrthancPluginValueRepresentation_SQ: | |
378 return ValueRepresentation_Sequence; | |
379 | |
380 case OrthancPluginValueRepresentation_SS: | |
381 return ValueRepresentation_SignedShort; | |
382 | |
383 case OrthancPluginValueRepresentation_ST: | |
384 return ValueRepresentation_ShortText; | |
385 | |
386 case OrthancPluginValueRepresentation_TM: | |
387 return ValueRepresentation_Time; | |
388 | |
389 case OrthancPluginValueRepresentation_UI: | |
390 return ValueRepresentation_UniqueIdentifier; | |
391 | |
392 case OrthancPluginValueRepresentation_UL: | |
393 return ValueRepresentation_UnsignedLong; | |
394 | |
395 case OrthancPluginValueRepresentation_UN: | |
396 return ValueRepresentation_Unknown; | |
397 | |
398 case OrthancPluginValueRepresentation_US: | |
399 return ValueRepresentation_UnsignedShort; | |
400 | |
401 case OrthancPluginValueRepresentation_UT: | |
402 return ValueRepresentation_UnlimitedText; | |
403 | |
404 default: | |
405 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
406 | |
407 /* | |
408 Not supported as of DCMTK 3.6.0: | |
409 return ValueRepresentation_OtherDouble | |
410 return ValueRepresentation_OtherLong | |
411 return ValueRepresentation_UniversalResource | |
412 return ValueRepresentation_UnlimitedCharacters | |
413 */ | |
414 } | |
415 } | |
416 | |
417 | |
418 OrthancPluginValueRepresentation Convert(ValueRepresentation vr) | |
419 { | |
420 switch (vr) | |
421 { | |
422 case ValueRepresentation_ApplicationEntity: | |
423 return OrthancPluginValueRepresentation_AE; | |
424 | |
425 case ValueRepresentation_AgeString: | |
426 return OrthancPluginValueRepresentation_AS; | |
427 | |
428 case ValueRepresentation_AttributeTag: | |
429 return OrthancPluginValueRepresentation_AT; | |
430 | |
431 case ValueRepresentation_CodeString: | |
432 return OrthancPluginValueRepresentation_CS; | |
433 | |
434 case ValueRepresentation_Date: | |
435 return OrthancPluginValueRepresentation_DA; | |
436 | |
437 case ValueRepresentation_DecimalString: | |
438 return OrthancPluginValueRepresentation_DS; | |
439 | |
440 case ValueRepresentation_DateTime: | |
441 return OrthancPluginValueRepresentation_DT; | |
442 | |
443 case ValueRepresentation_FloatingPointDouble: | |
444 return OrthancPluginValueRepresentation_FD; | |
445 | |
446 case ValueRepresentation_FloatingPointSingle: | |
447 return OrthancPluginValueRepresentation_FL; | |
448 | |
449 case ValueRepresentation_IntegerString: | |
450 return OrthancPluginValueRepresentation_IS; | |
451 | |
452 case ValueRepresentation_LongString: | |
453 return OrthancPluginValueRepresentation_LO; | |
454 | |
455 case ValueRepresentation_LongText: | |
456 return OrthancPluginValueRepresentation_LT; | |
457 | |
458 case ValueRepresentation_OtherByte: | |
459 return OrthancPluginValueRepresentation_OB; | |
460 | |
461 case ValueRepresentation_OtherFloat: | |
462 return OrthancPluginValueRepresentation_OF; | |
463 | |
464 case ValueRepresentation_OtherWord: | |
465 return OrthancPluginValueRepresentation_OW; | |
466 | |
467 case ValueRepresentation_PersonName: | |
468 return OrthancPluginValueRepresentation_PN; | |
469 | |
470 case ValueRepresentation_ShortString: | |
471 return OrthancPluginValueRepresentation_SH; | |
472 | |
473 case ValueRepresentation_SignedLong: | |
474 return OrthancPluginValueRepresentation_SL; | |
475 | |
476 case ValueRepresentation_Sequence: | |
477 return OrthancPluginValueRepresentation_SQ; | |
478 | |
479 case ValueRepresentation_SignedShort: | |
480 return OrthancPluginValueRepresentation_SS; | |
481 | |
482 case ValueRepresentation_ShortText: | |
483 return OrthancPluginValueRepresentation_ST; | |
484 | |
485 case ValueRepresentation_Time: | |
486 return OrthancPluginValueRepresentation_TM; | |
487 | |
488 case ValueRepresentation_UniqueIdentifier: | |
489 return OrthancPluginValueRepresentation_UI; | |
490 | |
491 case ValueRepresentation_UnsignedLong: | |
492 return OrthancPluginValueRepresentation_UL; | |
493 | |
494 case ValueRepresentation_UnsignedShort: | |
495 return OrthancPluginValueRepresentation_US; | |
496 | |
497 case ValueRepresentation_UnlimitedText: | |
498 return OrthancPluginValueRepresentation_UT; | |
499 | |
500 case ValueRepresentation_Unknown: | |
501 return OrthancPluginValueRepresentation_UN; // Unknown | |
502 | |
503 // These VR are not supported as of DCMTK 3.6.0, so they are | |
504 // mapped to "UN" (unknown) VR in the plugins | |
505 case ValueRepresentation_OtherDouble: | |
506 case ValueRepresentation_OtherLong: | |
507 case ValueRepresentation_UniversalResource: | |
508 case ValueRepresentation_UnlimitedCharacters: | |
509 return OrthancPluginValueRepresentation_UN; | |
510 | |
511 default: | |
512 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
513 } | |
514 } | |
515 | |
516 | |
517 OrthancPluginJobStepStatus Convert(JobStepCode step) | |
518 { | |
519 switch (step) | |
520 { | |
521 case JobStepCode_Success: | |
522 return OrthancPluginJobStepStatus_Success; | |
523 | |
524 case JobStepCode_Failure: | |
525 return OrthancPluginJobStepStatus_Failure; | |
526 | |
527 case JobStepCode_Continue: | |
528 return OrthancPluginJobStepStatus_Continue; | |
529 | |
530 default: | |
531 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
532 } | |
533 } | |
534 | |
535 JobStepCode Convert(OrthancPluginJobStepStatus step) | |
536 { | |
537 switch (step) | |
538 { | |
539 case OrthancPluginJobStepStatus_Success: | |
540 return JobStepCode_Success; | |
541 | |
542 case OrthancPluginJobStepStatus_Failure: | |
543 return JobStepCode_Failure; | |
544 | |
545 case OrthancPluginJobStepStatus_Continue: | |
546 return JobStepCode_Continue; | |
547 | |
548 default: | |
549 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
550 } | |
551 } | |
552 | |
553 | |
554 StorageCommitmentFailureReason Convert(OrthancPluginStorageCommitmentFailureReason reason) | |
555 { | |
556 switch (reason) | |
557 { | |
558 case OrthancPluginStorageCommitmentFailureReason_Success: | |
559 return StorageCommitmentFailureReason_Success; | |
560 | |
561 case OrthancPluginStorageCommitmentFailureReason_ProcessingFailure: | |
562 return StorageCommitmentFailureReason_ProcessingFailure; | |
563 | |
564 case OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance: | |
565 return StorageCommitmentFailureReason_NoSuchObjectInstance; | |
566 | |
567 case OrthancPluginStorageCommitmentFailureReason_ResourceLimitation: | |
568 return StorageCommitmentFailureReason_ResourceLimitation; | |
569 | |
570 case OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported: | |
571 return StorageCommitmentFailureReason_ReferencedSOPClassNotSupported; | |
572 | |
573 case OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict: | |
574 return StorageCommitmentFailureReason_ClassInstanceConflict; | |
575 | |
576 case OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID: | |
577 return StorageCommitmentFailureReason_DuplicateTransactionUID; | |
578 | |
579 default: | |
580 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
581 } | |
582 } | |
583 } | |
584 } |