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