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