]> Creatis software - gdcm.git/blob - src/gdcmGlobal.cxx
class ArgMgr (for Arguments Manager) is designed for
[gdcm.git] / src / gdcmGlobal.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmGlobal.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/06/06 12:37:58 $
7   Version:   $Revision: 1.24 $
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
38 const std::string GDCM_UNKNOWN   = "gdcm::Unknown";
39 const std::string GDCM_UNFOUND   = "gdcm::Unfound";
40 const std::string GDCM_BINLOADED = "gdcm::Binary data loaded";
41 const std::string GDCM_NOTLOADED = "gdcm::NotLoaded";
42 const std::string GDCM_UNREAD    = "gdcm::UnRead";
43
44 //-----------------------------------------------------------------------------
45 DictSet         *Global::Dicts     = (DictSet *)0;
46 VR              *Global::ValRes    = (VR *)0;
47 TS              *Global::TranSyn   = (TS *)0;
48 DictGroupName   *Global::GroupName = (DictGroupName *)0;
49 DicomDirElement *Global::ddElem    = (DicomDirElement *)0;
50
51 //-----------------------------------------------------------------------------
52 /**
53  * \brief   Global container
54  */
55 Global Glob;
56
57 //-------------------------------------------------------------------------
58 // Constructor / Destructor
59 /**
60  * \brief   constructor : populates the various H Tables
61  */
62 Global::Global()
63 {
64    if (ValRes || TranSyn || Dicts || ddElem)
65    {
66       gdcmWarningMacro( "VR or TS or Dicts already allocated");
67       return;
68    }
69    Dicts     = new DictSet();
70    ValRes    = new VR();
71    TranSyn   = new TS();
72    GroupName = new DictGroupName();
73    ddElem    = new DicomDirElement();
74 }
75
76 /**
77  * \brief   canonical destructor 
78  */
79 Global::~Global()
80 {
81    delete Dicts;
82    delete ValRes;
83    delete TranSyn;
84    delete GroupName;
85    delete ddElem;
86 }
87
88 //-----------------------------------------------------------------------------
89 // Public
90 /**
91  * \brief   returns a pointer to Dictionaries Table 
92  */
93 DictSet *Global::GetDicts()
94 {
95    return Dicts;
96 }
97
98 /**
99  * \brief   returns a pointer to the 'Value Representation Table' 
100  */
101 VR *Global::GetVR()
102 {
103    return ValRes;
104 }
105
106 /**
107  * \brief   returns a pointer to the 'Transfer Syntax Table' 
108  */
109 TS *Global::GetTS()
110 {
111    return TranSyn;
112 }
113
114 /**
115  * \brief   returns a pointer to the Group name correspondance table
116  */
117 DictGroupName *Global::GetDictGroupName()
118 {
119    return GroupName;
120 }
121
122 /**
123  * \brief   returns a pointer to the DicomDir related elements Table 
124  */
125 DicomDirElement *Global::GetDicomDirElements()
126 {
127    return ddElem;
128 }
129
130 //-----------------------------------------------------------------------------
131 // Protected
132
133 //-----------------------------------------------------------------------------
134 // Private
135
136 //-----------------------------------------------------------------------------
137 // Print
138
139 //-----------------------------------------------------------------------------
140 } // end namespace gdcm