]> Creatis software - gdcm.git/blob - src/gdcmDicomDirPatient.cxx
BUG: Remove the Print indent mess. Please only one Print per class default paramater...
[gdcm.git] / src / gdcmDicomDirPatient.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/16 04:50:41 $
7   Version:   $Revision: 1.24 $
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  */
33 DicomDirPatient::DicomDirPatient():
34    DicomDirObject()
35 {
36 }
37 /**
38  * \brief   Canonical destructor.
39  */
40 DicomDirPatient::~DicomDirPatient() 
41 {
42    for(ListDicomDirStudy::const_iterator cc = Studies.begin();
43                                          cc != Studies.end(); 
44                                        ++cc )
45    {
46       delete *cc;
47    }
48 }
49
50 //-----------------------------------------------------------------------------
51 // Print
52 /**
53  * \brief   Prints the Object
54  * @param os ostream to write to 
55  */ 
56 void DicomDirPatient::Print(std::ostream &os, std::string const & )
57 {
58    os << "PATIENT" << std::endl;
59    DicomDirObject::Print(os);
60
61    for(ListDicomDirStudy::const_iterator cc = Studies.begin();
62                                          cc != Studies.end(); 
63                                        ++cc )
64    {
65       (*cc)->SetPrintLevel(PrintLevel);
66       (*cc)->Print(os);
67    }
68 }
69
70 /**
71  * \brief   Writes the Object
72  * @param fp ofstream to write to
73  * @param t Type of the File (explicit VR, implicitVR, ...) 
74  */ 
75 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
76 {
77    DicomDirObject::WriteContent(fp, t);
78
79    for(ListDicomDirStudy::iterator cc = Studies.begin();
80                                    cc!= Studies.end();
81                                  ++cc )
82    {
83       (*cc)->WriteContent( fp, t );
84    }
85 }
86 //-----------------------------------------------------------------------------
87 // Public
88
89 /**
90  * \brief   adds a new Patient at the begining of the PatientList
91  *          of a partially created DICOMDIR
92  */
93 DicomDirStudy* DicomDirPatient::NewStudy()
94 {
95    ListDicomDirStudyElem const &elemList = 
96       Global::GetDicomDirElements()->GetDicomDirStudyElements();
97       
98    DicomDirStudy *st = new DicomDirStudy();
99    st->FillObject(elemList);
100
101    Studies.push_front(st);
102    return st; 
103 }   
104
105 //-----------------------------------------------------------------------------
106 // Protected
107
108 //-----------------------------------------------------------------------------
109 // Private
110
111 //-----------------------------------------------------------------------------
112
113 } // end namespace gdcm