]> Creatis software - gdcm.git/blob - src/gdcmDicomDir.h
Fix mistypings
[gdcm.git] / src / gdcmDicomDir.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDir.h,v $
5   Language:  C++
6   Date:      $Date: 2007/09/17 12:16:02 $
7   Version:   $Revision: 1.82 $
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 "gdcmDocument.h"
23 #include "gdcmDebug.h"
24
25 #include <list>
26 #include <vector>
27
28 namespace GDCM_NAME_SPACE 
29 {
30 //-----------------------------------------------------------------------------
31 class DicomDirPatient;
32 class DicomDirMeta;
33 class DicomDirElement;
34 class DicomDirStudy;
35 class DicomDirSerie;
36 class DicomDirVisit;
37 class DicomDirImage;
38 class DicomDirPrivate;
39 class SQItem;
40
41 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
42 typedef std::vector<Document *> VectDocument;
43
44 //-----------------------------------------------------------------------------
45 /**
46  * \brief   DicomDir defines an object representing a DICOMDIR in memory
47  *  as a tree-like structure :
48  *
49  *        ->DicomDirPatient 
50  *           -> DicomDirStudy 
51  *           -> DicomDirVisit 
52  *              -> DicomDirSerie
53  *                 -> DicomDirImage
54  *                 -> DicomDirPrivate (for Siemens CSA non image)
55  */
56 class GDCM_EXPORT DicomDir: public Document
57 {
58    gdcmTypeMacro(DicomDir);
59
60 public:
61 /// \brief Constructs a DicomDir with a RefCounter
62    static DicomDir *New() {return new DicomDir();}
63
64 //   GDCM_LEGACY( bool Load(std::string const &filename) )
65    bool Load( );
66    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
67
68    /// Sets the root Directory name to parse, recursively
69    void SetDirectoryName(std::string const &dirName)
70         { ParseDir = true; if (Filename != dirName)
71                                Filename = dirName, IsDocumentModified = true;}
72    /// Accessor to Filename
73    virtual void SetFileName(std::string const &fileName)
74                    { ParseDir = false; if (Filename != fileName)
75                               Filename = fileName, IsDocumentModified = true;}
76
77    // Informations contained in the parser
78    virtual bool IsReadable();
79
80    // Meta
81    DicomDirMeta *NewMeta();
82    /// Returns a pointer to the DicomDirMeta for this DICOMDIR. 
83    DicomDirMeta *GetMeta() { return MetaElems; }
84
85    // Patients
86    DicomDirPatient *NewPatient();
87    void ClearPatient();
88
89    DicomDirPatient *GetFirstPatient();
90    DicomDirPatient *GetNextPatient();
91    /// returns the number of Patients currently held in the gdcm::DicomDir
92    int              GetNumberOfPatients() { return Patients.size();}
93    
94    // Parsing
95    void ParseDirectory();
96
97    /// GetProgress GetProgress
98    float GetProgress() const { return Progress; }
99    /// AbortProgress AbortProgress
100    void  AbortProgress() { Abort = true; }
101    /// IsAborted IsAborted
102    bool  IsAborted() { return Abort; }
103
104    // Write
105    bool Write(std::string const &fileName);
106
107    bool Anonymize();
108
109    virtual void Copy(DocEntrySet *set);
110
111    /// Types of the DicomDirObject within the DicomDir
112    typedef enum
113    {
114       GDCM_DICOMDIR_NONE,
115       GDCM_DICOMDIR_META,
116       GDCM_DICOMDIR_PATIENT,
117       GDCM_DICOMDIR_STUDY,
118       GDCM_DICOMDIR_SERIE,
119       GDCM_DICOMDIR_VISIT,
120       GDCM_DICOMDIR_IMAGE,
121       GDCM_DICOMDIR_PRIVATE
122    } DicomDirType;
123
124 protected:
125    DicomDir();
126    ~DicomDir();
127 //   GDCM_LEGACY( DicomDir(std::string const &filename, bool parseDir = false) )
128
129    void CreateDicomDirChainedList(std::string const &path);
130
131 private:
132    void Initialize();
133    void CreateDicomDir();
134    bool DoTheLoadingJob();
135    bool AddPatientToEnd(DicomDirPatient *dd);   
136    bool AddStudyToEnd  (DicomDirStudy   *dd);
137    bool AddSerieToEnd  (DicomDirSerie   *dd);
138    bool AddVisitToEnd  (DicomDirVisit   *dd);
139    bool AddImageToEnd  (DicomDirImage   *dd);
140    bool AddPrivateToEnd(DicomDirPrivate *dd);
141    
142    void SetElements(std::string const &path, VectDocument const &list);
143    void SetElement (std::string const &path, DicomDirType type,
144                     Document *header);
145    void MoveSQItem(DocEntrySet *dst, DocEntrySet *src);
146
147    static bool HeaderLessThan(Document *header1, Document *header2);
148
149 // Variables
150
151    /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements'
152    DicomDirMeta *MetaElems;
153
154    /// Chained list of DicomDirPatient (to be exploited hierarchicaly) 
155    ListDicomDirPatient Patients;
156    ListDicomDirPatient::iterator ItPatient;
157
158    /// value of the ??? for any progress bar   
159    bool ParseDir;
160
161 };
162 } // end namespace gdcm
163 //-----------------------------------------------------------------------------
164 #endif