1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.h,v $
6 Date: $Date: 2005/08/29 12:29:50 $
7 Version: $Revision: 1.67 $
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
54 typedef void Method(void*);
57 GDCM_LEGACY( DicomDir(std::string const &filename, bool parseDir = false) );
60 GDCM_LEGACY( bool Load(std::string const &filename) );
62 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
64 /// Sets the root Directory name to parse, recursively
65 void SetDirectoryName(std::string const &dirName)
66 { ParseDir = true; if (Filename != dirName)
67 Filename = dirName, IsDocumentModified = true; }
68 /// Accessor to \ref Filename
69 virtual void SetFileName(std::string const &fileName)
70 { ParseDir = false; if (Filename != fileName)
71 Filename = fileName, IsDocumentModified = true;}
73 /// DEPRECATED : use SetDirectoryName
74 GDCM_LEGACY( void SetParseDir(bool parseDir) );
76 // Informations contained in the parser
77 virtual bool IsReadable();
80 DicomDirMeta *NewMeta();
81 /// Returns a pointer to the DicomDirMeta for this DICOMDIR.
82 DicomDirMeta *GetMeta() { return MetaElems; }
85 DicomDirPatient *NewPatient();
88 DicomDirPatient *GetFirstPatient();
89 DicomDirPatient *GetNextPatient();
92 void ParseDirectory();
94 // Note: the DicomDir:: namespace prefix is needed by Swig in the
95 // following method declarations. Refer to gdcmPython/gdcm.i
96 // for the reasons of this unnecessary notation at C++ level.
97 void SetStartMethod( DicomDir::Method *method,
99 void SetProgressMethod( DicomDir::Method *method,
101 void SetEndMethod( DicomDir::Method *method,
103 // Note: replace DicomDir::Method *method to void(*method)(void *) to
104 // avoid wrapping problems with the typemap conversions
105 void SetStartMethod( void(*method)(void *), // DicomDir::Method *method
107 void(*argDelete)(void *));
108 void SetProgressMethod( void(*method)(void *), // DicomDir::Method *method
110 void(*argDelete)(void *));
111 void SetEndMethod( void(*method)(void *), // DicomDir::Method *method
113 void(*argDelete)(void *));
114 void SetStartMethodArgDelete ( DicomDir::Method *method );
115 void SetProgressMethodArgDelete( DicomDir::Method *method );
116 void SetEndMethodArgDelete ( DicomDir::Method *method );
118 /// GetProgress GetProgress
119 float GetProgress() { return Progress; }
120 /// AbortProgress AbortProgress
121 void AbortProgress() { Abort = true; }
122 /// IsAborted IsAborted
123 bool IsAborted() { return Abort; }
126 bool WriteDicomDir(std::string const &fileName);
128 bool AnonymizeDicomDir();
130 /// Types of the DicomDirObject within the DicomDir
135 GDCM_DICOMDIR_PATIENT,
143 void CreateDicomDirChainedList(std::string const &path);
144 void CallStartMethod();
145 void CallProgressMethod();
146 void CallEndMethod();
150 void CreateDicomDir();
151 bool DoTheLoadingJob();
152 bool AddPatientToEnd(DicomDirPatient *dd);
153 bool AddStudyToEnd (DicomDirStudy *dd);
154 bool AddSerieToEnd (DicomDirSerie *dd);
155 bool AddVisitToEnd (DicomDirVisit *dd);
156 bool AddImageToEnd (DicomDirImage *dd);
158 void SetElements(std::string const &path, VectDocument const &list);
159 void SetElement (std::string const &path, DicomDirType type,
161 void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
163 static bool HeaderLessThan(Document *header1, Document *header2);
167 /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
168 DicomDirMeta *MetaElems;
170 /// Chained list of DicomDirPatient (to be exploited hierarchicaly)
171 ListDicomDirPatient Patients;
172 ListDicomDirPatient::iterator ItPatient;
174 /// pointer to the initialisation method for any progress bar
176 /// pointer to the incrementation method for any progress bar
177 Method *ProgressMethod;
178 /// pointer to the termination method for any progress bar
180 /// pointer to the ??? method for any progress bar
181 Method *StartMethodArgDelete;
182 /// pointer to the ??? method for any progress bar
183 Method* ProgressMethodArgDelete;
184 /// pointer to the ??? method for any progress bar
185 Method *EndMethodArgDelete;
186 /// pointer to the ??? for any progress bar
188 /// pointer to the ??? for any progress bar
190 /// pointer to the ??? for any progress bar
192 /// value of the ??? for any progress bar
194 /// value of the ??? for any progress bar
198 } // end namespace gdcm
199 //-----------------------------------------------------------------------------