1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
6 Date: $Date: 2007/10/08 15:20:17 $
7 Version: $Revision: 1.44 $
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"
26 namespace GDCM_NAME_SPACE
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, bool , bool )
62 DicomDirObject::WriteContent(fp, t, false, true);
64 for(ListDicomDirStudy::iterator cc = Studies.begin();
68 (*cc)->WriteContent( fp, t, false, true );
73 * \brief adds a new Patient at the beginning of the PatientList
74 * of a partially created DICOMDIR
76 DicomDirStudy* DicomDirPatient::NewStudy()
78 DicomDirStudy *dd = DicomDirStudy::New();
79 Studies.push_back(dd);
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())
140 * \brief Copies all the attributes from an other DocEntrySet
141 * @param set entry to copy from
142 * @remarks The contained DocEntries a not copied, only referenced
144 void DicomDirPatient::Copy(DocEntrySet *set)
146 // Remove all previous childs
149 DicomDirObject::Copy(set);
151 DicomDirPatient *ddEntry = dynamic_cast<DicomDirPatient *>(set);
154 Studies = ddEntry->Studies;
155 for(ItStudy = Studies.begin();ItStudy != Studies.end();++ItStudy)
156 (*ItStudy)->Register();
160 //-----------------------------------------------------------------------------
163 //-----------------------------------------------------------------------------
166 //-----------------------------------------------------------------------------
169 * \brief Prints the Object
170 * @param os ostream to write to
171 * @param indent Indentation string to be prepended during printing
173 void DicomDirPatient::Print(std::ostream &os, std::string const & )
175 os << "PATIENT" << std::endl;
176 DicomDirObject::Print(os);
178 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
182 (*cc)->SetPrintLevel(PrintLevel);
187 //-----------------------------------------------------------------------------
188 } // end namespace gdcm