1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.h,v $
6 Date: $Date: 2007/08/20 13:24:04 $
7 Version: $Revision: 1.80 $
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"
28 namespace GDCM_NAME_SPACE
30 //-----------------------------------------------------------------------------
31 class DicomDirPatient;
33 class DicomDirElement;
38 class DicomDirPrivate;
41 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
42 typedef std::vector<Document *> VectDocument;
44 //-----------------------------------------------------------------------------
46 * \brief DicomDir defines an object representing a DICOMDIR in memory
47 * as a tree-like structure :
54 * -> DicomDirPrivate (for Siemens CSA non image)
56 class GDCM_EXPORT DicomDir: public Document
58 gdcmTypeMacro(DicomDir);
61 /// \brief Constructs a DicomDir with a RefCounter
62 static DicomDir *New() {return new DicomDir();}
64 // GDCM_LEGACY( bool Load(std::string const &filename) )
66 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
68 /// Sets the root Directory name to parse, recursively
69 void SetDirectoryName(std::string const &dirName)
70 { ParseDir = true; if (Filename != dirName)
71 Filename = dirName, IsDocumentModified = true;}
72 /// Accessor to \ref Filename
73 virtual void SetFileName(std::string const &fileName)
74 { ParseDir = false; if (Filename != fileName)
75 Filename = fileName, IsDocumentModified = true;}
77 // Informations contained in the parser
78 virtual bool IsReadable();
81 DicomDirMeta *NewMeta();
82 /// Returns a pointer to the DicomDirMeta for this DICOMDIR.
83 DicomDirMeta *GetMeta() { return MetaElems; }
86 DicomDirPatient *NewPatient();
89 DicomDirPatient *GetFirstPatient();
90 DicomDirPatient *GetNextPatient();
91 /// returns the number of Patients currently held in the gdcm::DicomDir
92 int GetNumberOfPatients() { return Patients.size();}
95 void ParseDirectory();
97 /// GetProgress GetProgress
98 float GetProgress() const { return Progress; }
99 /// AbortProgress AbortProgress
100 void AbortProgress() { Abort = true; }
101 /// IsAborted IsAborted
102 bool IsAborted() { return Abort; }
105 bool Write(std::string const &fileName);
109 virtual void Copy(DocEntrySet *set);
111 /// Types of the DicomDirObject within the DicomDir
116 GDCM_DICOMDIR_PATIENT,
121 GDCM_DICOMDIR_PRIVATE
127 // GDCM_LEGACY( DicomDir(std::string const &filename, bool parseDir = false) )
129 void CreateDicomDirChainedList(std::string const &path);
133 void CreateDicomDir();
134 bool DoTheLoadingJob();
135 bool AddPatientToEnd(DicomDirPatient *dd);
136 bool AddStudyToEnd (DicomDirStudy *dd);
137 bool AddSerieToEnd (DicomDirSerie *dd);
138 bool AddVisitToEnd (DicomDirVisit *dd);
139 bool AddImageToEnd (DicomDirImage *dd);
140 bool AddPrivateToEnd(DicomDirPrivate *dd);
142 void SetElements(std::string const &path, VectDocument const &list);
143 void SetElement (std::string const &path, DicomDirType type,
145 void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
147 static bool HeaderLessThan(Document *header1, Document *header2);
151 /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
152 DicomDirMeta *MetaElems;
154 /// Chained list of DicomDirPatient (to be exploited hierarchicaly)
155 ListDicomDirPatient Patients;
156 ListDicomDirPatient::iterator ItPatient;
158 /// value of the ??? for any progress bar
162 } // end namespace gdcm
163 //-----------------------------------------------------------------------------