1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.h,v $
6 Date: $Date: 2005/11/28 15:20:32 $
7 Version: $Revision: 1.71 $
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 #ifndef GDCMDICOMDIR_H
20 #define GDCMDICOMDIR_H
22 #include "gdcmDocument.h"
23 #include "gdcmDebug.h"
30 //-----------------------------------------------------------------------------
31 class DicomDirPatient;
33 class DicomDirElement;
40 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
41 typedef std::vector<Document *> VectDocument;
43 //-----------------------------------------------------------------------------
45 * \brief DicomDir defines an object representing a DICOMDIR in memory
46 * as a tree-like structure DicomDirPatient
51 class GDCM_EXPORT DicomDir: public Document
53 gdcmTypeMacro(DicomDir);
56 /// \brief Constructs a DicomDir with a RefCounter
57 static DicomDir *New() {return new DicomDir();}
60 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
62 /// Sets the root Directory name to parse, recursively
63 void SetDirectoryName(std::string const &dirName)
64 { ParseDir = true; if (Filename != dirName)
65 Filename = dirName, IsDocumentModified = true; }
66 /// Accessor to \ref Filename
67 virtual void SetFileName(std::string const &fileName)
68 { ParseDir = false; if (Filename != fileName)
69 Filename = fileName, IsDocumentModified = true;}
71 // Informations contained in the parser
72 virtual bool IsReadable();
75 DicomDirMeta *NewMeta();
76 /// Returns a pointer to the DicomDirMeta for this DICOMDIR.
77 DicomDirMeta *GetMeta() { return MetaElems; }
80 DicomDirPatient *NewPatient();
83 DicomDirPatient *GetFirstPatient();
84 DicomDirPatient *GetNextPatient();
87 void ParseDirectory();
89 /// GetProgress GetProgress
90 float GetProgress() const { return Progress; }
91 /// AbortProgress AbortProgress
92 void AbortProgress() { Abort = true; }
93 /// IsAborted IsAborted
94 bool IsAborted() { return Abort; }
97 bool Write(std::string const &fileName);
101 /// Types of the DicomDirObject within the DicomDir
106 GDCM_DICOMDIR_PATIENT,
117 void CreateDicomDirChainedList(std::string const &path);
118 void CallStartMethod();
119 void CallProgressMethod();
120 void CallEndMethod();
124 void CreateDicomDir();
125 bool DoTheLoadingJob();
126 bool AddPatientToEnd(DicomDirPatient *dd);
127 bool AddStudyToEnd (DicomDirStudy *dd);
128 bool AddSerieToEnd (DicomDirSerie *dd);
129 bool AddVisitToEnd (DicomDirVisit *dd);
130 bool AddImageToEnd (DicomDirImage *dd);
132 void SetElements(std::string const &path, VectDocument const &list);
133 void SetElement (std::string const &path, DicomDirType type,
135 void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
137 static bool HeaderLessThan(Document *header1, Document *header2);
141 /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
142 DicomDirMeta *MetaElems;
144 /// Chained list of DicomDirPatient (to be exploited hierarchicaly)
145 ListDicomDirPatient Patients;
146 ListDicomDirPatient::iterator ItPatient;
148 /// value of the ??? for any progress bar
150 /// value of the ??? for any progress bar
155 } // end namespace gdcm
156 //-----------------------------------------------------------------------------