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