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