1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
6 Date: $Date: 2005/01/28 17:01:29 $
7 Version: $Revision: 1.34 $
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
33 * \note End user must use : DicomDir::NewPatient()
35 DicomDirPatient::DicomDirPatient(bool empty):
40 ListDicomDirStudyElem const &elemList =
41 Global::GetDicomDirElements()->GetDicomDirPatientElements();
47 * \brief Canonical destructor.
49 DicomDirPatient::~DicomDirPatient()
54 //-----------------------------------------------------------------------------
57 * \brief Prints the Object
58 * @param os ostream to write to
59 * @param indent Indentation string to be prepended during printing
61 void DicomDirPatient::Print(std::ostream &os, std::string const & )
63 os << "PATIENT" << std::endl;
64 DicomDirObject::Print(os);
66 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
70 (*cc)->SetPrintLevel(PrintLevel);
75 //-----------------------------------------------------------------------------
78 * \brief Writes the Object
79 * @param fp ofstream to write to
80 * @param t Type of the File (explicit VR, implicitVR, ...)
82 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
84 DicomDirObject::WriteContent(fp, t);
86 for(ListDicomDirStudy::iterator cc = Studies.begin();
90 (*cc)->WriteContent( fp, t );
95 * \brief adds a new Patient at the begining of the PatientList
96 * of a partially created DICOMDIR
98 DicomDirStudy* DicomDirPatient::NewStudy()
100 DicomDirStudy *st = new DicomDirStudy();
101 Studies.push_back(st);
106 * \brief Remove all studies in the patient
108 void DicomDirPatient::ClearStudy()
110 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
120 * \brief Get the first entry while visiting the DicomDirStudy
121 * \return The first DicomDirStudy if found, otherwhise NULL
123 DicomDirStudy *DicomDirPatient::GetFirstStudy()
125 ItStudy = Studies.begin();
126 if (ItStudy != Studies.end())
132 * \brief Get the next entry while visiting the DicomDirStudies
133 * \note : meaningfull only if GetFirstEntry already called
134 * \return The next DicomDirStudies if found, otherwhise NULL
136 DicomDirStudy *DicomDirPatient::GetNextStudy()
138 gdcmAssertMacro (ItStudy != Studies.end())
141 if (ItStudy != Studies.end())
147 * \brief Get the first entry while visiting the DicomDirStudy
148 * \return The first DicomDirStudy if found, otherwhise NULL
150 DicomDirStudy *DicomDirPatient::GetLastStudy()
152 ItStudy = Studies.end();
153 if (ItStudy != Studies.begin())
161 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
167 //-----------------------------------------------------------------------------
168 } // end namespace gdcm