comparison Orthanc/Core/Enumerations.h @ 14:f7379096e014

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Jan 2016 14:21:51 +0100
parents
children
comparison
equal deleted inserted replaced
13:a07ee8b6946e 14:f7379096e014
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 *
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_EmptyRequest = 33 /*!< The request is empty */,
83 ErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */,
84 ErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */,
85 ErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */,
86 ErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
87 ErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */,
88 ErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */,
89 ErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */,
90 ErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */,
91 ErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */,
92 ErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */,
93 ErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */,
94 ErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */,
95 ErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */,
96 ErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */,
97 ErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */,
98 ErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */,
99 ErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */,
100 ErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */,
101 ErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */,
102 ErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */,
103 ErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is already in use */,
104 ErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is already in use */,
105 ErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */,
106 ErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */,
107 ErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */,
108 ErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */,
109 ErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */,
110 ErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */,
111 ErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */,
112 ErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */,
113 ErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */,
114 ErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */,
115 ErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */,
116 ErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */,
117 ErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */,
118 ErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */,
119 ErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */,
120 ErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */,
121 ErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */,
122 ErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */,
123 ErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */,
124 ErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */,
125 ErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */,
126 ErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */,
127 ErrorCode_UnknownModality = 2027 /*!< Unknown modality */,
128 ErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */,
129 ErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */,
130 ErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */,
131 ErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */,
132 ErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */,
133 ErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */,
134 ErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */,
135 ErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */,
136 ErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */,
137 ErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */,
138 ErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */,
139 ErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */,
140 ErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */,
141 ErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */,
142 ErrorCode_START_PLUGINS = 1000000
143 };
144
145 enum LogLevel
146 {
147 LogLevel_Error,
148 LogLevel_Warning,
149 LogLevel_Info,
150 LogLevel_Trace
151 };
152
153
154 /**
155 * {summary}{The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.}
156 **/
157 enum PixelFormat
158 {
159 /**
160 * {summary}{Color image in RGB24 format.}
161 * {description}{This format describes a color image. The pixels are stored in 3
162 * consecutive bytes. The memory layout is RGB.}
163 **/
164 PixelFormat_RGB24 = 1,
165
166 /**
167 * {summary}{Color image in RGBA32 format.}
168 * {description}{This format describes a color image. The pixels are stored in 4
169 * consecutive bytes. The memory layout is RGBA.}
170 **/
171 PixelFormat_RGBA32 = 2,
172
173 /**
174 * {summary}{Graylevel 8bpp image.}
175 * {description}{The image is graylevel. Each pixel is unsigned and stored in one byte.}
176 **/
177 PixelFormat_Grayscale8 = 3,
178
179 /**
180 * {summary}{Graylevel, unsigned 16bpp image.}
181 * {description}{The image is graylevel. Each pixel is unsigned and stored in two bytes.}
182 **/
183 PixelFormat_Grayscale16 = 4,
184
185 /**
186 * {summary}{Graylevel, signed 16bpp image.}
187 * {description}{The image is graylevel. Each pixel is signed and stored in two bytes.}
188 **/
189 PixelFormat_SignedGrayscale16 = 5
190 };
191
192
193 /**
194 * {summary}{The extraction mode specifies the way the values of the pixels are scaled when downloading a 2D image.}
195 **/
196 enum ImageExtractionMode
197 {
198 /**
199 * {summary}{Rescaled to 8bpp.}
200 * {description}{The minimum value of the image is set to 0, and its maximum value is set to 255.}
201 **/
202 ImageExtractionMode_Preview = 1,
203
204 /**
205 * {summary}{Truncation to the [0, 255] range.}
206 **/
207 ImageExtractionMode_UInt8 = 2,
208
209 /**
210 * {summary}{Truncation to the [0, 65535] range.}
211 **/
212 ImageExtractionMode_UInt16 = 3,
213
214 /**
215 * {summary}{Truncation to the [-32768, 32767] range.}
216 **/
217 ImageExtractionMode_Int16 = 4
218 };
219
220
221 /**
222 * Most common, non-joke and non-experimental HTTP status codes
223 * http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
224 **/
225 enum HttpStatus
226 {
227 HttpStatus_None = -1,
228
229 // 1xx Informational
230 HttpStatus_100_Continue = 100,
231 HttpStatus_101_SwitchingProtocols = 101,
232 HttpStatus_102_Processing = 102,
233
234 // 2xx Success
235 HttpStatus_200_Ok = 200,
236 HttpStatus_201_Created = 201,
237 HttpStatus_202_Accepted = 202,
238 HttpStatus_203_NonAuthoritativeInformation = 203,
239 HttpStatus_204_NoContent = 204,
240 HttpStatus_205_ResetContent = 205,
241 HttpStatus_206_PartialContent = 206,
242 HttpStatus_207_MultiStatus = 207,
243 HttpStatus_208_AlreadyReported = 208,
244 HttpStatus_226_IMUsed = 226,
245
246 // 3xx Redirection
247 HttpStatus_300_MultipleChoices = 300,
248 HttpStatus_301_MovedPermanently = 301,
249 HttpStatus_302_Found = 302,
250 HttpStatus_303_SeeOther = 303,
251 HttpStatus_304_NotModified = 304,
252 HttpStatus_305_UseProxy = 305,
253 HttpStatus_307_TemporaryRedirect = 307,
254
255 // 4xx Client Error
256 HttpStatus_400_BadRequest = 400,
257 HttpStatus_401_Unauthorized = 401,
258 HttpStatus_402_PaymentRequired = 402,
259 HttpStatus_403_Forbidden = 403,
260 HttpStatus_404_NotFound = 404,
261 HttpStatus_405_MethodNotAllowed = 405,
262 HttpStatus_406_NotAcceptable = 406,
263 HttpStatus_407_ProxyAuthenticationRequired = 407,
264 HttpStatus_408_RequestTimeout = 408,
265 HttpStatus_409_Conflict = 409,
266 HttpStatus_410_Gone = 410,
267 HttpStatus_411_LengthRequired = 411,
268 HttpStatus_412_PreconditionFailed = 412,
269 HttpStatus_413_RequestEntityTooLarge = 413,
270 HttpStatus_414_RequestUriTooLong = 414,
271 HttpStatus_415_UnsupportedMediaType = 415,
272 HttpStatus_416_RequestedRangeNotSatisfiable = 416,
273 HttpStatus_417_ExpectationFailed = 417,
274 HttpStatus_422_UnprocessableEntity = 422,
275 HttpStatus_423_Locked = 423,
276 HttpStatus_424_FailedDependency = 424,
277 HttpStatus_426_UpgradeRequired = 426,
278
279 // 5xx Server Error
280 HttpStatus_500_InternalServerError = 500,
281 HttpStatus_501_NotImplemented = 501,
282 HttpStatus_502_BadGateway = 502,
283 HttpStatus_503_ServiceUnavailable = 503,
284 HttpStatus_504_GatewayTimeout = 504,
285 HttpStatus_505_HttpVersionNotSupported = 505,
286 HttpStatus_506_VariantAlsoNegotiates = 506,
287 HttpStatus_507_InsufficientStorage = 507,
288 HttpStatus_509_BandwidthLimitExceeded = 509,
289 HttpStatus_510_NotExtended = 510
290 };
291
292
293 enum HttpMethod
294 {
295 HttpMethod_Get = 0,
296 HttpMethod_Post = 1,
297 HttpMethod_Delete = 2,
298 HttpMethod_Put = 3
299 };
300
301
302 enum ImageFormat
303 {
304 ImageFormat_Png = 1
305 };
306
307
308 // https://en.wikipedia.org/wiki/HTTP_compression
309 enum HttpCompression
310 {
311 HttpCompression_None,
312 HttpCompression_Deflate,
313 HttpCompression_Gzip
314 };
315
316
317 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/
318 enum Encoding
319 {
320 Encoding_Ascii,
321 Encoding_Utf8,
322 Encoding_Latin1,
323 Encoding_Latin2,
324 Encoding_Latin3,
325 Encoding_Latin4,
326 Encoding_Latin5, // Turkish
327 Encoding_Cyrillic,
328 Encoding_Windows1251, // Windows-1251 (commonly used for Cyrillic)
329 Encoding_Arabic,
330 Encoding_Greek,
331 Encoding_Hebrew,
332 Encoding_Thai, // TIS 620-2533
333 Encoding_Japanese, // JIS X 0201 (Shift JIS): Katakana
334 Encoding_Chinese // GB18030 - Chinese simplified
335 //Encoding_JapaneseKanji, // Multibyte - JIS X 0208: Kanji
336 //Encoding_JapaneseSupplementaryKanji, // Multibyte - JIS X 0212: Supplementary Kanji set
337 //Encoding_Korean, // Multibyte - KS X 1001: Hangul and Hanja
338 };
339
340
341 // https://www.dabsoft.ch/dicom/3/C.7.6.3.1.2/
342 enum PhotometricInterpretation
343 {
344 PhotometricInterpretation_ARGB, // Retired
345 PhotometricInterpretation_CMYK, // Retired
346 PhotometricInterpretation_HSV, // Retired
347 PhotometricInterpretation_Monochrome1,
348 PhotometricInterpretation_Monochrome2,
349 PhotometricInterpretation_Palette,
350 PhotometricInterpretation_RGB,
351 PhotometricInterpretation_YBRFull,
352 PhotometricInterpretation_YBRFull422,
353 PhotometricInterpretation_YBRPartial420,
354 PhotometricInterpretation_YBRPartial422,
355 PhotometricInterpretation_YBR_ICT,
356 PhotometricInterpretation_YBR_RCT,
357 PhotometricInterpretation_Unknown
358 };
359
360 enum DicomModule
361 {
362 DicomModule_Patient,
363 DicomModule_Study,
364 DicomModule_Series,
365 DicomModule_Instance,
366 DicomModule_Image
367 };
368
369 enum RequestOrigin
370 {
371 RequestOrigin_Unknown,
372 RequestOrigin_DicomProtocol,
373 RequestOrigin_RestApi,
374 RequestOrigin_Plugins,
375 RequestOrigin_Lua
376 };
377
378
379 /**
380 * WARNING: Do not change the explicit values in the enumerations
381 * below this point. This would result in incompatible databases
382 * between versions of Orthanc!
383 **/
384
385 enum CompressionType
386 {
387 /**
388 * Buffer/file that is stored as-is, in a raw fashion, without
389 * compression.
390 **/
391 CompressionType_None = 1,
392
393 /**
394 * Buffer that is compressed using the "deflate" algorithm (RFC
395 * 1951), wrapped inside the zlib data format (RFC 1950), prefixed
396 * with a "uint64_t" (8 bytes) that encodes the size of the
397 * uncompressed buffer. If the compressed buffer is empty, its
398 * represents an empty uncompressed buffer. This format is
399 * internal to Orthanc. If the 8 first bytes are skipped AND the
400 * buffer is non-empty, the buffer is compatible with the
401 * "deflate" HTTP compression.
402 **/
403 CompressionType_ZlibWithSize = 2
404 };
405
406 enum FileContentType
407 {
408 // If you add a value below, insert it in "PluginStorageArea" in
409 // the file "Plugins/Engine/OrthancPlugins.cpp"
410 FileContentType_Unknown = 0,
411 FileContentType_Dicom = 1,
412 FileContentType_DicomAsJson = 2,
413
414 // Make sure that the value "65535" can be stored into this enumeration
415 FileContentType_StartUser = 1024,
416 FileContentType_EndUser = 65535
417 };
418
419 enum ResourceType
420 {
421 ResourceType_Patient = 1,
422 ResourceType_Study = 2,
423 ResourceType_Series = 3,
424 ResourceType_Instance = 4
425 };
426
427
428 const char* EnumerationToString(ErrorCode code);
429
430 const char* EnumerationToString(HttpMethod method);
431
432 const char* EnumerationToString(HttpStatus status);
433
434 const char* EnumerationToString(ResourceType type);
435
436 const char* EnumerationToString(ImageFormat format);
437
438 const char* EnumerationToString(Encoding encoding);
439
440 const char* EnumerationToString(PhotometricInterpretation photometric);
441
442 const char* EnumerationToString(LogLevel level);
443
444 const char* EnumerationToString(RequestOrigin origin);
445
446 Encoding StringToEncoding(const char* encoding);
447
448 ResourceType StringToResourceType(const char* type);
449
450 ImageFormat StringToImageFormat(const char* format);
451
452 LogLevel StringToLogLevel(const char* format);
453
454 unsigned int GetBytesPerPixel(PixelFormat format);
455
456 bool GetDicomEncoding(Encoding& encoding,
457 const char* specificCharacterSet);
458
459 ResourceType GetChildResourceType(ResourceType type);
460
461 ResourceType GetParentResourceType(ResourceType type);
462
463 DicomModule GetModule(ResourceType type);
464
465 const char* GetDicomSpecificCharacterSet(Encoding encoding);
466
467 HttpStatus ConvertErrorCodeToHttpStatus(ErrorCode error);
468
469 bool IsUserContentType(FileContentType type);
470 }