1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
6 Date: $Date: 2005/01/18 14:28:32 $
7 Version: $Revision: 1.28 $
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.
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.
17 =========================================================================*/
19 #include "gdcmDicomDirPatient.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmGlobal.h"
22 #include "gdcmDicomDirStudy.h"
23 #include "gdcmSQItem.h"
24 #include "gdcmDebug.h"
29 //-----------------------------------------------------------------------------
30 // Constructor / Destructor
34 DicomDirPatient::DicomDirPatient():
39 * \brief Canonical destructor.
41 DicomDirPatient::~DicomDirPatient()
43 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
51 //-----------------------------------------------------------------------------
54 * \brief Prints the Object
55 * @param os ostream to write to
56 * @param indent indent
58 void DicomDirPatient::Print(std::ostream &os, std::string const & )
60 os << "PATIENT" << std::endl;
61 DicomDirObject::Print(os);
63 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
67 (*cc)->SetPrintLevel(PrintLevel);
73 * \brief Writes the Object
74 * @param fp ofstream to write to
75 * @param t Type of the File (explicit VR, implicitVR, ...)
77 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
79 DicomDirObject::WriteContent(fp, t);
81 for(ListDicomDirStudy::iterator cc = Studies.begin();
85 (*cc)->WriteContent( fp, t );
88 //-----------------------------------------------------------------------------
92 * \brief adds a new Patient at the begining of the PatientList
93 * of a partially created DICOMDIR
95 DicomDirStudy* DicomDirPatient::NewStudy()
97 ListDicomDirStudyElem const &elemList =
98 Global::GetDicomDirElements()->GetDicomDirStudyElements();
100 DicomDirStudy *st = new DicomDirStudy();
101 st->FillObject(elemList);
103 Studies.push_front(st);
108 * \brief Get the first entry while visiting the DicomDirStudy
109 * \return The first DicomDirStudy if found, otherwhise NULL
111 DicomDirStudy *DicomDirPatient::GetFirstEntry()
113 ItDicomDirStudy = Studies.begin();
114 if (ItDicomDirStudy != Studies.end())
115 return *ItDicomDirStudy;
120 * \brief Get the next entry while visiting the DicomDirStudies
121 * \note : meaningfull only if GetFirstEntry already called
122 * \return The next DicomDirStudies if found, otherwhise NULL
124 DicomDirStudy *DicomDirPatient::GetNextEntry()
126 gdcmAssertMacro (ItDicomDirStudy != Studies.end())
129 if (ItDicomDirStudy != Studies.end())
130 return *ItDicomDirStudy;
134 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
140 //-----------------------------------------------------------------------------
142 } // end namespace gdcm