1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.h,v $
6 Date: $Date: 2005/07/08 10:13:38 $
7 Version: $Revision: 1.62 $
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"
29 //-----------------------------------------------------------------------------
30 class DicomDirPatient;
32 class DicomDirElement;
38 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
39 typedef std::vector<Document *> VectDocument;
41 //-----------------------------------------------------------------------------
43 * \brief DicomDir defines an object representing a DICOMDIR in memory
44 * as a tree-like structure DicomDirPatient
49 class GDCM_EXPORT DicomDir: public Document
52 typedef void Method(void*);
54 DicomDir( std::string const &filename, bool parseDir = false );
59 bool Load( std::string const &filename );
61 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
63 /// Sets the root Directory name to parse, recursively
64 void SetDirectoryName(std::string const &dirName)
65 { ParseDir = true; if (Filename != dirName)
66 Filename = dirName, IsDocumentModified = true; };
67 /// Accessor to \ref Filename
68 virtual void SetFileName(std::string const &fileName)
69 { ParseDir = false; if (Filename != fileName)
70 Filename = fileName, IsDocumentModified = true; }
72 /// DEPRECATED : use SetDirectoryName
73 void SetParseDir(bool parseDir) { ParseDir = parseDir; };
75 // Informations contained in the parser
76 virtual bool IsReadable();
79 DicomDirMeta *NewMeta();
80 /// Returns a pointer to the DicomDirMeta for this DICOMDIR.
81 DicomDirMeta *GetMeta() { return MetaElems; };
84 DicomDirPatient *NewPatient();
87 DicomDirPatient *GetFirstPatient();
88 DicomDirPatient *GetNextPatient();
91 void ParseDirectory();
93 // Note: the DicomDir:: namespace prefix is needed by Swig in the
94 // following method declarations. Refer to gdcmPython/gdcm.i
95 // for the reasons of this unnecessary notation at C++ level.
96 void SetStartMethod( DicomDir::Method *method,
98 DicomDir::Method *argDelete = NULL );
99 void SetProgressMethod( DicomDir::Method *method,
101 DicomDir::Method *argDelete = NULL );
102 void SetEndMethod( DicomDir::Method *method,
104 DicomDir::Method *argDelete = NULL );
105 void SetStartMethodArgDelete ( DicomDir::Method *m );
106 void SetProgressMethodArgDelete( DicomDir::Method *m );
107 void SetEndMethodArgDelete ( DicomDir::Method *m );
109 /// GetProgress GetProgress
110 float GetProgress() { return Progress; };
111 /// AbortProgress AbortProgress
112 void AbortProgress() { Abort = true; };
113 /// IsAborted IsAborted
114 bool IsAborted() { return Abort; };
117 bool WriteDicomDir(std::string const &fileName);
119 bool AnonymizeDicomDir();
121 /// Types of the DicomDirObject within the DicomDir
126 GDCM_DICOMDIR_PATIENT,
133 void CreateDicomDirChainedList(std::string const &path);
134 void CallStartMethod();
135 void CallProgressMethod();
136 void CallEndMethod();
140 void CreateDicomDir();
141 bool DoTheLoadingJob();
142 bool AddPatientToEnd(DicomDirPatient *dd);
143 bool AddStudyToEnd (DicomDirStudy *dd);
144 bool AddSerieToEnd (DicomDirSerie *dd);
145 bool AddImageToEnd (DicomDirImage *dd);
147 void SetElements(std::string const &path, VectDocument const &list);
148 void SetElement (std::string const &path, DicomDirType type,
150 void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
152 static bool HeaderLessThan(Document *header1, Document *header2);
156 /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
157 DicomDirMeta *MetaElems;
159 /// Chained list of DicomDirPatient (to be exploited hierarchicaly)
160 ListDicomDirPatient Patients;
161 ListDicomDirPatient::iterator ItPatient;
163 /// pointer to the initialisation method for any progress bar
165 /// pointer to the incrementation method for any progress bar
166 Method *ProgressMethod;
167 /// pointer to the termination method for any progress bar
169 /// pointer to the ??? method for any progress bar
170 Method *StartMethodArgDelete;
171 /// pointer to the ??? method for any progress bar
172 Method* ProgressMethodArgDelete;
173 /// pointer to the ??? method for any progress bar
174 Method *EndMethodArgDelete;
175 /// pointer to the ??? for any progress bar
177 /// pointer to the ??? for any progress bar
179 /// pointer to the ??? for any progress bar
181 /// value of the ??? for any progress bar
183 /// value of the ??? for any progress bar
187 } // end namespace gdcm
188 //-----------------------------------------------------------------------------