1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2004/08/31 14:24:47 $
7 Version: $Revision: 1.17 $
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"
32 //-----------------------------------------------------------------------------
34 * \ingroup gdcmDocEntry
35 * \brief The dicom header of a Dicom file contains a set of such entries
36 * (when successfuly parsed against a given Dicom dictionary)
38 class GDCM_EXPORT gdcmDocEntry
41 gdcmDocEntry(gdcmDictEntry*);
43 /// Returns the Dicom Group number of the current Dicom Header Entry
44 uint16_t GetGroup() { return DictEntry->GetGroup(); };
46 /// Returns the Dicom Element number of the current Dicom Header Entry
47 uint16_t GetElement() { return DictEntry->GetElement();};
49 /// Returns the 'key' of the current Dicom Header Entry
50 std::string GetKey() { return DictEntry->GetKey(); };
52 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
53 /// Dictionnary of the current Dicom Header Entry
54 std::string GetName() { return DictEntry->GetName(); };
56 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
57 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
58 /// Dictionnary, of the current Dicom Header Entry
59 std::string GetVR() { return DictEntry->GetVR(); };
61 /// \brief Returns offset (since the beginning of the file, including
62 /// the File Pramble, if any) of the value of the current Dicom HeaderEntry
63 /// \warning offset of the *value*, not of the Dicom Header Entry
64 size_t GetOffset() { return Offset; };
66 /// \brief Returns the actual value length of the current Dicom Header Entry
67 /// \warning this value is not *always* the one stored in the Dicom Header
68 /// in case of well knowned bugs
69 uint32_t GetLength() { return UsableLength; };
71 /// \brief Returns the 'read length' of the current Dicom Header Entry
72 /// \warning this value is the one stored in the Dicom Header but not
73 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
74 /// the usable length is set to zero)
75 uint32_t GetReadLength() { return ReadLength; };
77 /// Sets the 'Value Representation' of the current Dicom Header Entry
78 void SetVR(std::string const & v) { DictEntry->SetVR(v); };
80 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
81 /// Dicom Header Entry
82 void SetLength(uint32_t l) { ReadLength = UsableLength = l;};
84 // The following 3 members, for internal use only !
86 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
87 /// Dicom Header Entry
88 void SetReadLength(uint32_t l) { ReadLength = l; };
90 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
91 /// Dicom Header Entry
92 void SetUsableLength(uint32_t l) { UsableLength = l; };
94 /// \brief Sets the offset of the Dicom Element
95 /// \warning use with caution !
96 /// @param of offset to be set
97 void SetOffset(size_t of) { Offset = of; };
99 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
100 void SetImplicitVR() { ImplicitVR = true; };
102 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
103 /// @return true if the current Dicom Element was checked as ImplicitVr
104 bool IsImplicitVR() { return ImplicitVR; };
106 /// \brief Tells us if the VR of the current Dicom Element is Unknown
107 /// @return true if the VR is unkonwn
108 bool IsVRUnknown() { return DictEntry->IsVRUnknown(); };
110 /// \brief Sets the DicEntry of the current Dicom Element
111 /// @param newEntry pointer to the DictEntry
112 void SetDictEntry(gdcmDictEntry *newEntry) { DictEntry = newEntry; };
114 /// \brief Gets the DicEntry of the current Dicom Element
115 /// @return The DicEntry of the current Dicom Element
116 gdcmDictEntry * GetDictEntry() { return DictEntry; };
118 /// \brief Sets the print level for the Dicom Header Elements
119 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
120 void SetPrintLevel(int level) { PrintLevel = level; };
122 /// \brief Gets the print level for the Dicom Header Elements
123 int GetPrintLevel() { return PrintLevel; };
125 virtual void Print (std::ostream & os = std::cout);
126 virtual void Write(FILE *fp, FileType filetype);
128 uint32_t GetFullLength();
130 void Copy(gdcmDocEntry *doc);
132 bool IsItemDelimitor();
133 bool IsSequenceDelimitor();
135 /// \brief Gets the depth level of a Dicom header entry embedded in
137 int GetDepthLevel() { return SQDepthLevel; }
139 /// \brief Sets the depth level of a Dicom header entry embedded in
141 void SetDepthLevel(int depth) { SQDepthLevel = depth; }
144 // FIXME: In fact we should be more specific and use :
145 // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void);
146 friend class gdcmHeader;
151 /// \brief pointer to the underlying Dicom dictionary element
152 gdcmDictEntry *DictEntry;
154 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
155 /// in the header or helping the parser going on
156 uint32_t UsableLength;
158 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
159 /// will be updated only when FixFoundLength actually fixes a bug in the
160 /// header, not when it performs a trick to help the Parser going on.
163 /// \brief Even when reading explicit vr files, some elements happen to
164 /// be implicit. Flag them here since we can't use the entry->vr without
165 /// breaking the underlying dictionary.
168 /// Offset from the begining of file for direct user access
171 /// How many details are to be printed (value : 0,1,2)
174 /// Gives the depth level of elements inside SeQuences
178 //-----------------------------------------------------------------------------