]> Creatis software - gdcm.git/blob - src/gdcmHeaderEntrySet.h
* src/gdcmHeaderEntry.[h|cxx] : gdcmElValue -> gdcmHeaderEntry
[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  * Container for a set of successfully parsed HeaderEntrys (i.e. Dicom Elements).
28  */
29 class GDCM_EXPORT gdcmHeaderEntrySet {
30 public: 
31    ~gdcmHeaderEntrySet();
32
33    void Print(std::ostream &);
34
35    void Add(gdcmHeaderEntry*);
36                         
37    gdcmHeaderEntry* GetHeaderEntryByNumber(guint16 group, guint16 element);
38    std::string GetEntryByNumber(guint16 group, guint16 element);
39         
40    bool SetEntryByNumber(std::string content, guint16 group, guint16 element);
41    bool SetEntryLengthByNumber(guint32 l, guint16 group, guint16 element);
42    bool SetVoidAreaByNumber(void *a, guint16 Group, guint16 Elem );
43
44    guint32 GenerateFreeTagKeyInGroup(guint16 group);
45    int CheckIfExistByNumber(guint16 Group, guint16 Elem );  // int !
46
47    /**
48     * \ingroup gdcmHeaderEntrySet
49     * \brief   returns a ref to the Dicom Header H table (multimap)
50     * return the Dicom Header H table
51     */
52    inline TagHeaderEntryHT & gdcmHeaderEntrySet::GetTagHT(void) { return tagHT; };
53
54    /**
55     * \ingroup gdcmHeaderEntrySet
56     * \brief   returns a ref to the Dicom Header chained list
57     * return the Dicom Header chained list
58     */
59    inline ListTag      & gdcmHeaderEntrySet::GetListEntry(void) { return listEntries; };
60
61    bool Write(FILE *fp, FileType type);
62
63 private:
64    void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
65    void WriteEntries(FileType type, FILE *);
66    
67 // Variables
68    TagHeaderEntryHT tagHT; // H Table (multimap), to provide fast access
69    ListTag listEntries;   // chained list, to keep the 'spacial' ordering
70 };
71
72 //-----------------------------------------------------------------------------
73 #endif