2 //-----------------------------------------------------------------------------
9 #include "gdcmDictEntry.h"
12 //-----------------------------------------------------------------------------
14 * \ingroup gdcmDocEntry
15 * \brief The dicom header of a Dicom file contains a set of such entries
16 * (when successfuly parsed against a given Dicom dictionary)
18 class GDCM_EXPORT gdcmDocEntry {
20 gdcmDocEntry(gdcmDictEntry*);
22 /// \brief Returns the 'Value' (e.g. "Dupond Marcel") converted into a
23 /// 'string', if it's stored as an integer in the Dicom Header of the
24 /// current Dicom Header Entry
26 //inline std::string GetValue(void) { return value; };
27 // Pour continuer a compiler :-(
28 inline std::string GetValue(void) { return "value"; };
30 /// Returns the Dicom Group number of the current Dicom Header Entry
31 inline guint16 GetGroup(void) { return entry->GetGroup(); };
33 /// Returns the Dicom Element number of the current Dicom Header Entry
34 inline guint16 GetElement(void) { return entry->GetElement();};
36 /// Returns the 'key' of the current Dicom Header Entry
37 inline std::string GetKey(void) { return entry->GetKey(); };
39 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
40 /// Dictionnary of the current Dicom Header Entry
41 inline std::string GetName(void) { return entry->GetName(); };
43 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
44 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
45 /// Dictionnary, of the current Dicom Header Entry
46 inline std::string GetVR(void) { return entry->GetVR(); };
48 /// \brief Returns offset (since the beginning of the file, including
49 /// the File Pramble, if any) of the value of the current Dicom HeaderEntry
50 /// \warning offset of the *value*, not of the Dicom Header Entry
51 inline size_t GetOffset(void) { return Offset; };
53 /// \brief Returns the actual value length of the current Dicom Header Entry
54 /// \warning this value is not *allways* the one stored in the Dicom Header
55 /// in case of well knowned bugs
56 inline guint32 GetLength(void) { return UsableLength; };
58 /// \brief Returns the 'read length' of the current Dicom Header Entry
59 /// \warning this value is the one stored in the Dicom Header but not
60 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
61 /// the usable length is set to zero)
62 inline guint32 GetReadLength(void) { return ReadLength; };
64 /// Sets the 'Value Representation' of the current Dicom Header Entry
65 inline void SetVR(std::string v) { entry->SetVR(v); };
67 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
68 /// Dicom Header Entry
69 inline void SetLength(guint32 l) { ReadLength=UsableLength=l;};
71 // The following 3 members, for internal use only !
73 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
74 /// Dicom Header Entry
75 inline void SetReadLength(guint32 l) { ReadLength = l; };
77 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
78 /// Dicom Header Entry
79 inline void SetUsableLength(guint32 l) { UsableLength = l; };
81 /// \brief Sets the offset of the Dicom Element
82 /// \warning use with caution !
83 /// @param of offset to be set
84 inline void gdcmDocEntry::SetOffset(size_t of) { Offset = of; };
86 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
87 inline void gdcmDocEntry::SetImplicitVR(void) { ImplicitVR = true; };
89 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
90 /// @return true if the current Dicom Element was checked as ImplicitVr
91 inline bool gdcmDocEntry::IsImplicitVR(void) { return ImplicitVR; };
93 /// \brief Tells us if the VR of the current Dicom Element is Unknown
94 /// @return true if the VR is unkonwn
95 inline bool gdcmDocEntry::IsVRUnknown(void)
96 { return entry->IsVRUnknown(); };
98 /// \brief Sets the DicEntry of the current Dicom Element
99 /// @param NewEntry pointer to the DictEntry
100 inline void gdcmDocEntry::SetDictEntry(gdcmDictEntry *NewEntry)
101 { entry = NewEntry; };
103 /// \brief Gets the DicEntry of the current Dicom Element
104 /// @return The DicEntry of the current Dicom Element
105 gdcmDictEntry * gdcmDocEntry::GetDictEntry(void) { return entry; };
107 /// \brief Sets the print level for the Dicom Header Elements
108 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
109 void SetPrintLevel(int level) { printLevel = level; };
111 /// \brief Gets the print level for the Dicom Header Elements
112 int GetPrintLevel(void) { return(printLevel); };
114 void Print (std::ostream & os = std::cout);
116 /// Gets the depth level of a Dicom Header Entry embedded in a SeQuence
117 inline int GetSQDepthLevel(void) { return (SQDepthLevel); };
119 guint32 GetFullLength(void);
121 void Copy(gdcmDocEntry *doc);
123 bool isItemDelimitor();
124 bool isSequenceDelimitor();
127 // FIXME: In fact we should be more specific and use :
128 // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void);
129 friend class gdcmHeader;
131 /// Sets the depth level of a Dicom Header Entry embedded in a SeQuence
132 inline void SetSQDepthLevel(int depthLevel) { SQDepthLevel = depthLevel; };
136 gdcmDictEntry *entry;
138 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
139 /// in the header or helping the parser going on
140 guint32 UsableLength;
142 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
143 /// will be updated only when FixFoundLength actually fixes a bug in the
144 /// header, not when it performs a trick to help the Parser going on.
147 /// \brief Even when reading explicit vr files, some elements happen to
148 /// be implicit. Flag them here since we can't use the entry->vr without
149 /// breaking the underlying dictionary.
152 /// Offset from the begining of file for direct user access
155 /// How many details are to be printed (value : 0,1,2)
158 /// Gives the depth level of elements inside SeQuences
162 //-----------------------------------------------------------------------------