]> Creatis software - gdcm.git/blob - src/gdcmCommon.h
BUG: Hopefully fix the bug on MacOSX and static global initialization. This is the...
[gdcm.git] / src / gdcmCommon.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmCommon.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/10 19:23:31 $
7   Version:   $Revision: 1.48 $
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 GDCM_HAVE_STDINT_H
49 #include <stdint.h>   // For uint8_t uint16_t and uint32_t
50 #else
51 #if defined(_MSC_VER) || defined(__BORLANDC__)
52 typedef  signed char    int8_t;
53 #endif
54 typedef  unsigned char  uint8_t;
55 typedef  unsigned short uint16_t;
56 typedef  unsigned int   uint32_t;
57 #define UINT32_MAX    (4294967295U)
58 #endif
59
60 #if defined(_MSC_VER) || defined(__BORLANDC__)
61 #define GDCM_EXPORT __declspec( dllexport )
62 #else
63 #define GDCM_EXPORT
64 #endif
65
66 #include <string>
67
68 namespace gdcm
69 {
70
71 // Centralize information about the gdcm dictionary in only one file:
72 #ifndef PUB_DICT_PATH
73 #  define PUB_DICT_PATH   "../Dicts/"
74 #endif
75 #define PUB_DICT_NAME     "DicomV3Dict"
76 #define PUB_DICT_FILENAME "dicomV3.dic"
77 #define DICT_ELEM         "DicomDir.dic"
78 #define DICT_TS           "dicomTS.dic"
79 #define DICT_VR           "dicomVR.dic"
80
81 struct Dummy {};
82 template<typename T>
83 struct Strings_
84 {
85     static std::string const UNKNOWN;
86     static std::string const UNFOUND;
87     static std::string const BINLOADED;
88     static std::string const NOTLOADED;
89     static std::string const UNREAD;
90 };
91 template<typename T> std::string const Strings_<T>::UNKNOWN   = "gdcm::Unknown";
92 template<typename T> std::string const Strings_<T>::UNFOUND   = "gdcm::Unfound";
93 template<typename T> std::string const Strings_<T>::BINLOADED = "gdcm::Binary data loaded";
94 template<typename T> std::string const Strings_<T>::NOTLOADED = "gdcm::NotLoaded";
95 template<typename T> std::string const Strings_<T>::UNREAD    = "gdcm::UnRead";
96 typedef Strings_<Dummy> Strings;
97 #define GDCM_UNKNOWN   Strings::UNKNOWN
98 #define GDCM_UNFOUND   Strings::UNFOUND
99 #define GDCM_BINLOADED Strings::BINLOADED
100 #define GDCM_NOTLOADED Strings::NOTLOADED
101 #define GDCM_UNREAD    Strings::UNREAD
102
103 /// \brief TagKey is made to hold an "universal" (as in URL, Universal
104 ///        Ressource Locator)  key to a DocEntry i.e. a dicom tag.
105 ///        A dicom tag always has a group and an element, but a set of tags
106 ///        embeded in various (optionally nested) sequences and sharing
107 ///        the same group and element all share the same (group, element)
108 ///        "identifier". Hence the (group, element) cannot be used as an
109 ///        identifier (in gdcm we shall refer to a "TagKey") of a tag.
110 ///        In order to construct a proper tag identifier (i.e. a key) we
111 ///        consider the following definition of a TagKey:
112 ///        - let Group, Element be the string representation of the
113 ///          group and element dicom tag members,
114 ///        - let ItemNumber be the string representation of the integer
115 ///          index of the considered item number of a sequence,
116 ///        Let the key of a tag embeded in a sequence, noted SeqTag, be
117 ///        the form:
118 ///           /ItemNumber#Group|Element
119 ///        where "/", "#" and "|" are characters acting as separators.
120 ///        Then the general form of a TagKey is given by:
121 ///           Group|Element[SeqTag]
122 ///        where [SeqTag] means NO or many instances of SeqTag.
123 ///        Hence the TagKey of a tag not "leaving" in a sequence is the
124 ///        string e.g. 
125 ///            0028|1201
126 ///        but the TagKey of a tag "embeded" is the first item of
127 ///        a sequence, itself nested in the third item of a sequence is the
128 ///        string e.g.
129 ///            0004|1220/2#0008|0082/0#0008|0090
130 typedef std::string TagKey;
131 typedef std::string TagName;
132
133 enum FileType {
134    Unknown = 0,
135    ExplicitVR, // DicomDir is in this case
136    ImplicitVR,
137    ACR,
138    ACR_LIBIDO
139 };
140 } //namespace gdcm
141 //-----------------------------------------------------------------------------
142 #endif