1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2004/07/02 13:55:27 $
7 Version: $Revision: 1.13 $
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 {
40 gdcmDocEntry(gdcmDictEntry*);
42 /// Returns the Dicom Group number of the current Dicom Header Entry
43 uint16_t GetGroup(void) { return entry->GetGroup(); };
45 /// Returns the Dicom Element number of the current Dicom Header Entry
46 uint16_t GetElement(void) { return entry->GetElement();};
48 /// Returns the 'key' of the current Dicom Header Entry
49 std::string GetKey(void) { return entry->GetKey(); };
51 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
52 /// Dictionnary of the current Dicom Header Entry
53 std::string GetName(void) { return entry->GetName(); };
55 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
56 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
57 /// Dictionnary, of the current Dicom Header Entry
58 std::string GetVR(void) { return entry->GetVR(); };
60 /// \brief Returns offset (since the beginning of the file, including
61 /// the File Pramble, if any) of the value of the current Dicom HeaderEntry
62 /// \warning offset of the *value*, not of the Dicom Header Entry
63 size_t GetOffset(void) { return Offset; };
65 /// \brief Returns the actual value length of the current Dicom Header Entry
66 /// \warning this value is not *always* the one stored in the Dicom Header
67 /// in case of well knowned bugs
68 uint32_t GetLength(void) { return UsableLength; };
70 /// \brief Returns the 'read length' of the current Dicom Header Entry
71 /// \warning this value is the one stored in the Dicom Header but not
72 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
73 /// the usable length is set to zero)
74 uint32_t GetReadLength(void) { return ReadLength; };
76 /// Sets the 'Value Representation' of the current Dicom Header Entry
77 void SetVR(std::string v) { entry->SetVR(v); };
79 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
80 /// Dicom Header Entry
81 void SetLength(uint32_t l) { ReadLength=UsableLength=l;};
83 // The following 3 members, for internal use only !
85 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
86 /// Dicom Header Entry
87 void SetReadLength(uint32_t l) { ReadLength = l; };
89 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
90 /// Dicom Header Entry
91 void SetUsableLength(uint32_t l) { UsableLength = l; };
93 /// \brief Sets the offset of the Dicom Element
94 /// \warning use with caution !
95 /// @param of offset to be set
96 void gdcmDocEntry::SetOffset(size_t of) { Offset = of; };
98 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
99 void gdcmDocEntry::SetImplicitVR(void) { ImplicitVR = true; };
101 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
102 /// @return true if the current Dicom Element was checked as ImplicitVr
103 bool gdcmDocEntry::IsImplicitVR(void) { return ImplicitVR; };
105 /// \brief Tells us if the VR of the current Dicom Element is Unknown
106 /// @return true if the VR is unkonwn
107 bool gdcmDocEntry::IsVRUnknown(void) { return entry->IsVRUnknown(); };
109 /// \brief Sets the DicEntry of the current Dicom Element
110 /// @param NewEntry pointer to the DictEntry
111 void gdcmDocEntry::SetDictEntry(gdcmDictEntry *NewEntry)
112 { entry = NewEntry; };
114 /// \brief Gets the DicEntry of the current Dicom Element
115 /// @return The DicEntry of the current Dicom Element
116 gdcmDictEntry * gdcmDocEntry::GetDictEntry(void) { return entry; };
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(void) { return(printLevel); };
125 virtual void Print (std::ostream & os = std::cout);
126 virtual void Write(FILE *fp, FileType filetype);
128 uint32_t GetFullLength(void);
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(void) {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 *entry;
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 //-----------------------------------------------------------------------------