]> Creatis software - gdcm.git/blob - src/gdcmHeaderEntry.h
1c8520aecc211afafa6676045cc7df55d7312fe0
[gdcm.git] / src / gdcmHeaderEntry.h
1 // gdcmHeaderEntry.h
2 //-----------------------------------------------------------------------------
3 #ifndef GDCMHeaderEntry_H
4 #define GDCMHeaderEntry_H
5
6 #include "gdcmDictEntry.h"
7 class gdcmHeader;
8
9 #include <stdio.h>
10
11 //-----------------------------------------------------------------------------
12 /*
13  * The dicom header of a Dicom file contains a set of such entries
14  * (when successfuly parsed against a given Dicom dictionary)
15  */
16 class GDCM_EXPORT gdcmHeaderEntry {
17 public:
18    gdcmHeaderEntry(gdcmDictEntry*);
19    
20    inline guint16      GetGroup(void)     { return entry->GetGroup();  };
21    inline guint16      GetElement(void)   { return entry->GetElement();};
22    inline std::string  GetKey(void)       { return entry->GetKey();    };
23    inline std::string  GetName(void)      { return entry->GetName();   };
24    inline std::string  GetVR(void)        { return entry->GetVR();     };
25    inline std::string  GetValue(void)     { return value;              };
26    inline void *       GetVoidArea(void)  { return voidArea;           };
27    inline size_t       GetOffset(void)    { return Offset;             };   
28    inline guint32      GetLength(void)    { return UsableLength;       };   
29    inline void         SetVR(std::string v)      { entry->SetVR(v);          };    
30    inline void         SetLength(guint32 l)      { ReadLength=UsableLength=l;};
31       
32    // The following 3 members, for internal use only ! 
33    inline void         SetReadLength(guint32 l)  { ReadLength   = l; };         
34    inline void         SetUsableLength(guint32 l){ UsableLength = l; };         
35    inline guint32      GetReadLength(void)       { return ReadLength;};
36         
37    inline void         SetValue(std::string val) { value = val;      };
38    inline void         SetVoidArea(void * area)  { voidArea = area;  };
39    
40    /**
41     * \ingroup gdcmHeaderEntry
42     * \brief   Sets the offset of the Dicom Element
43     * \warning : use with caution !
44     * @param   of offset to be set
45     */
46    inline void gdcmHeaderEntry::SetOffset(size_t of) { Offset = of; };
47
48    /**
49     * \ingroup gdcmHeaderEntry
50     * \brief   Sets the DicEntry of the current Dicom Element
51     * @param   NewEntry pointer to the DictEntry
52     */ 
53    inline void gdcmHeaderEntry::SetDictEntry(gdcmDictEntry *NewEntry) { 
54       entry = NewEntry; 
55    };
56
57    /**
58     * \ingroup gdcmHeaderEntry
59     * \brief   Sets to TRUE the ImplicitVr flag of the current Dicom Element
60     */
61    inline void gdcmHeaderEntry::SetImplicitVr(void) { 
62       ImplicitVr = true; 
63    };
64  
65    /**
66     * \ingroup gdcmHeaderEntry
67     * \brief   tells us if the current Dicom Element was checked as ImplicitVr
68     * @return true if the current Dicom Element was checked as ImplicitVr
69     */ 
70    inline bool  gdcmHeaderEntry::IsImplicitVr(void) { 
71        return ImplicitVr; 
72     };
73
74    /**
75     * \ingroup gdcmHeaderEntry
76     * \brief   Gets the DicEntry of the current Dicom Element
77     * @return  the DicEntry of the current Dicom Element
78     */
79    gdcmDictEntry * gdcmHeaderEntry::GetDictEntry(void) { 
80       return entry;    
81    }; 
82
83    /**
84     * \ingroup gdcmHeaderEntry
85     * \brief   tells us if the VR of the current Dicom Element is Unkonwn
86     * @return true if the VR is unkonwn
87     */ 
88    inline bool   gdcmHeaderEntry::IsVRUnknown(void) { 
89       return entry->IsVRUnknown(); 
90    };
91
92 private:
93    // FIXME: In fact we should be more specific and use :
94    // friend gdcmHeaderEntry * gdcmHeader::ReadNextElement(void);
95    friend class gdcmHeader;
96
97 // Variables
98    gdcmDictEntry *entry;
99    guint32 UsableLength;  // Updated from ReadLength, by FixFoungLentgh()
100                           // for fixing a bug in the header or helping
101                           // the parser going on 
102                           
103    guint32 ReadLength;    // Length actually read on disk
104                           // (before FixFoundLength)
105                           // ReadLength will be updated only when
106                           // FixFoundLength actually fixes a bug in the header,
107                           // not when it performs a trick to help the Parser
108                           // going on.
109                           // *for internal* use only
110         
111    bool ImplicitVr;       // Even when reading explicit vr files, some
112                           // elements happen to be implicit. Flag them here
113                           // since we can't use the entry->vr without breaking
114                           // the underlying dictionary.
115                           
116
117    std::string  value;
118    void *voidArea;  // unsecure memory area to hold 'non string' values 
119                      // (ie : Lookup Tables, overlays)
120    size_t Offset;    // Offset from the begining of file for direct user access
121 };
122
123 //-----------------------------------------------------------------------------
124 #endif