]> Creatis software - gdcm.git/blob - src/gdcmDicomDir.h
ENH: Could not compile using g++ -pedantic
[gdcm.git] / src / gdcmDicomDir.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDir.h,v $
5   Language:  C++
6   Date:      $Date: 2004/09/23 23:28:19 $
7   Version:   $Revision: 1.30 $
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.htm 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 //-----------------------------------------------------------------------------
32 typedef std::list<gdcmDicomDirPatient*>   ListDicomDirPatient;
33 typedef std::vector<gdcmDocument*>  VectDocument;
34
35 typedef GDCM_EXPORT void(gdcmMethod)(void * = NULL);
36 //-----------------------------------------------------------------------------
37
38 /**
39  * \ingroup gdcmDicomDir
40  * \brief    gdcmDicomDir defines an object representing a DICOMDIR in memory.
41  *
42  */
43 class GDCM_EXPORT gdcmDicomDir: public gdcmDocument
44 {
45 public:
46    gdcmDicomDir( std::string const & fileName, bool parseDir = false );
47    gdcmDicomDir(); 
48                    
49    ~gdcmDicomDir();
50
51    /// \brief   canonical Printer 
52    /// \sa    SetPrintLevel
53    virtual void Print(std::ostream &os = std::cout);
54
55 // Informations contained in the parser
56    virtual bool IsReadable();
57
58    /// Returns a pointer to the gdcmDicomDirMeta for this DICOMDIR. 
59    gdcmDicomDirMeta* GetDicomDirMeta() { return metaElems; };
60
61    /// Returns the PATIENT chained List for this DICOMDIR.    
62    ListDicomDirPatient &GetDicomDirPatients() { return patients; };
63
64 // Parsing
65    void ParseDirectory();
66    
67    void SetStartMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL);
68    void SetStartMethodArgDelete(gdcmMethod *);
69    void SetProgressMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL);
70    void SetProgressMethodArgDelete(gdcmMethod *);
71    void SetEndMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL);
72    void SetEndMethodArgDelete(gdcmMethod *);
73
74    /// GetProgress GetProgress
75    float GetProgress()  { return progress; };
76
77    /// AbortProgress AbortProgress
78    void  AbortProgress() { abort = true; };
79
80    /// IsAborted IsAborted
81    bool  IsAborted() { return abort; };
82    
83 // Adding
84    gdcmDicomDirMeta*    NewMeta();
85    gdcmDicomDirPatient* NewPatient();
86
87 // Write  
88    bool WriteDicomDir(std::string const & fileName);
89
90    /// Types of the gdcmDicomDirObject within the gdcmDicomDir
91    typedef enum
92    {
93       GDCM_DICOMDIR_NONE,
94       GDCM_DICOMDIR_META,
95       GDCM_DICOMDIR_PATIENT,
96       GDCM_DICOMDIR_STUDY,
97       GDCM_DICOMDIR_SERIE,
98       GDCM_DICOMDIR_IMAGE
99    } gdcmDicomDirType;
100    
101 protected:
102    void CreateDicomDirChainedList(std::string const & path);
103    void CallStartMethod();
104    void CallProgressMethod();
105    void CallEndMethod();
106
107 private:
108    void Initialize();
109    void CreateDicomDir();
110    void AddDicomDirMeta();
111    void AddDicomDirPatientToEnd(gdcmSQItem *s);
112    void AddDicomDirStudyToEnd  (gdcmSQItem *s);
113    void AddDicomDirSerieToEnd  (gdcmSQItem *s);
114    void AddDicomDirImageToEnd  (gdcmSQItem *s);
115
116    void SetElements(std::string &path, VectDocument &list);
117    void SetElement (std::string &path,gdcmDicomDirType type,
118                     gdcmDocument *header);
119
120    static bool HeaderLessThan(gdcmDocument *header1,gdcmDocument *header2);
121    
122 // Variables
123
124    /// Pointer on *the* gdcmDicomDirObject 'DicomDirMeta Elements'
125    gdcmDicomDirMeta *metaElems;
126
127    /// Chained list of DicomDirPatient (to be exploited recursively) 
128    ListDicomDirPatient patients;
129
130 /// pointer to the initialisation method for any progress bar   
131    gdcmMethod *startMethod;
132 /// pointer to the incrementation method for any progress bar
133     gdcmMethod *progressMethod;
134 /// pointer to the termination method for any progress bar
135    gdcmMethod *endMethod;
136 /// pointer to the ??? method for any progress bar   
137    gdcmMethod *startMethodArgDelete;
138 /// pointer to the ??? method for any progress bar
139    gdcmMethod *progressMethodArgDelete;
140 /// pointer to the ??? method for any progress bar
141    gdcmMethod *endMethodArgDelete;
142 /// pointer to the ??? for any progress bar   
143    void *startArg;
144 /// pointer to the ??? for any progress bar
145    void *progressArg;
146 /// pointer to the ??? for any progress bar   
147    void *endArg;
148 /// value of the ??? for any progress bar
149    float progress;
150 /// value of the ??? for any progress bar   
151    bool abort;
152 };
153
154 //-----------------------------------------------------------------------------
155 #endif