]> Creatis software - gdcm.git/blob - src/gdcmDicomDir.h
* src/gdcmDicomDit.h the Method typedef is now local to DicomDir class.
[gdcm.git] / src / gdcmDicomDir.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDir.h,v $
5   Language:  C++
6   Date:      $Date: 2004/11/09 10:25:27 $
7   Version:   $Revision: 1.37 $
8   
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.
12   
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.
16   
17 =========================================================================*/
18
19 #ifndef GDCMDICOMDIR_H
20 #define GDCMDICOMDIR_H
21
22 #include "gdcmCommon.h"
23 #include "gdcmDocument.h"
24 #include "gdcmDicomDirPatient.h"
25 #include "gdcmDicomDirMeta.h"
26 #include "gdcmDicomDirElement.h"
27
28 #include <list>
29 #include <vector>
30
31 namespace gdcm 
32 {
33 //-----------------------------------------------------------------------------
34 typedef std::list<DicomDirPatient*>   ListDicomDirPatient;
35 typedef std::vector<Document*>  VectDocument;
36
37 //-----------------------------------------------------------------------------
38
39 /**
40  * \ingroup DicomDir
41  * \brief    DicomDir defines an object representing a DICOMDIR in memory.
42  *
43  */
44 class GDCM_EXPORT DicomDir: public Document
45 {
46 public:
47    typedef GDCM_EXPORT void(Method)(void*);
48    DicomDir( std::string const & filename, bool parseDir = false );
49    DicomDir(); 
50                    
51    ~DicomDir();
52
53    /// \brief   canonical Printer 
54    /// \sa    SetPrintLevel
55    void Print(std::ostream &os = std::cout);
56
57    /// Informations contained in the parser
58    virtual bool IsReadable();
59
60    /// Returns a pointer to the DicomDirMeta for this DICOMDIR. 
61    DicomDirMeta* GetDicomDirMeta() { return MetaElems; };
62
63    /// Returns the PATIENT chained List for this DICOMDIR.    
64    ListDicomDirPatient const & GetDicomDirPatients() const { return Patients; };
65
66    /// Parsing
67    void ParseDirectory();
68    
69    void SetStartMethod(    DicomDir::Method*,
70                            void* = NULL,
71                            DicomDir::Method* = NULL );
72    void SetProgressMethod( DicomDir::Method*, 
73                            void* = NULL,
74                            DicomDir::Method* = NULL );
75    void SetEndMethod(      DicomDir::Method*,
76                            void* = NULL, 
77                            DicomDir::Method* = NULL );
78    void SetStartMethodArgDelete( DicomDir::Method* );
79    void SetProgressMethodArgDelete( DicomDir::Method* );
80    void SetEndMethodArgDelete( DicomDir::Method* );
81
82    /// GetProgress GetProgress
83    float GetProgress()  { return Progress; };
84
85    /// AbortProgress AbortProgress
86    void  AbortProgress() { Abort = true; };
87
88    /// IsAborted IsAborted
89    bool  IsAborted() { return Abort; };
90    
91    /// Adding
92    DicomDirMeta*    NewMeta();
93    DicomDirPatient* NewPatient();
94
95    /// Write  
96    bool WriteDicomDir(std::string const & fileName);
97
98    /// Types of the DicomDirObject within the DicomDir
99    typedef enum
100    {
101       GDCM_DICOMDIR_NONE,
102       GDCM_DICOMDIR_META,
103       GDCM_DICOMDIR_PATIENT,
104       GDCM_DICOMDIR_STUDY,
105       GDCM_DICOMDIR_SERIE,
106       GDCM_DICOMDIR_IMAGE
107    } DicomDirType;
108    
109 protected:
110    void CreateDicomDirChainedList(std::string const & path);
111    void CallStartMethod();
112    void CallProgressMethod();
113    void CallEndMethod();
114
115 private:
116    void Initialize();
117    void CreateDicomDir();
118    void AddDicomDirMeta();
119    void AddDicomDirPatientToEnd(SQItem* s);
120    void AddDicomDirStudyToEnd  (SQItem* s);
121    void AddDicomDirSerieToEnd  (SQItem* s);
122    void AddDicomDirImageToEnd  (SQItem* s);
123
124    void SetElements(std::string const & path, VectDocument const &list);
125    void SetElement (std::string const & path, DicomDirType type,
126                     Document* header);
127
128    static bool HeaderLessThan(Document* header1, Document* header2);
129    
130 // Variables
131
132    /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
133    DicomDirMeta* MetaElems;
134
135    /// Chained list of DicomDirPatient (to be exploited recursively) 
136    ListDicomDirPatient Patients;
137
138    /// pointer to the initialisation method for any progress bar   
139    Method* StartMethod;
140    /// pointer to the incrementation method for any progress bar
141    Method* ProgressMethod;
142    /// pointer to the termination method for any progress bar
143    Method* EndMethod;
144    /// pointer to the ??? method for any progress bar   
145    Method* StartMethodArgDelete;
146    /// pointer to the ??? method for any progress bar
147    Method* ProgressMethodArgDelete;
148    /// pointer to the ??? method for any progress bar
149    Method* EndMethodArgDelete;
150    /// pointer to the ??? for any progress bar   
151    void* StartArg;
152    /// pointer to the ??? for any progress bar
153    void* ProgressArg;
154    /// pointer to the ??? for any progress bar   
155    void* EndArg;
156    /// value of the ??? for any progress bar
157    float Progress;
158    /// value of the ??? for any progress bar   
159    bool Abort;
160 };
161 } // end namespace gdcm
162 //-----------------------------------------------------------------------------
163 #endif