+bool DicomDir::IsReadable()
+{
+ if ( Filetype == Unknown )
+ {
+ gdcmErrorMacro( "Wrong filetype for " << GetFileName());
+ return false;
+ }
+ if ( !MetaElems )
+ {
+ gdcmWarningMacro( "Meta Elements missing in DicomDir");
+ return false;
+ }
+ if ( Patients.size() <= 0 )
+ {
+ gdcmWarningMacro( "NO Patient in DicomDir");
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * \brief adds *the* Meta to a partially created DICOMDIR
+ */
+DicomDirMeta *DicomDir::NewMeta()
+{
+ if ( MetaElems )
+ MetaElems->Delete();
+
+ DocEntry *entry = GetFirstEntry();
+ if ( entry )
+ {
+ MetaElems = DicomDirMeta::New(true); // true = empty
+
+ entry = GetFirstEntry();
+ while( entry )
+ {
+ if ( dynamic_cast<SeqEntry *>(entry) )
+ break;
+
+ MetaElems->AddEntry(entry);
+ RemoveEntry(entry);
+
+ entry = GetFirstEntry();
+ }
+ }
+ else // after root directory parsing
+ {
+ MetaElems = DicomDirMeta::New(false); // false = not empty
+ }
+ MetaElems->SetSQItemNumber(0); // To avoid further missprinting
+ return MetaElems;
+}
+
+/**
+ * \brief adds a new Patient (with the basic elements) to a partially created
+ * DICOMDIR
+ */
+DicomDirPatient *DicomDir::NewPatient()
+{
+ DicomDirPatient *dd = DicomDirPatient::New();
+ AddPatientToEnd( dd );
+ return dd;
+}
+
+/**
+ * \brief Remove all Patients
+ */
+void DicomDir::ClearPatient()
+{
+ for(ListDicomDirPatient::iterator cc = Patients.begin();
+ cc!= Patients.end();
+ ++cc)
+ {
+ (*cc)->Unregister();
+ }
+ Patients.clear();
+}
+
+/**
+ * \brief Get the first entry while visiting the DicomDirPatients
+ * \return The first DicomDirPatient if found, otherwhise NULL
+ */
+DicomDirPatient *DicomDir::GetFirstPatient()
+{
+ ItPatient = Patients.begin();
+ if ( ItPatient != Patients.end() )
+ return *ItPatient;
+ return NULL;
+}
+
+/**
+ * \brief Get the next entry while visiting the DicomDirPatients
+ * \note : meaningfull only if GetFirstEntry already called
+ * \return The next DicomDirPatient if found, otherwhise NULL
+ */
+DicomDirPatient *DicomDir::GetNextPatient()
+{
+ gdcmAssertMacro (ItPatient != Patients.end());
+
+ ++ItPatient;
+ if ( ItPatient != Patients.end() )
+ return *ItPatient;
+ return NULL;
+}
+
+/**
+ * \brief fills the whole structure, starting from a root Directory
+ */
+void DicomDir::ParseDirectory()
+{
+ CreateDicomDirChainedList( GetFileName() );