]> Creatis software - gdcm.git/blob - src/gdcmCommon.h
Update comments for DicomDir stuff
[gdcm.git] / src / gdcmCommon.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmCommon.h,v $
5   Language:  C++
6   Date:      $Date: 2005/02/06 14:31:09 $
7   Version:   $Revision: 1.60 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef GDCMCOMMON_H
20 #define GDCMCOMMON_H
21
22 #include "gdcmConfigure.h"
23
24 //-----------------------------------------------------------------------------
25 //This is needed when compiling in debug mode
26 #ifdef _MSC_VER
27 // 'identifier' : class 'type' needs to have dll-interface to be used by
28 // clients of class 'type2'
29 #pragma warning ( disable : 4251 )
30 // 'identifier' : identifier was truncated to 'number' characters in the
31 // debug information
32 #pragma warning ( disable : 4786 )
33 //'identifier' : decorated name length exceeded, name was truncated
34 #pragma warning ( disable : 4503 )
35 // C++ exception specification ignored except to indicate a 
36 // function is not __declspec(nothrow)
37 #pragma warning ( disable : 4290 )
38 // signed/unsigned mismatch
39 #pragma warning ( disable : 4018 )
40 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
41 // produce errors if applied using infix notation
42 #pragma warning ( disable : 4284 )
43 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
44 // //#pragma warning ( disable : 4800 )
45 #endif //_MSC_VER
46
47 //-----------------------------------------------------------------------------
48 #ifdef CMAKE_HAVE_STDINT_H
49    #include <stdint.h>
50 #else
51 #ifdef CMAKE_HAVE_INTTYPES_H
52    // Old system only have this
53    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
54 #endif
55 #endif
56
57 // Broken plateform do not respect C99 and do not provide those typedef
58 #if defined(_MSC_VER) || defined(__BORLANDC__)
59 typedef  signed char         int8_t;
60 typedef  signed short        int16_t;
61 typedef  signed int          int32_t;
62 typedef  unsigned char       uint8_t;
63 typedef  unsigned short      uint16_t;
64 typedef  unsigned int        uint32_t;
65 #define UINT32_MAX    (4294967295U)
66 #endif
67
68 #if defined(_WIN32) && defined(BUILD_SHARED_LIBS)
69   #ifdef gdcm_EXPORTS
70     #define GDCM_EXPORT __declspec( dllexport )
71   #else
72     #define GDCM_EXPORT __declspec( dllimport )
73   #endif
74 #else
75   #define GDCM_EXPORT
76 #endif
77
78 #include <string>
79
80 namespace gdcm
81 {
82
83 // Centralize information about the gdcm dictionary in only one file:
84 #ifndef PUB_DICT_PATH
85 #  define PUB_DICT_PATH   "../Dicts/"
86 #endif
87 #define PUB_DICT_NAME     "DicomV3Dict"
88 #define PUB_DICT_FILENAME "dicomV3.dic"
89 #define DICT_ELEM         "DicomDir.dic"
90 #define DICT_TS           "dicomTS.dic"
91 #define DICT_VR           "dicomVR.dic"
92
93 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
94 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
95 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
96 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
97 GDCM_EXPORT extern const std::string GDCM_UNREAD;
98
99 /// \brief TagKey is made to hold an "universal" (as in URL, Universal
100 ///        Ressource Locator) key to a DocEntry i.e. a dicom tag.
101 ///        A dicom tag always has a group and an elem, but a set of tags
102 ///        embeded in various (optionally nested) sequences and sharing
103 ///        the same group and elem all share the same (group, elem)
104 ///        "identifier". Hence the (group, elem) cannot be used as an
105 ///        identifier (in gdcm we shall refer to a "TagKey") of a tag.
106 ///        In order to construct a proper tag identifier (i.e. a key) we
107 ///        consider the following definition of a TagKey:
108 ///        - let Group, Element be the string representation of the
109 ///          group and elem dicom tag members,
110 ///        - let ItemNumber be the string representation of the integer
111 ///          index of the considered item number of a sequence,
112 ///        Let the key of a tag embeded in a sequence, noted SeqTag, be
113 ///        the form:
114 ///           /ItemNumber#Group|Element
115 ///        where "/", "#" and "|" are characters acting as separators.
116 ///        Then the general form of a TagKey is given by:
117 ///           Group|Element[SeqTag]
118 ///        where [SeqTag] means NO or many instances of SeqTag.
119 ///        Hence the TagKey of a tag not "leaving" in a sequence is the
120 ///        string e.g. 
121 ///            0028|1201
122 ///        but the TagKey of a tag "embeded" is the first item of
123 ///        a sequence, itself nested in the third item of a sequence is the
124 ///        string e.g.
125 ///            0004|1220/2#0008|0082/0#0008|0090
126 typedef std::string TagKey;
127 typedef std::string TagName;
128
129 enum FileType {
130    Unknown = 0,
131    ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
132    ImplicitVR,
133    ACR,
134    ACR_LIBIDO
135 };
136
137 enum DicomDirType {
138    DD_UNKNOWN = 0,
139    DD_META,
140    DD_PATIENT,
141    DD_STUDY,
142    DD_SERIE,
143    DD_IMAGE
144 };
145
146 /**
147  * \brief structure, for internal use only
148  */  
149 GDCM_EXPORT typedef struct
150 {
151    /// DicomGroup number
152    unsigned short int Group;
153    /// DicomElement number
154    unsigned short int Elem;
155    /// value (coded as a std::string) of the Element
156    std::string Value;
157 } Element;
158
159 } //namespace gdcm
160 //-----------------------------------------------------------------------------
161 #endif