]> Creatis software - gdcm.git/blob - src/gdcmDicomDirPatient.cxx
ENH: Adding 'gdcm' namespace. Be nice with me this was a ~13000 lines patch. Also...
[gdcm.git] / src / gdcmDicomDirPatient.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/10/12 04:35:45 $
7   Version:   $Revision: 1.15 $
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::iterator cc = studies.begin();
53                                    cc != studies.end(); ++cc)
54    {
55       delete *cc;
56    }
57 }
58
59 //-----------------------------------------------------------------------------
60 // Print
61 /**
62  * \brief   Prints the Object
63  * @return
64  */ 
65 void DicomDirPatient::Print(std::ostream& os)
66 {
67    os << "PATIENT" << std::endl;
68    DicomDirObject::Print(os);
69
70    for(ListDicomDirStudy::iterator cc = studies.begin();
71                                    cc != studies.end(); ++cc)
72    {
73       (*cc)->SetPrintLevel(PrintLevel);
74       (*cc)->Print(os);
75    }
76 }
77
78 /**
79  * \brief   Writes the Object
80  * @return
81  */ 
82 void DicomDirPatient::Write(FILE* fp, FileType t)
83 {
84    DicomDirObject::Write(fp, t);
85
86    for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
87    {
88       (*cc)->Write( fp, t );
89    }
90 }
91 //-----------------------------------------------------------------------------
92 // Public
93
94 /**
95  * \brief   adds a new Patient at the begining of the PatientList
96  *          of a partially created DICOMDIR
97  */
98 DicomDirStudy* DicomDirPatient::NewStudy()
99 {
100    std::list<Element> elemList = 
101       Global::GetDicomDirElements()->GetDicomDirStudyElements();
102       
103    DicomDirStudy* st = new DicomDirStudy( PtagHT );
104    st->FillObject(elemList);
105
106    studies.push_front(st);
107    return st; 
108 }   
109
110 //-----------------------------------------------------------------------------
111 // Protected
112
113 //-----------------------------------------------------------------------------
114 // Private
115
116 //-----------------------------------------------------------------------------
117
118 } // end namespace gdcm