]> Creatis software - gdcm.git/blob - src/gdcmDicomDirPatient.cxx
* src/ : fix compilation warnings for the Write method (2 different
[gdcm.git] / src / gdcmDicomDirPatient.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/11/25 15:46:11 $
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 "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  s SQ Item holding the elements related to this "PATIENT" part
30  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
31  *               to build the HeaderEntries)
32  */
33 DicomDirPatient::DicomDirPatient(SQItem *s, TagDocEntryHT *ptagHT) :
34    DicomDirObject(ptagHT)
35 {
36    DocEntries = s->GetDocEntries();
37 }
38 /**
39  * \brief   Constructor
40  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
41  *               to build the HeaderEntries)
42  */
43 DicomDirPatient::DicomDirPatient(TagDocEntryHT* ptagHT):
44    DicomDirObject(ptagHT)
45 {
46 }
47 /**
48  * \brief   Canonical destructor.
49  */
50 DicomDirPatient::~DicomDirPatient() 
51 {
52    for(ListDicomDirStudy::const_iterator cc = Studies.begin();
53                                          cc != Studies.end(); 
54                                        ++cc )
55    {
56       delete *cc;
57    }
58 }
59
60 //-----------------------------------------------------------------------------
61 // Print
62 /**
63  * \brief   Prints the Object
64  * @return
65  */ 
66 void DicomDirPatient::Print(std::ostream& os)
67 {
68    os << "PATIENT" << std::endl;
69    DicomDirObject::Print(os);
70
71    for(ListDicomDirStudy::const_iterator cc = Studies.begin();
72                                          cc != Studies.end(); 
73                                        ++cc )
74    {
75       (*cc)->SetPrintLevel(PrintLevel);
76       (*cc)->Print(os);
77    }
78 }
79
80 /**
81  * \brief   Writes the Object
82  * @return
83  */ 
84 void DicomDirPatient::WriteContent(std::ofstream* fp, FileType t)
85 {
86    DicomDirObject::WriteContent(fp, t);
87
88    for(ListDicomDirStudy::iterator cc = Studies.begin();
89                                    cc!= Studies.end();
90                                  ++cc )
91    {
92       (*cc)->WriteContent( fp, t );
93    }
94 }
95 //-----------------------------------------------------------------------------
96 // Public
97
98 /**
99  * \brief   adds a new Patient at the begining of the PatientList
100  *          of a partially created DICOMDIR
101  */
102 DicomDirStudy* DicomDirPatient::NewStudy()
103 {
104    ListDicomDirStudyElem const & elemList = 
105       Global::GetDicomDirElements()->GetDicomDirStudyElements();
106       
107    DicomDirStudy* st = new DicomDirStudy( PtagHT );
108    st->FillObject(elemList);
109
110    Studies.push_front(st);
111    return st; 
112 }   
113
114 //-----------------------------------------------------------------------------
115 // Protected
116
117 //-----------------------------------------------------------------------------
118 // Private
119
120 //-----------------------------------------------------------------------------
121
122 } // end namespace gdcm