1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
6 Date: $Date: 2005/01/23 10:12:33 $
7 Version: $Revision: 1.31 $
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(bool empty):
39 ListDicomDirStudyElem const &elemList =
40 Global::GetDicomDirElements()->GetDicomDirPatientElements();
46 * \brief Canonical destructor.
48 DicomDirPatient::~DicomDirPatient()
50 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
58 //-----------------------------------------------------------------------------
61 * \brief Prints the Object
62 * @param os ostream to write to
63 * @param indent Indentation string to be prepended during printing
65 void DicomDirPatient::Print(std::ostream &os, std::string const & )
67 os << "PATIENT" << std::endl;
68 DicomDirObject::Print(os);
70 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
74 (*cc)->SetPrintLevel(PrintLevel);
79 //-----------------------------------------------------------------------------
82 * \brief Writes the Object
83 * @param fp ofstream to write to
84 * @param t Type of the File (explicit VR, implicitVR, ...)
86 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
88 DicomDirObject::WriteContent(fp, t);
90 for(ListDicomDirStudy::iterator cc = Studies.begin();
94 (*cc)->WriteContent( fp, t );
99 * \brief adds a new Patient at the begining of the PatientList
100 * of a partially created DICOMDIR
102 DicomDirStudy* DicomDirPatient::NewStudy()
104 DicomDirStudy *st = new DicomDirStudy();
105 Studies.push_back(st);
110 * \brief Get the first entry while visiting the DicomDirStudy
111 * \return The first DicomDirStudy if found, otherwhise NULL
113 DicomDirStudy *DicomDirPatient::GetFirstStudy()
115 ItStudy = Studies.begin();
116 if (ItStudy != Studies.end())
122 * \brief Get the next entry while visiting the DicomDirStudies
123 * \note : meaningfull only if GetFirstEntry already called
124 * \return The next DicomDirStudies if found, otherwhise NULL
126 DicomDirStudy *DicomDirPatient::GetNextStudy()
128 gdcmAssertMacro (ItStudy != Studies.end())
131 if (ItStudy != Studies.end())
138 * \brief Get the first entry while visiting the DicomDirStudy
139 * \return The first DicomDirStudy if found, otherwhise NULL
141 DicomDirStudy *DicomDirPatient::GetLastStudy()
143 ItStudy = Studies.end();
144 if (ItStudy != Studies.begin())
152 //-----------------------------------------------------------------------------
155 //-----------------------------------------------------------------------------
158 //-----------------------------------------------------------------------------
159 } // end namespace gdcm