00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GDCMDICOMDIR_H
00020 #define GDCMDICOMDIR_H
00021
00022 #include "gdcmDocument.h"
00023
00024 #include <list>
00025 #include <vector>
00026
00027 namespace gdcm
00028 {
00029
00030 class DicomDirPatient;
00031 class DicomDirMeta;
00032 class DicomDirElement;
00033 class DicomDirStudy;
00034 class DicomDirSerie;
00035 class DicomDirImage;
00036 class SQItem;
00037
00038 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
00039 typedef std::vector<Document *> VectDocument;
00040
00041
00049 class GDCM_EXPORT DicomDir: public Document
00050 {
00051 public:
00052 typedef void(Method)(void*);
00053
00054 DicomDir( std::string const &filename, bool parseDir = false );
00055 DicomDir();
00056
00057 ~DicomDir();
00058
00059 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
00060
00061
00062 virtual bool IsReadable();
00063
00064
00065 DicomDirMeta *NewMeta();
00067 DicomDirMeta* GetMeta() { return MetaElems; };
00068
00069
00070 DicomDirPatient *NewPatient();
00071 void ClearPatient();
00072
00073 DicomDirPatient *GetFirstPatient();
00074 DicomDirPatient *GetNextPatient();
00075
00076
00077 void ParseDirectory();
00078
00079
00080
00081
00082 void SetStartMethod( DicomDir::Method *method,
00083 void *arg = NULL,
00084 DicomDir::Method *argDelete = NULL );
00085 void SetProgressMethod( DicomDir::Method *method,
00086 void *arg = NULL,
00087 DicomDir::Method *argDelete = NULL );
00088 void SetEndMethod( DicomDir::Method *method,
00089 void *arg = NULL,
00090 DicomDir::Method *argDelete = NULL );
00091 void SetStartMethodArgDelete( DicomDir::Method *m );
00092 void SetProgressMethodArgDelete( DicomDir::Method *m );
00093 void SetEndMethodArgDelete( DicomDir::Method *m );
00094
00096 float GetProgress() { return Progress; };
00098 void AbortProgress() { Abort = true; };
00100 bool IsAborted() { return Abort; };
00101
00102
00103 bool WriteDicomDir(std::string const &fileName);
00104
00106 typedef enum
00107 {
00108 GDCM_DICOMDIR_NONE,
00109 GDCM_DICOMDIR_META,
00110 GDCM_DICOMDIR_PATIENT,
00111 GDCM_DICOMDIR_STUDY,
00112 GDCM_DICOMDIR_SERIE,
00113 GDCM_DICOMDIR_IMAGE
00114 } DicomDirType;
00115
00116 protected:
00117 void CreateDicomDirChainedList(std::string const &path);
00118 void CallStartMethod();
00119 void CallProgressMethod();
00120 void CallEndMethod();
00121
00122 private:
00123 void Initialize();
00124 void CreateDicomDir();
00125
00126 bool AddPatientToEnd(DicomDirPatient *dd);
00127 bool AddStudyToEnd (DicomDirStudy *dd);
00128 bool AddSerieToEnd (DicomDirSerie *dd);
00129 bool AddImageToEnd (DicomDirImage *dd);
00130
00131 void SetElements(std::string const &path, VectDocument const &list);
00132 void SetElement (std::string const &path, DicomDirType type,
00133 Document *header);
00134 void MoveSQItem(DocEntrySet *dst,DocEntrySet *src);
00135
00136 static bool HeaderLessThan(Document *header1, Document *header2);
00137
00138
00139
00141 DicomDirMeta* MetaElems;
00142
00144 ListDicomDirPatient Patients;
00145 ListDicomDirPatient::iterator ItPatient;
00146
00148 Method *StartMethod;
00150 Method *ProgressMethod;
00152 Method *EndMethod;
00154 Method *StartMethodArgDelete;
00156 Method* ProgressMethodArgDelete;
00158 Method *EndMethodArgDelete;
00160 void *StartArg;
00162 void *ProgressArg;
00164 void *EndArg;
00166 float Progress;
00168 bool Abort;
00169 };
00170 }
00171
00172 #endif