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