]> Creatis software - gdcm.git/blob - src/gdcmHeaderEntrySet.h
Write uses now chained list instead of (now unuable for this purpose) H Table
[gdcm.git] / src / gdcmHeaderEntrySet.h
1 // gdcmHeaderEntrySet.h
2 //-----------------------------------------------------------------------------
3 #ifndef GDCMHeaderEntrySet_H
4 #define GDCMHeaderEntrySet_H
5
6 #include "gdcmCommon.h"
7 #include "gdcmHeaderEntry.h"
8
9 #include <stdio.h>
10 #include <map>
11 #include <list>       // for linking together *all* the Dicom Elements
12
13 //-----------------------------------------------------------------------------
14 typedef std::multimap<TagKey, gdcmHeaderEntry*> TagHeaderEntryHT;
15 typedef std::pair<TagKey, gdcmHeaderEntry*> PairHT;
16 typedef std::pair<TagHeaderEntryHT::iterator,TagHeaderEntryHT::iterator> IterHT; 
17
18 typedef std::list<gdcmHeaderEntry*> ListTag; // for linking together the Elements
19
20 // TODO : to be removed after re-writting   gdcmHeaderEntrySet::UpdateGroupLength
21 //          using the chained list instead of the H table
22 typedef std::string GroupKey;
23 typedef std::map<GroupKey, int> GroupHT;
24
25 //-----------------------------------------------------------------------------
26 /*
27  * \defgroup gdcmHeaderEntrySet
28  * \brief Container for a set of successfully parsed HeaderEntries 
29  *        (i.e. Dicom Elements).
30  */
31 class GDCM_EXPORT gdcmHeaderEntrySet {
32 public: 
33    ~gdcmHeaderEntrySet();
34
35    void Print(std::ostream &);
36
37    void Add(gdcmHeaderEntry*);
38                         
39    gdcmHeaderEntry* GetHeaderEntryByNumber(guint16 group, guint16 element);
40    std::string GetEntryByNumber(guint16 group, guint16 element);
41         
42    bool SetEntryByNumber(std::string content, guint16 group, guint16 element);
43    bool SetEntryLengthByNumber(guint32 l, guint16 group, guint16 element);
44    bool SetVoidAreaByNumber(void *a, guint16 Group, guint16 Elem );
45
46    guint32 GenerateFreeTagKeyInGroup(guint16 group);
47    int CheckIfExistByNumber(guint16 Group, guint16 Elem );  // int !
48
49    /**
50     * \ingroup gdcmHeaderEntrySet
51     * \brief   returns a ref to the Dicom Header H table (multimap)
52     * return the Dicom Header H table
53     */
54    inline TagHeaderEntryHT & gdcmHeaderEntrySet::GetTagHT(void) { return tagHT; };
55
56    /**
57     * \ingroup gdcmHeaderEntrySet
58     * \brief   returns a ref to the Dicom Header chained list
59     * return the Dicom Header chained list
60     */
61    inline ListTag      & gdcmHeaderEntrySet::GetListEntry(void) { return listEntries; };
62
63    bool Write(FILE *fp, FileType type);
64
65 private:
66    void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
67    void WriteEntries(FileType type, FILE *);
68    
69 // Variables
70    TagHeaderEntryHT tagHT; // H Table (multimap), to provide fast access
71    ListTag listEntries;    // chained list, to keep the 'spacial' ordering
72 };
73
74 //-----------------------------------------------------------------------------
75 #endif