1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
6 Date: $Date: 2005/02/02 10:02:16 $
7 Version: $Revision: 1.37 $
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"
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
32 * \note End user must use : DicomDir::NewPatient()
34 DicomDirPatient::DicomDirPatient(bool empty)
39 ListDicomDirStudyElem const &elemList =
40 Global::GetDicomDirElements()->GetDicomDirPatientElements();
46 * \brief Canonical destructor.
48 DicomDirPatient::~DicomDirPatient()
53 //-----------------------------------------------------------------------------
56 * \brief Writes the Object
57 * @param fp ofstream to write to
58 * @param t Type of the File (explicit VR, implicitVR, ...)
60 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
62 DicomDirObject::WriteContent(fp, t);
64 for(ListDicomDirStudy::iterator cc = Studies.begin();
68 (*cc)->WriteContent( fp, t );
73 * \brief adds a new Patient at the beginning of the PatientList
74 * of a partially created DICOMDIR
76 DicomDirStudy* DicomDirPatient::NewStudy()
78 DicomDirStudy *st = new DicomDirStudy();
79 Studies.push_back(st);
84 * \brief Remove all studies in the patient
86 void DicomDirPatient::ClearStudy()
88 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
98 * \brief Get the first entry while visiting the DicomDirStudy
99 * \return The first DicomDirStudy if found, otherwhise NULL
101 DicomDirStudy *DicomDirPatient::GetFirstStudy()
103 ItStudy = Studies.begin();
104 if (ItStudy != Studies.end())
110 * \brief Get the next entry while visiting the DicomDirStudies
111 * \note : meaningfull only if GetFirstEntry already called
112 * \return The next DicomDirStudies if found, otherwhise NULL
114 DicomDirStudy *DicomDirPatient::GetNextStudy()
116 gdcmAssertMacro (ItStudy != Studies.end())
119 if (ItStudy != Studies.end())
125 * \brief Get the first entry while visiting the DicomDirStudy
126 * \return The first DicomDirStudy if found, otherwhise NULL
128 DicomDirStudy *DicomDirPatient::GetLastStudy()
130 ItStudy = Studies.end();
131 if (ItStudy != Studies.begin())
139 //-----------------------------------------------------------------------------
142 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
148 * \brief Prints the Object
149 * @param os ostream to write to
150 * @param indent Indentation string to be prepended during printing
152 void DicomDirPatient::Print(std::ostream &os, std::string const & )
154 os << "PATIENT" << std::endl;
155 DicomDirObject::Print(os);
157 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
161 (*cc)->SetPrintLevel(PrintLevel);
166 //-----------------------------------------------------------------------------
167 } // end namespace gdcm