]> Creatis software - gdcm.git/blob - src/gdcmDicomDir.h
* FIX : bug fix in the gdcmDirList for the recursivity in directories
[gdcm.git] / src / gdcmDicomDir.h
1 // gdcmDicomDir.h
2 //-----------------------------------------------------------------------------
3 #ifndef GDCMDICOMDIR_H
4 #define GDCMDICOMDIR_H
5
6 #include "gdcmHeader.h"
7 #include "gdcmCommon.h"
8 #include "gdcmPatient.h"
9 #include "gdcmMeta.h"
10 #include "gdcmDicomDirElement.h"
11
12 #include <list>
13 #include <vector>
14
15 //-----------------------------------------------------------------------------
16 typedef std::list<gdcmPatient *>   ListPatient;
17 typedef std::vector<gdcmHeader *>  ListHeader;
18
19 //-----------------------------------------------------------------------------
20 /*
21  * \defgroup gdcmDicomDir
22  * \brief    gdcmDicomDir defines an object representing a DICOMDIR in memory.
23  *
24  */
25 class GDCM_EXPORT gdcmDicomDir: public gdcmParser
26 {
27 public:
28 //   gdcmDicomDir(ListTag *l,         bool exception_on_error = false);
29    gdcmDicomDir(const char *FileName, 
30                 bool parseDir = false,
31                 bool exception_on_error = false);
32    
33    ~gdcmDicomDir(void);
34
35    void SetPrintLevel(int level) { printLevel = level; };
36    virtual void Print(std::ostream &os = std::cout);
37
38    inline gdcmMeta   *GetMeta()      {return metaElems;};
39    inline ListPatient &GetPatients() {return patients;};
40
41 // Write
42    bool Write(std::string fileName);
43    void ParseDirectory(void);
44
45 // Types
46    typedef enum
47    {
48       GDCM_NONE,
49       GDCM_META,
50       GDCM_PATIENT,
51       GDCM_STUDY,
52       GDCM_SERIE,
53       GDCM_IMAGE,
54    } gdcmDicomDirType;
55    
56 protected:
57    void NewDicomDir(std::string path);
58    std::string GetPath(void);
59
60 private:
61    void CreateDicomDir(void);
62    void AddObjectToEnd(gdcmDicomDirType type,
63                         ListTag::iterator begin,ListTag::iterator end);
64    void AddMetaToEnd   (ListTag::iterator begin,ListTag::iterator end);
65    void AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end);
66    void AddStudyToEnd  (ListTag::iterator begin,ListTag::iterator end);
67    void AddSerieToEnd  (ListTag::iterator begin,ListTag::iterator end);
68    void AddImageToEnd  (ListTag::iterator begin,ListTag::iterator end);
69
70    void SetElements(std::string &path,ListHeader &list);
71    void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header);
72
73    static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
74
75    gdcmMeta *metaElems;
76    ListPatient patients;
77 };
78
79 //-----------------------------------------------------------------------------
80 #endif