]> Creatis software - gdcm.git/blob - src/gdcmGlobal.cxx
BUG: Fix mem leak
[gdcm.git] / src / gdcmGlobal.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmGlobal.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/10/28 18:13:36 $
7   Version:   $Revision: 1.6 $
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 #include "gdcmDebug.h"
21
22 namespace gdcm 
23 {
24
25 /**
26  * \ingroup Globals
27  * \brief Pointer to a container, holding _all_ the Dicom Dictionaries.
28  */
29 DictSet         *Global::Dicts  = (DictSet *)0;
30
31 /**
32  * \ingroup Globals
33  * \brief   Pointer to a hash table containing the 'Value Representations'.
34  */
35 VR              *Global::ValRes     = (VR *)0;
36
37 /**
38  * \ingroup Globals
39  * \brief   Pointer to a hash table containing the Transfer Syntax codes
40  *          and their english description 
41  */
42 TS              *Global::TranSyn     = (TS *)0;
43
44 /**
45  * \ingroup Globals
46  * \brief   Pointer to the hash table containing the Dicom Elements
47  *          necessary to describe each part of a DICOMDIR 
48  */
49 DicomDirElement *Global::ddElem = (DicomDirElement *)0;
50
51 /**
52  * \ingroup Globals
53  * \brief   Global container
54  */
55 Global Glob;
56
57 /**
58  * \ingroup Global
59  * \brief   constructor : populates the various H Tables
60  */
61 Global::Global()
62 {
63    if (ValRes || TranSyn || Dicts || ddElem)
64    {
65       dbg.Verbose(0, "Global::Global : VR or TS or Dicts already allocated");
66       return;
67    }
68    Dicts   = new DictSet();
69    ValRes  = new VR();
70    TranSyn = new TS();
71    ddElem  = new DicomDirElement();
72 }
73
74 /**
75  * \ingroup Global
76  * \brief   canonical destructor 
77  */
78 Global::~Global()
79 {
80    delete Dicts;
81    delete ValRes;
82    delete TranSyn;
83    delete ddElem;
84 }
85 /**
86  * \ingroup Global
87  * \brief   returns a pointer to the 'Value Representation Table' 
88  */
89 VR *Global::GetVR()
90 {
91    return ValRes;
92 }
93 /**
94  * \ingroup Global
95  * \brief   returns a pointer to the 'Transfert Syntax Table' 
96  */
97 TS *Global::GetTS()
98 {
99    return TranSyn;
100 }
101 /**
102  * \ingroup Global
103  * \brief   returns a pointer to Dictionaries Table 
104  */
105 DictSet *Global::GetDicts()
106 {
107    return Dicts;
108 }
109 /**
110  * \ingroup Global
111  * \brief   returns a pointer to the DicomDir related elements Table 
112  */
113 DicomDirElement *Global::GetDicomDirElements()
114 {
115    return ddElem;
116 }
117 } // end namespace gdcm