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