comparison Orthanc/Core/Enumerations.h @ 78:d6da56f86e5a

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Sep 2015 11:29:17 +0200
parents
children 581937911d14
comparison
equal deleted inserted replaced
77:f44ebb25691c 78:d6da56f86e5a
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * In addition, as a special exception, the copyright holders of this
12 * program give permission to link the code of its release with the
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
14 * that use the same license as the "OpenSSL" library), and distribute
15 * the linked executables. You must obey the GNU General Public License
16 * in all respects for all of the code used other than "OpenSSL". If you
17 * modify file(s) with this exception, you may extend this exception to
18 * your version of the file(s), but you are not obligated to do so. If
19 * you do not wish to do so, delete this exception statement from your
20 * version. If you delete this exception statement from all source files
21 * in the program, then also delete it here.
22 *
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 **/
31
32
33 #pragma once
34
35 namespace Orthanc
36 {
37 enum Endianness
38 {
39 Endianness_Unknown,
40 Endianness_Big,
41 Endianness_Little
42 };
43
44 // This enumeration is autogenerated by the script
45 // "Resources/GenerateErrorCodes.py"
46 enum ErrorCode
47 {
48 ErrorCode_InternalError = -1 /*!< Internal error */,
49 ErrorCode_Success = 0 /*!< Success */,
50 ErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */,
51 ErrorCode_NotImplemented = 2 /*!< Not implemented yet */,
52 ErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */,
53 ErrorCode_NotEnoughMemory = 4 /*!< Not enough memory */,
54 ErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */,
55 ErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */,
56 ErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */,
57 ErrorCode_BadRequest = 8 /*!< Bad request */,
58 ErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */,
59 ErrorCode_SystemCommand = 10 /*!< Error while calling a system command */,
60 ErrorCode_Database = 11 /*!< Error with the database engine */,
61 ErrorCode_UriSyntax = 12 /*!< Badly formatted URI */,
62 ErrorCode_InexistentFile = 13 /*!< Inexistent file */,
63 ErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */,
64 ErrorCode_BadFileFormat = 15 /*!< Bad file format */,
65 ErrorCode_Timeout = 16 /*!< Timeout */,
66 ErrorCode_UnknownResource = 17 /*!< Unknown resource */,
67 ErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */,
68 ErrorCode_FullStorage = 19 /*!< The file storage is full */,
69 ErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */,
70 ErrorCode_InexistentTag = 21 /*!< Inexistent tag */,
71 ErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */,
72 ErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */,
73 ErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */,
74 ErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */,
75 ErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */,
76 ErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */,
77 ErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */,
78 ErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */,
79 ErrorCode_BadFont = 30 /*!< Badly formatted font file */,
80 ErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */,
81 ErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */,
82 ErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */,
83 ErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */,
84 ErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
85 ErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */,
86 ErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */,
87 ErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */,
88 ErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */,
89 ErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */,
90 ErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */,
91 ErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */,
92 ErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */,
93 ErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */,
94 ErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */,
95 ErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */,
96 ErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */,
97 ErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */,
98 ErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */,
99 ErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */,
100 ErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */,
101 ErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is already in use */,
102 ErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is already in use */,
103 ErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */,
104 ErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */,
105 ErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */,
106 ErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */,
107 ErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */,
108 ErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */,
109 ErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */,
110 ErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */,
111 ErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */,
112 ErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */,
113 ErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */,
114 ErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */,
115 ErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */,
116 ErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */,
117 ErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */,
118 ErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */,
119 ErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */,
120 ErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */,
121 ErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */,
122 ErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */,
123 ErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */,
124 ErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */,
125 ErrorCode_UnknownModality = 2027 /*!< Unknown modality */,
126 ErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */,
127 ErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */,
128 ErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */,
129 ErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */,
130 ErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */,
131 ErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */,
132 ErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */,
133 ErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */,
134 ErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */,
135 ErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */,
136 ErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */,
137 ErrorCode_START_PLUGINS = 1000000
138 };
139
140 enum LogLevel
141 {
142 LogLevel_Error,
143 LogLevel_Warning,
144 LogLevel_Info,
145 LogLevel_Trace
146 };
147
148
149 /**
150 * {summary}{The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.}
151 **/
152 enum PixelFormat
153 {
154 /**
155 * {summary}{Color image in RGB24 format.}
156 * {description}{This format describes a color image. The pixels are stored in 3
157 * consecutive bytes. The memory layout is RGB.}
158 **/
159 PixelFormat_RGB24 = 1,
160
161 /**
162 * {summary}{Color image in RGBA32 format.}
163 * {description}{This format describes a color image. The pixels are stored in 4
164 * consecutive bytes. The memory layout is RGBA.}
165 **/
166 PixelFormat_RGBA32 = 2,
167
168 /**
169 * {summary}{Graylevel 8bpp image.}
170 * {description}{The image is graylevel. Each pixel is unsigned and stored in one byte.}
171 **/
172 PixelFormat_Grayscale8 = 3,
173
174 /**
175 * {summary}{Graylevel, unsigned 16bpp image.}
176 * {description}{The image is graylevel. Each pixel is unsigned and stored in two bytes.}
177 **/
178 PixelFormat_Grayscale16 = 4,
179
180 /**
181 * {summary}{Graylevel, signed 16bpp image.}
182 * {description}{The image is graylevel. Each pixel is signed and stored in two bytes.}
183 **/
184 PixelFormat_SignedGrayscale16 = 5
185 };
186
187
188 /**
189 * {summary}{The extraction mode specifies the way the values of the pixels are scaled when downloading a 2D image.}
190 **/
191 enum ImageExtractionMode
192 {
193 /**
194 * {summary}{Rescaled to 8bpp.}
195 * {description}{The minimum value of the image is set to 0, and its maximum value is set to 255.}
196 **/
197 ImageExtractionMode_Preview = 1,
198
199 /**
200 * {summary}{Truncation to the [0, 255] range.}
201 **/
202 ImageExtractionMode_UInt8 = 2,
203
204 /**
205 * {summary}{Truncation to the [0, 65535] range.}
206 **/
207 ImageExtractionMode_UInt16 = 3,
208
209 /**
210 * {summary}{Truncation to the [-32768, 32767] range.}
211 **/
212 ImageExtractionMode_Int16 = 4
213 };
214
215
216 /**
217 * Most common, non-joke and non-experimental HTTP status codes
218 * http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
219 **/
220 enum HttpStatus
221 {
222 HttpStatus_None = -1,
223
224 // 1xx Informational
225 HttpStatus_100_Continue = 100,
226 HttpStatus_101_SwitchingProtocols = 101,
227 HttpStatus_102_Processing = 102,
228
229 // 2xx Success
230 HttpStatus_200_Ok = 200,
231 HttpStatus_201_Created = 201,
232 HttpStatus_202_Accepted = 202,
233 HttpStatus_203_NonAuthoritativeInformation = 203,
234 HttpStatus_204_NoContent = 204,
235 HttpStatus_205_ResetContent = 205,
236 HttpStatus_206_PartialContent = 206,
237 HttpStatus_207_MultiStatus = 207,
238 HttpStatus_208_AlreadyReported = 208,
239 HttpStatus_226_IMUsed = 226,
240
241 // 3xx Redirection
242 HttpStatus_300_MultipleChoices = 300,
243 HttpStatus_301_MovedPermanently = 301,
244 HttpStatus_302_Found = 302,
245 HttpStatus_303_SeeOther = 303,
246 HttpStatus_304_NotModified = 304,
247 HttpStatus_305_UseProxy = 305,
248 HttpStatus_307_TemporaryRedirect = 307,
249
250 // 4xx Client Error
251 HttpStatus_400_BadRequest = 400,
252 HttpStatus_401_Unauthorized = 401,
253 HttpStatus_402_PaymentRequired = 402,
254 HttpStatus_403_Forbidden = 403,
255 HttpStatus_404_NotFound = 404,
256 HttpStatus_405_MethodNotAllowed = 405,
257 HttpStatus_406_NotAcceptable = 406,
258 HttpStatus_407_ProxyAuthenticationRequired = 407,
259 HttpStatus_408_RequestTimeout = 408,
260 HttpStatus_409_Conflict = 409,
261 HttpStatus_410_Gone = 410,
262 HttpStatus_411_LengthRequired = 411,
263 HttpStatus_412_PreconditionFailed = 412,
264 HttpStatus_413_RequestEntityTooLarge = 413,
265 HttpStatus_414_RequestUriTooLong = 414,
266 HttpStatus_415_UnsupportedMediaType = 415,
267 HttpStatus_416_RequestedRangeNotSatisfiable = 416,
268 HttpStatus_417_ExpectationFailed = 417,
269 HttpStatus_422_UnprocessableEntity = 422,
270 HttpStatus_423_Locked = 423,
271 HttpStatus_424_FailedDependency = 424,
272 HttpStatus_426_UpgradeRequired = 426,
273
274 // 5xx Server Error
275 HttpStatus_500_InternalServerError = 500,
276 HttpStatus_501_NotImplemented = 501,
277 HttpStatus_502_BadGateway = 502,
278 HttpStatus_503_ServiceUnavailable = 503,
279 HttpStatus_504_GatewayTimeout = 504,
280 HttpStatus_505_HttpVersionNotSupported = 505,
281 HttpStatus_506_VariantAlsoNegotiates = 506,
282 HttpStatus_507_InsufficientStorage = 507,
283 HttpStatus_509_BandwidthLimitExceeded = 509,
284 HttpStatus_510_NotExtended = 510
285 };
286
287
288 enum HttpMethod
289 {
290 HttpMethod_Get = 0,
291 HttpMethod_Post = 1,
292 HttpMethod_Delete = 2,
293 HttpMethod_Put = 3
294 };
295
296
297 enum ImageFormat
298 {
299 ImageFormat_Png = 1
300 };
301
302
303 // https://en.wikipedia.org/wiki/HTTP_compression
304 enum HttpCompression
305 {
306 HttpCompression_None,
307 HttpCompression_Deflate,
308 HttpCompression_Gzip
309 };
310
311
312 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/
313 enum Encoding
314 {
315 Encoding_Ascii,
316 Encoding_Utf8,
317 Encoding_Latin1,
318 Encoding_Latin2,
319 Encoding_Latin3,
320 Encoding_Latin4,
321 Encoding_Latin5, // Turkish
322 Encoding_Cyrillic,
323 Encoding_Windows1251, // Windows-1251 (commonly used for Cyrillic)
324 Encoding_Arabic,
325 Encoding_Greek,
326 Encoding_Hebrew,
327 Encoding_Thai, // TIS 620-2533
328 Encoding_Japanese, // JIS X 0201 (Shift JIS): Katakana
329 Encoding_Chinese // GB18030 - Chinese simplified
330 //Encoding_JapaneseKanji, // Multibyte - JIS X 0208: Kanji
331 //Encoding_JapaneseSupplementaryKanji, // Multibyte - JIS X 0212: Supplementary Kanji set
332 //Encoding_Korean, // Multibyte - KS X 1001: Hangul and Hanja
333 };
334
335
336 // https://www.dabsoft.ch/dicom/3/C.7.6.3.1.2/
337 enum PhotometricInterpretation
338 {
339 PhotometricInterpretation_ARGB, // Retired
340 PhotometricInterpretation_CMYK, // Retired
341 PhotometricInterpretation_HSV, // Retired
342 PhotometricInterpretation_Monochrome1,
343 PhotometricInterpretation_Monochrome2,
344 PhotometricInterpretation_Palette,
345 PhotometricInterpretation_RGB,
346 PhotometricInterpretation_YBRFull,
347 PhotometricInterpretation_YBRFull422,
348 PhotometricInterpretation_YBRPartial420,
349 PhotometricInterpretation_YBRPartial422,
350 PhotometricInterpretation_YBR_ICT,
351 PhotometricInterpretation_YBR_RCT,
352 PhotometricInterpretation_Unknown
353 };
354
355 enum DicomModule
356 {
357 DicomModule_Patient,
358 DicomModule_Study,
359 DicomModule_Series,
360 DicomModule_Instance,
361 DicomModule_Image
362 };
363
364 enum RequestOrigin
365 {
366 RequestOrigin_Unknown,
367 RequestOrigin_DicomProtocol,
368 RequestOrigin_Http,
369 RequestOrigin_Plugins,
370 RequestOrigin_Lua
371 };
372
373
374 /**
375 * WARNING: Do not change the explicit values in the enumerations
376 * below this point. This would result in incompatible databases
377 * between versions of Orthanc!
378 **/
379
380 enum CompressionType
381 {
382 /**
383 * Buffer/file that is stored as-is, in a raw fashion, without
384 * compression.
385 **/
386 CompressionType_None = 1,
387
388 /**
389 * Buffer that is compressed using the "deflate" algorithm (RFC
390 * 1951), wrapped inside the zlib data format (RFC 1950), prefixed
391 * with a "uint64_t" (8 bytes) that encodes the size of the
392 * uncompressed buffer. If the compressed buffer is empty, its
393 * represents an empty uncompressed buffer. This format is
394 * internal to Orthanc. If the 8 first bytes are skipped AND the
395 * buffer is non-empty, the buffer is compatible with the
396 * "deflate" HTTP compression.
397 **/
398 CompressionType_ZlibWithSize = 2
399 };
400
401 enum FileContentType
402 {
403 // If you add a value below, insert it in "PluginStorageArea" in
404 // the file "Plugins/Engine/OrthancPlugins.cpp"
405 FileContentType_Unknown = 0,
406 FileContentType_Dicom = 1,
407 FileContentType_DicomAsJson = 2,
408
409 // Make sure that the value "65535" can be stored into this enumeration
410 FileContentType_StartUser = 1024,
411 FileContentType_EndUser = 65535
412 };
413
414 enum ResourceType
415 {
416 ResourceType_Patient = 1,
417 ResourceType_Study = 2,
418 ResourceType_Series = 3,
419 ResourceType_Instance = 4
420 };
421
422
423 const char* EnumerationToString(ErrorCode code);
424
425 const char* EnumerationToString(HttpMethod method);
426
427 const char* EnumerationToString(HttpStatus status);
428
429 const char* EnumerationToString(ResourceType type);
430
431 const char* EnumerationToString(ImageFormat format);
432
433 const char* EnumerationToString(Encoding encoding);
434
435 const char* EnumerationToString(PhotometricInterpretation photometric);
436
437 const char* EnumerationToString(LogLevel level);
438
439 const char* EnumerationToString(RequestOrigin origin);
440
441 Encoding StringToEncoding(const char* encoding);
442
443 ResourceType StringToResourceType(const char* type);
444
445 ImageFormat StringToImageFormat(const char* format);
446
447 LogLevel StringToLogLevel(const char* format);
448
449 unsigned int GetBytesPerPixel(PixelFormat format);
450
451 bool GetDicomEncoding(Encoding& encoding,
452 const char* specificCharacterSet);
453
454 const char* GetMimeType(FileContentType type);
455
456 const char* GetFileExtension(FileContentType type);
457
458 ResourceType GetChildResourceType(ResourceType type);
459
460 ResourceType GetParentResourceType(ResourceType type);
461
462 DicomModule GetModule(ResourceType type);
463
464 const char* GetDicomSpecificCharacterSet(Encoding encoding);
465
466 HttpStatus ConvertErrorCodeToHttpStatus(ErrorCode error);
467 }