]> Creatis software - gdcm.git/blob - src/gdcmDicomDirStudy.cxx
* Remove memory leaks on the DicomDir
[gdcm.git] / src / gdcmDicomDirStudy.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/12/03 17:13:18 $
7   Version:   $Revision: 1.19 $
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 "gdcmDicomDirStudy.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmGlobal.h"
22
23 namespace gdcm 
24 {
25 //-----------------------------------------------------------------------------
26 // Constructor / Destructor
27 /**
28  * \ingroup DicomDirStudy
29  * \brief constructor  
30  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
31  *               to build the HeaderEntries)
32  */
33 DicomDirStudy::DicomDirStudy():
34    DicomDirObject()
35 {
36 }
37 /**
38  * \ingroup DicomDirStudy
39  * \brief   Canonical destructor.
40  */
41 DicomDirStudy::~DicomDirStudy() 
42 {
43    for(ListDicomDirSerie::iterator cc = Series.begin();
44                                    cc != Series.end();
45                                  ++cc )
46    {
47       delete *cc;
48    }
49 }
50
51 //-----------------------------------------------------------------------------
52 // Print
53 /**
54  * \ingroup DicomDirStudy
55  * \brief   Prints the Object
56  * @return
57  */ 
58 void DicomDirStudy::Print(std::ostream& os)
59 {
60    os << "STUDY" << std::endl;
61    DicomDirObject::Print(os);
62
63    for(ListDicomDirSerie::iterator cc = Series.begin();
64                                    cc != Series.end();
65                                    ++cc)
66    {
67       (*cc)->SetPrintLevel(PrintLevel);
68       (*cc)->Print(os);
69    }
70 }
71
72 //-----------------------------------------------------------------------------
73 // Public
74
75 /**
76  * \brief   Writes the Object
77  * @return
78  */ 
79 void DicomDirStudy::WriteContent(std::ofstream* fp, FileType t)
80 {
81    DicomDirObject::WriteContent(fp, t);
82
83    for(ListDicomDirSerie::iterator cc = Series.begin();
84                                    cc!= Series.end();
85                                  ++cc )
86    {
87       (*cc)->WriteContent( fp, t );
88    }
89 }
90
91 /**
92  * \ingroup DicomDirStudy
93  * \brief   adds a new Serie at the begining of the SerieList
94  *          of a partially created DICOMDIR
95  */
96 DicomDirSerie* DicomDirStudy::NewSerie()
97 {
98    ListDicomDirSerieElem const & elemList = 
99       Global::GetDicomDirElements()->GetDicomDirSerieElements();   
100
101    DicomDirSerie* st = new DicomDirSerie();
102    FillObject(elemList);
103    Series.push_front(st);
104
105    return st;  
106 }   
107 //-----------------------------------------------------------------------------
108 // Protected
109
110 //-----------------------------------------------------------------------------
111 // Private
112
113 //-----------------------------------------------------------------------------
114 } // end namespace gdcm
115