1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2004/06/20 18:08:47 $
7 Version: $Revision: 1.9 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #ifndef GDCMDocEntry_H
20 #define GDCMDocEntry_H
25 #include "gdcmDictEntry.h"
26 //#include "gdcmValEntry.h"
29 //-----------------------------------------------------------------------------
31 * \ingroup gdcmDocEntry
32 * \brief The dicom header of a Dicom file contains a set of such entries
33 * (when successfuly parsed against a given Dicom dictionary)
35 class GDCM_EXPORT gdcmDocEntry {
37 gdcmDocEntry(gdcmDictEntry*);
39 /// Returns the Dicom Group number of the current Dicom Header Entry
40 inline guint16 GetGroup(void) { return entry->GetGroup(); };
42 /// Returns the Dicom Element number of the current Dicom Header Entry
43 inline guint16 GetElement(void) { return entry->GetElement();};
45 /// Returns the 'key' of the current Dicom Header Entry
46 inline std::string GetKey(void) { return entry->GetKey(); };
48 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
49 /// Dictionnary of the current Dicom Header Entry
50 inline std::string GetName(void) { return entry->GetName(); };
52 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
53 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
54 /// Dictionnary, of the current Dicom Header Entry
55 inline std::string GetVR(void) { return entry->GetVR(); };
57 /// \brief Returns offset (since the beginning of the file, including
58 /// the File Pramble, if any) of the value of the current Dicom HeaderEntry
59 /// \warning offset of the *value*, not of the Dicom Header Entry
60 inline size_t GetOffset(void) { return Offset; };
62 /// \brief Returns the actual value length of the current Dicom Header Entry
63 /// \warning this value is not *allways* the one stored in the Dicom Header
64 /// in case of well knowned bugs
65 inline guint32 GetLength(void) { return UsableLength; };
67 /// \brief Returns the 'read length' of the current Dicom Header Entry
68 /// \warning this value is the one stored in the Dicom Header but not
69 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
70 /// the usable length is set to zero)
71 inline guint32 GetReadLength(void) { return ReadLength; };
73 /// Sets the 'Value Representation' of the current Dicom Header Entry
74 inline void SetVR(std::string v) { entry->SetVR(v); };
76 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
77 /// Dicom Header Entry
78 inline void SetLength(guint32 l) { ReadLength=UsableLength=l;};
80 // The following 3 members, for internal use only !
82 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
83 /// Dicom Header Entry
84 inline void SetReadLength(guint32 l) { ReadLength = l; };
86 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
87 /// Dicom Header Entry
88 inline void SetUsableLength(guint32 l) { UsableLength = l; };
90 /// \brief Sets the offset of the Dicom Element
91 /// \warning use with caution !
92 /// @param of offset to be set
93 inline void gdcmDocEntry::SetOffset(size_t of) { Offset = of; };
95 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
96 inline void gdcmDocEntry::SetImplicitVR(void) { ImplicitVR = true; };
98 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
99 /// @return true if the current Dicom Element was checked as ImplicitVr
100 inline bool gdcmDocEntry::IsImplicitVR(void) { return ImplicitVR; };
102 /// \brief Tells us if the VR of the current Dicom Element is Unknown
103 /// @return true if the VR is unkonwn
104 inline bool gdcmDocEntry::IsVRUnknown(void)
105 { return entry->IsVRUnknown(); };
107 /// \brief Sets the DicEntry of the current Dicom Element
108 /// @param NewEntry pointer to the DictEntry
109 inline void gdcmDocEntry::SetDictEntry(gdcmDictEntry *NewEntry)
110 { entry = NewEntry; };
112 /// \brief Gets the DicEntry of the current Dicom Element
113 /// @return The DicEntry of the current Dicom Element
114 gdcmDictEntry * gdcmDocEntry::GetDictEntry(void) { return entry; };
116 /// \brief Sets the print level for the Dicom Header Elements
117 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
118 void SetPrintLevel(int level) { printLevel = level; };
120 /// \brief Gets the print level for the Dicom Header Elements
121 int GetPrintLevel(void) { return(printLevel); };
123 virtual void Print (std::ostream & os = std::cout);
125 void gdcmDocEntry::PrintCommonPart(std::ostream & os);
127 guint32 GetFullLength(void);
129 void Copy(gdcmDocEntry *doc);
131 bool isItemDelimitor();
132 bool isSequenceDelimitor();
134 /// \brief Gets the depth level of a Dicom header entry embedded in
136 inline int GetDepthLevel(void) {return(SQDepthLevel);}
138 /// \brief Sets the depth level of a Dicom header entry embedded in
140 inline void SetDepthLevel(int depth) {SQDepthLevel = depth;}
143 // FIXME: In fact we should be more specific and use :
144 // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void);
145 friend class gdcmHeader;
150 /// \brief pointer to the underlying Dicom dictionary element
151 gdcmDictEntry *entry;
153 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
154 /// in the header or helping the parser going on
155 guint32 UsableLength;
157 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
158 /// will be updated only when FixFoundLength actually fixes a bug in the
159 /// header, not when it performs a trick to help the Parser going on.
162 /// \brief Even when reading explicit vr files, some elements happen to
163 /// be implicit. Flag them here since we can't use the entry->vr without
164 /// breaking the underlying dictionary.
167 /// Offset from the begining of file for direct user access
170 /// How many details are to be printed (value : 0,1,2)
173 /// Gives the depth level of elements inside SeQuences
177 //-----------------------------------------------------------------------------