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