+/**
+ * \brief This predicate, based on hopefully reasonable heuristics,
+ * decides whether or not the current document was properly parsed
+ * and contains the mandatory information for being considered as
+ * a well formed and usable DicomDir.
+ * @return true when Document is the one of a reasonable DicomDir,
+ * false otherwise.
+ */
+bool DicomDir::IsReadable()
+{
+ if ( Filetype == Unknown )
+ {
+ gdcmWarningMacro( "Wrong filetype");
+ 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 )
+ delete MetaElems;
+
+ DocEntry *entry = GetFirstEntry();
+ if ( entry )
+ {
+ MetaElems = new DicomDirMeta(true); // true = empty
+
+ entry = GetFirstEntry();
+ while( entry )
+ {
+ if ( dynamic_cast<SeqEntry *>(entry) )
+ break;
+
+ RemoveEntryNoDestroy(entry);
+ MetaElems->AddEntry(entry);
+
+ entry = GetFirstEntry();
+ }
+ }
+ else // after root directory parsing
+ {
+ MetaElems = new DicomDirMeta(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 *p = new DicomDirPatient();
+ AddPatientToEnd( p );
+ return p;
+}
+
+/**
+ * \brief Remove all Patients
+ */
+void DicomDir::ClearPatient()
+{
+ for(ListDicomDirPatient::iterator cc = Patients.begin();
+ cc!= Patients.end();
+ ++cc)
+ {
+ delete *cc;
+ }
+ 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;