]> Creatis software - gdcm.git/blob - src/gdcmGlobal.cxx
5d8c4e7195124f8fa38fe2d917b2d8935338cbf6
[gdcm.git] / src / gdcmGlobal.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmGlobal.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/23 10:12:34 $
7   Version:   $Revision: 1.16 $
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 initialization 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  * \brief Pointer to a container, holding _all_ the Dicom Dictionaries.
43  */
44 DictSet         *Global::Dicts  = (DictSet *)0;
45
46 /**
47  * \brief   Pointer to a hash table containing the 'Value Representations'.
48  */
49 VR              *Global::ValRes     = (VR *)0;
50
51 /**
52  * \brief   Pointer to a hash table containing the Transfer Syntax codes
53  *          and their english description 
54  */
55 TS              *Global::TranSyn     = (TS *)0;
56
57 /**
58  * \brief   Pointer to the hash table containing the Dicom Elements
59  *          necessary to describe each part of a DICOMDIR 
60  */
61 DicomDirElement *Global::ddElem = (DicomDirElement *)0;
62
63 /**
64  * \brief   Global container
65  */
66 Global Glob;
67
68 /**
69  * \brief   constructor : populates the various H Tables
70  */
71 Global::Global()
72 {
73    if (ValRes || TranSyn || Dicts || ddElem)
74    {
75       gdcmVerboseMacro( "VR or TS or Dicts already allocated");
76       return;
77    }
78    Dicts   = new DictSet();
79    ValRes  = new VR();
80    TranSyn = new TS();
81    ddElem  = new DicomDirElement();
82 }
83
84 /**
85  * \brief   canonical destructor 
86  */
87 Global::~Global()
88 {
89    delete Dicts;
90    delete ValRes;
91    delete TranSyn;
92    delete ddElem;
93 }
94 /**
95  * \brief   returns a pointer to the 'Value Representation Table' 
96  */
97 VR *Global::GetVR()
98 {
99    return ValRes;
100 }
101 /**
102  * \brief   returns a pointer to the 'Transfer Syntax Table' 
103  */
104 TS *Global::GetTS()
105 {
106    return TranSyn;
107 }
108 /**
109  * \brief   returns a pointer to Dictionaries Table 
110  */
111 DictSet *Global::GetDicts()
112 {
113    return Dicts;
114 }
115 /**
116  * \brief   returns a pointer to the DicomDir related elements Table 
117  */
118 DicomDirElement *Global::GetDicomDirElements()
119 {
120    return ddElem;
121 }
122 } // end namespace gdcm