+ d = (*i)->GetDocEntry(0x0004, 0x1430); // Directory Record Type
+ if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) )
+ {
+ v = valEntry->GetValue();
+ }
+ else
+ {
+ gdcmVerboseMacro( "Not a ValEntry.");
+ continue;
+ }
+
+ if( v == "PATIENT " )
+ {
+ si = new DicomDirPatient();
+ AddDicomDirPatientToEnd( static_cast<DicomDirPatient *>(si) );
+ type = DicomDir::GDCM_DICOMDIR_PATIENT;
+ }
+ else if( v == "STUDY " )
+ {
+ si = new DicomDirStudy();
+ AddDicomDirStudyToEnd( static_cast<DicomDirStudy *>(si) );
+ type = DicomDir::GDCM_DICOMDIR_STUDY;
+ }
+ else if( v == "SERIES" )
+ {
+ si = new DicomDirSerie();
+ AddDicomDirSerieToEnd( static_cast<DicomDirSerie *>(si) );
+ type = DicomDir::GDCM_DICOMDIR_SERIE;
+ }
+ else if( v == "IMAGE " )
+ {
+ si = new DicomDirImage();
+ AddDicomDirImageToEnd( static_cast<DicomDirImage *>(si) );
+ type = DicomDir::GDCM_DICOMDIR_IMAGE;
+ }
+ else
+ {
+ // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
+ // neither an 'IMAGE' SQItem. Skip to next item.
+ continue;
+ }
+ MoveSQItem(si,*i);
+ }
+ TagHT.clear();
+}
+
+/**
+ * \ingroup DicomDir
+ * \brief Well ... there is only one occurence
+ */
+bool DicomDir::AddDicomDirMeta()
+{
+ if( MetaElems )
+ {
+ delete MetaElems;
+ }
+ MetaElems = new DicomDirMeta();
+ return true;
+}
+
+/**
+ * \ingroup DicomDir
+ * \brief AddDicomDirPatientToEnd
+ * @param dd SQ Item to enqueue to the DicomPatient chained List
+ */
+bool DicomDir::AddDicomDirPatientToEnd(DicomDirPatient *dd)
+{
+ Patients.push_back(dd);
+ return true;
+}
+
+/**
+ * \ingroup DicomDir
+ * \brief AddDicomDirStudyToEnd
+ * @param dd SQ Item to enqueue to the DicomDirStudy chained List
+ */
+bool DicomDir::AddDicomDirStudyToEnd(DicomDirStudy *dd)
+{
+ if( Patients.size() > 0 )
+ {
+ ListDicomDirPatient::iterator itp = Patients.end();