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