2 //-----------------------------------------------------------------------------
9 #include "gdcmDictEntry.h"
10 //#include "gdcmValEntry.h"
13 //-----------------------------------------------------------------------------
15 * \ingroup gdcmDocEntry
16 * \brief The dicom header of a Dicom file contains a set of such entries
17 * (when successfuly parsed against a given Dicom dictionary)
19 class GDCM_EXPORT gdcmDocEntry {
21 gdcmDocEntry(gdcmDictEntry*);
23 /// Returns the Dicom Group number of the current Dicom Header Entry
24 inline guint16 GetGroup(void) { return entry->GetGroup(); };
26 /// Returns the Dicom Element number of the current Dicom Header Entry
27 inline guint16 GetElement(void) { return entry->GetElement();};
29 /// Returns the 'key' of the current Dicom Header Entry
30 inline std::string GetKey(void) { return entry->GetKey(); };
32 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
33 /// Dictionnary of the current Dicom Header Entry
34 inline std::string GetName(void) { return entry->GetName(); };
36 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
37 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
38 /// Dictionnary, of the current Dicom Header Entry
39 inline std::string GetVR(void) { return entry->GetVR(); };
41 /// \brief Returns offset (since the beginning of the file, including
42 /// the File Pramble, if any) of the value of the current Dicom HeaderEntry
43 /// \warning offset of the *value*, not of the Dicom Header Entry
44 inline size_t GetOffset(void) { return Offset; };
46 /// \brief Returns the actual value length of the current Dicom Header Entry
47 /// \warning this value is not *allways* the one stored in the Dicom Header
48 /// in case of well knowned bugs
49 inline guint32 GetLength(void) { return UsableLength; };
51 /// \brief Returns the 'read length' of the current Dicom Header Entry
52 /// \warning this value is the one stored in the Dicom Header but not
53 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
54 /// the usable length is set to zero)
55 inline guint32 GetReadLength(void) { return ReadLength; };
57 /// Sets the 'Value Representation' of the current Dicom Header Entry
58 inline void SetVR(std::string v) { entry->SetVR(v); };
60 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
61 /// Dicom Header Entry
62 inline void SetLength(guint32 l) { ReadLength=UsableLength=l;};
64 // The following 3 members, for internal use only !
66 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
67 /// Dicom Header Entry
68 inline void SetReadLength(guint32 l) { ReadLength = l; };
70 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
71 /// Dicom Header Entry
72 inline void SetUsableLength(guint32 l) { UsableLength = l; };
74 /// \brief Sets the offset of the Dicom Element
75 /// \warning use with caution !
76 /// @param of offset to be set
77 inline void gdcmDocEntry::SetOffset(size_t of) { Offset = of; };
79 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
80 inline void gdcmDocEntry::SetImplicitVR(void) { ImplicitVR = true; };
82 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
83 /// @return true if the current Dicom Element was checked as ImplicitVr
84 inline bool gdcmDocEntry::IsImplicitVR(void) { return ImplicitVR; };
86 /// \brief Tells us if the VR of the current Dicom Element is Unknown
87 /// @return true if the VR is unkonwn
88 inline bool gdcmDocEntry::IsVRUnknown(void)
89 { return entry->IsVRUnknown(); };
91 /// \brief Sets the DicEntry of the current Dicom Element
92 /// @param NewEntry pointer to the DictEntry
93 inline void gdcmDocEntry::SetDictEntry(gdcmDictEntry *NewEntry)
94 { entry = NewEntry; };
96 /// \brief Gets the DicEntry of the current Dicom Element
97 /// @return The DicEntry of the current Dicom Element
98 gdcmDictEntry * gdcmDocEntry::GetDictEntry(void) { return entry; };
100 /// \brief Sets the print level for the Dicom Header Elements
101 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
102 void SetPrintLevel(int level) { printLevel = level; };
104 /// \brief Gets the print level for the Dicom Header Elements
105 int GetPrintLevel(void) { return(printLevel); };
107 virtual void Print (std::ostream & os = std::cout);
109 void gdcmDocEntry::PrintCommonPart(std::ostream & os);
111 guint32 GetFullLength(void);
113 void Copy(gdcmDocEntry *doc);
115 bool isItemDelimitor();
116 bool isSequenceDelimitor();
118 /// \brief Gets the depth level of a Dicom header entry embedded in a SeQuence
119 inline int GetDepthLevel(void)
120 {return(SQDepthLevel);}
122 /// \brief Sets the depth level of a Dicom header entry embedded in a SeQuence
123 inline void SetDepthLevel(int depth)
124 {SQDepthLevel = depth;}
127 // FIXME: In fact we should be more specific and use :
128 // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void);
129 friend class gdcmHeader;
134 /// \brief pointer to the underlying Dicom dictionary element
135 gdcmDictEntry *entry;
137 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
138 /// in the header or helping the parser going on
139 guint32 UsableLength;
141 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
142 /// will be updated only when FixFoundLength actually fixes a bug in the
143 /// header, not when it performs a trick to help the Parser going on.
146 /// \brief Even when reading explicit vr files, some elements happen to
147 /// be implicit. Flag them here since we can't use the entry->vr without
148 /// breaking the underlying dictionary.
151 /// Offset from the begining of file for direct user access
154 /// How many details are to be printed (value : 0,1,2)
157 /// Gives the depth level of elements inside SeQuences
161 //-----------------------------------------------------------------------------