]> Creatis software - gdcm.git/blob - src/gdcmGlobal.cxx
BUG: Solve -hopefully- problem on MacOSX where gdcm seemed to stop working. More...
[gdcm.git] / src / gdcmGlobal.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmGlobal.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/09 00:13:26 $
7   Version:   $Revision: 1.11 $
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 "gdcmDictSet.h"
25 #include "gdcmDicomDirElement.h"
26
27 namespace gdcm 
28 {
29
30 // Those global string that are return by reference everywhere in gdcm code
31 // used to be in gdcmCommon.h but due to a 'bug' in gcc/MacOSX
32 // you cannot have static initialization in a multithreaded environment
33 // since there is a lazy construction everything got skrew up somehow
34 // Therefore the actual initiliazation is done in a cxx file (avoid
35 // duplicated symbol), and an extern is used in gdcmCommon.h
36 const std::string GDCM_UNKNOWN   = "gdcm::Unknown";
37 const std::string GDCM_UNFOUND   = "gdcm::Unfound";
38 const std::string GDCM_BINLOADED = "gdcm::Binary data loaded";
39 const std::string GDCM_NOTLOADED = "gdcm::NotLoaded";
40 const std::string GDCM_UNREAD    = "gdcm::UnRead";
41   
42 /**
43  * \ingroup Globals
44  * \brief Pointer to a container, holding _all_ the Dicom Dictionaries.
45  */
46 DictSet         *Global::Dicts  = (DictSet *)0;
47
48 /**
49  * \ingroup Globals
50  * \brief   Pointer to a hash table containing the 'Value Representations'.
51  */
52 VR              *Global::ValRes     = (VR *)0;
53
54 /**
55  * \ingroup Globals
56  * \brief   Pointer to a hash table containing the Transfer Syntax codes
57  *          and their english description 
58  */
59 TS              *Global::TranSyn     = (TS *)0;
60
61 /**
62  * \ingroup Globals
63  * \brief   Pointer to the hash table containing the Dicom Elements
64  *          necessary to describe each part of a DICOMDIR 
65  */
66 DicomDirElement *Global::ddElem = (DicomDirElement *)0;
67
68 /**
69  * \ingroup Globals
70  * \brief   Global container
71  */
72 Global Glob;
73
74 /**
75  * \ingroup Global
76  * \brief   constructor : populates the various H Tables
77  */
78 Global::Global()
79 {
80    if (ValRes || TranSyn || Dicts || ddElem)
81    {
82       gdcmVerboseMacro( "VR or TS or Dicts already allocated");
83       return;
84    }
85    Dicts   = new DictSet();
86    ValRes  = new VR();
87    TranSyn = new TS();
88    ddElem  = new DicomDirElement();
89 }
90
91 /**
92  * \ingroup Global
93  * \brief   canonical destructor 
94  */
95 Global::~Global()
96 {
97    delete Dicts;
98    delete ValRes;
99    delete TranSyn;
100    delete ddElem;
101 }
102 /**
103  * \ingroup Global
104  * \brief   returns a pointer to the 'Value Representation Table' 
105  */
106 VR *Global::GetVR()
107 {
108    return ValRes;
109 }
110 /**
111  * \ingroup Global
112  * \brief   returns a pointer to the 'Transfert Syntax Table' 
113  */
114 TS *Global::GetTS()
115 {
116    return TranSyn;
117 }
118 /**
119  * \ingroup Global
120  * \brief   returns a pointer to Dictionaries Table 
121  */
122 DictSet *Global::GetDicts()
123 {
124    return Dicts;
125 }
126 /**
127  * \ingroup Global
128  * \brief   returns a pointer to the DicomDir related elements Table 
129  */
130 DicomDirElement *Global::GetDicomDirElements()
131 {
132    return ddElem;
133 }
134 } // end namespace gdcm