]> Creatis software - gdcm.git/blob - src/gdcmGlobal.cxx
* src/gdcmDictGroupName.[h|cxx] : add a correlation between a group (number)
[gdcm.git] / src / gdcmGlobal.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmGlobal.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/04/05 10:56:25 $
7   Version:   $Revision: 1.23 $
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 #include "gdcmGlobal.h"
20
21 #include "gdcmDebug.h"
22 #include "gdcmVR.h"
23 #include "gdcmTS.h"
24 #include "gdcmDictGroupName.h"
25 #include "gdcmDictSet.h"
26 #include "gdcmDicomDirElement.h"
27
28 namespace gdcm 
29 {
30 //-----------------------------------------------------------------------------
31 /// \brief Those global string that are returned by reference everywhere in 
32 /// gdcm code used to be in gdcmCommon.h but due to a 'bug' in gcc/MacOSX
33 /// you cannot have static initialization in a multithreaded environment
34 /// since there is a lazy construction everything got skrew up somehow
35 /// Therefore the actual initialization is done in a cxx file (avoid
36 /// duplicated symbol), and an extern is used in gdcmCommon.h
37 const std::string GDCM_UNKNOWN   = "gdcm::Unknown";
38 const std::string GDCM_UNFOUND   = "gdcm::Unfound";
39 const std::string GDCM_BINLOADED = "gdcm::Binary data loaded";
40 const std::string GDCM_NOTLOADED = "gdcm::NotLoaded";
41 const std::string GDCM_UNREAD    = "gdcm::UnRead";
42
43 //-----------------------------------------------------------------------------
44 DictSet         *Global::Dicts     = (DictSet *)0;
45 VR              *Global::ValRes    = (VR *)0;
46 TS              *Global::TranSyn   = (TS *)0;
47 DictGroupName   *Global::GroupName = (DictGroupName *)0;
48 DicomDirElement *Global::ddElem    = (DicomDirElement *)0;
49
50 //-----------------------------------------------------------------------------
51 /**
52  * \brief   Global container
53  */
54 Global Glob;
55
56 //-------------------------------------------------------------------------
57 // Constructor / Destructor
58 /**
59  * \brief   constructor : populates the various H Tables
60  */
61 Global::Global()
62 {
63    if (ValRes || TranSyn || Dicts || ddElem)
64    {
65       gdcmWarningMacro( "VR or TS or Dicts already allocated");
66       return;
67    }
68    Dicts     = new DictSet();
69    ValRes    = new VR();
70    TranSyn   = new TS();
71    GroupName = new DictGroupName();
72    ddElem    = new DicomDirElement();
73 }
74
75 /**
76  * \brief   canonical destructor 
77  */
78 Global::~Global()
79 {
80    delete Dicts;
81    delete ValRes;
82    delete TranSyn;
83    delete GroupName;
84    delete ddElem;
85 }
86
87 //-----------------------------------------------------------------------------
88 // Public
89 /**
90  * \brief   returns a pointer to Dictionaries Table 
91  */
92 DictSet *Global::GetDicts()
93 {
94    return Dicts;
95 }
96
97 /**
98  * \brief   returns a pointer to the 'Value Representation Table' 
99  */
100 VR *Global::GetVR()
101 {
102    return ValRes;
103 }
104
105 /**
106  * \brief   returns a pointer to the 'Transfer Syntax Table' 
107  */
108 TS *Global::GetTS()
109 {
110    return TranSyn;
111 }
112
113 /**
114  * \brief   returns a pointer to the Group name correspondance table
115  */
116 DictGroupName *Global::GetDictGroupName()
117 {
118    return GroupName;
119 }
120
121 /**
122  * \brief   returns a pointer to the DicomDir related elements Table 
123  */
124 DicomDirElement *Global::GetDicomDirElements()
125 {
126    return ddElem;
127 }
128
129 //-----------------------------------------------------------------------------
130 // Protected
131
132 //-----------------------------------------------------------------------------
133 // Private
134
135 //-----------------------------------------------------------------------------
136 // Print
137
138 //-----------------------------------------------------------------------------
139 } // end namespace gdcm