]> Creatis software - gdcm.git/blob - src/gdcmDicomDirPatient.cxx
- now, DicomDir stuff stakes into account the 'new' structure
[gdcm.git] / src / gdcmDicomDirPatient.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/08/26 15:29:52 $
7   Version:   $Revision: 1.11 $
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.htm 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
23 //-----------------------------------------------------------------------------
24 // Constructor / Destructor
25 /**
26  * \brief   Constructor
27  * @param  s SQ Item holding the elements related to this "PATIENT" part
28  * @param ptagHT pointer to the HTable (gdcmObject needs it 
29  *               to build the gdcmHeaderEntries)
30  */
31 gdcmDicomDirPatient::gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT):
32    gdcmObject(ptagHT)
33 {
34    docEntries = s->GetDocEntries();
35 }
36 /**
37  * \brief   Constructor
38  * @param ptagHT pointer to the HTable (gdcmObject needs it 
39  *               to build the gdcmHeaderEntries)
40  */
41 gdcmDicomDirPatient::gdcmDicomDirPatient(TagDocEntryHT *ptagHT):
42    gdcmObject(ptagHT)
43 {
44 }
45 /**
46  * \brief   Canonical destructor.
47  */
48 gdcmDicomDirPatient::~gdcmDicomDirPatient() 
49 {
50    for(ListDicomDirStudy::iterator cc = studies.begin();
51                                    cc != studies.end(); ++cc)
52    {
53       delete *cc;
54    }
55 }
56
57 //-----------------------------------------------------------------------------
58 // Print
59 /**
60  * \brief   Prints the Object
61  * @return
62  */ 
63 void gdcmDicomDirPatient::Print(std::ostream &os)
64 {
65    os << "PATIENT" << std::endl;
66    gdcmObject::Print(os);
67
68    for(ListDicomDirStudy::iterator cc = studies.begin();
69                                    cc != studies.end(); ++cc)
70    {
71       (*cc)->SetPrintLevel(PrintLevel);
72       (*cc)->Print(os);
73    }
74 }
75
76 /**
77  * \brief   Writes the Object
78  * @return
79  */ 
80 void gdcmDicomDirPatient::Write(FILE *fp, FileType t)
81 {
82    gdcmObject::Write(fp, t);
83
84    for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
85    {
86       (*cc)->Write( fp, t );
87    }
88 }
89 //-----------------------------------------------------------------------------
90 // Public
91
92 /**
93  * \brief   adds a new Patient at the begining of the PatientList
94  *          of a partially created DICOMDIR
95  */
96 gdcmDicomDirStudy * gdcmDicomDirPatient::NewStudy()
97 {
98    std::list<gdcmElement> elemList = 
99       gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
100       
101    gdcmDicomDirStudy *st = new gdcmDicomDirStudy( PtagHT );
102    st->FillObject(elemList);
103
104    studies.push_front(st);
105    return st; 
106 }   
107
108 //-----------------------------------------------------------------------------
109 // Protected
110
111 //-----------------------------------------------------------------------------
112 // Private
113
114 //-----------------------------------------------------------------------------