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