]> Creatis software - gdcm.git/blob - src/gdcmDicomDir.h
56f8a083f73bca693ec69c20664d4359fd857f27
[gdcm.git] / src / gdcmDicomDir.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDir.h,v $
5   Language:  C++
6   Date:      $Date: 2004/11/02 03:10:32 $
7   Version:   $Revision: 1.36 $
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 typedef GDCM_EXPORT void(Method)(void*);
38 //-----------------------------------------------------------------------------
39
40 /**
41  * \ingroup DicomDir
42  * \brief    DicomDir defines an object representing a DICOMDIR in memory.
43  *
44  */
45 class GDCM_EXPORT DicomDir: public Document
46 {
47 public:
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(Method*, void* = NULL, Method* = NULL);
70    void SetStartMethodArgDelete(Method*);
71    void SetProgressMethod(Method* ,void* = NULL, Method* = NULL);
72    void SetProgressMethodArgDelete(Method*);
73    void SetEndMethod(Method*, void* = NULL,Method* = NULL);
74    void SetEndMethodArgDelete(Method*);
75
76    /// GetProgress GetProgress
77    float GetProgress()  { return Progress; };
78
79    /// AbortProgress AbortProgress
80    void  AbortProgress() { Abort = true; };
81
82    /// IsAborted IsAborted
83    bool  IsAborted() { return Abort; };
84    
85    /// Adding
86    DicomDirMeta*    NewMeta();
87    DicomDirPatient* NewPatient();
88
89    /// Write  
90    bool WriteDicomDir(std::string const & fileName);
91
92    /// Types of the DicomDirObject within the DicomDir
93    typedef enum
94    {
95       GDCM_DICOMDIR_NONE,
96       GDCM_DICOMDIR_META,
97       GDCM_DICOMDIR_PATIENT,
98       GDCM_DICOMDIR_STUDY,
99       GDCM_DICOMDIR_SERIE,
100       GDCM_DICOMDIR_IMAGE
101    } DicomDirType;
102    
103 protected:
104    void CreateDicomDirChainedList(std::string const & path);
105    void CallStartMethod();
106    void CallProgressMethod();
107    void CallEndMethod();
108
109 private:
110    void Initialize();
111    void CreateDicomDir();
112    void AddDicomDirMeta();
113    void AddDicomDirPatientToEnd(SQItem* s);
114    void AddDicomDirStudyToEnd  (SQItem* s);
115    void AddDicomDirSerieToEnd  (SQItem* s);
116    void AddDicomDirImageToEnd  (SQItem* s);
117
118    void SetElements(std::string const & path, VectDocument const &list);
119    void SetElement (std::string const & path, DicomDirType type,
120                     Document* header);
121
122    static bool HeaderLessThan(Document* header1, Document* header2);
123    
124 // Variables
125
126    /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
127    DicomDirMeta* MetaElems;
128
129    /// Chained list of DicomDirPatient (to be exploited recursively) 
130    ListDicomDirPatient Patients;
131
132    /// pointer to the initialisation method for any progress bar   
133    Method* StartMethod;
134    /// pointer to the incrementation method for any progress bar
135    Method* ProgressMethod;
136    /// pointer to the termination method for any progress bar
137    Method* EndMethod;
138    /// pointer to the ??? method for any progress bar   
139    Method* StartMethodArgDelete;
140    /// pointer to the ??? method for any progress bar
141    Method* ProgressMethodArgDelete;
142    /// pointer to the ??? method for any progress bar
143    Method* EndMethodArgDelete;
144    /// pointer to the ??? for any progress bar   
145    void* StartArg;
146    /// pointer to the ??? for any progress bar
147    void* ProgressArg;
148    /// pointer to the ??? for any progress bar   
149    void* EndArg;
150    /// value of the ??? for any progress bar
151    float Progress;
152    /// value of the ??? for any progress bar   
153    bool Abort;
154 };
155 } // end namespace gdcm
156 //-----------------------------------------------------------------------------
157 #endif