1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2004/12/03 20:16:58 $
7 Version: $Revision: 1.32 $
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.html 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
22 #include "gdcmDictEntry.h"
34 //-----------------------------------------------------------------------------
36 * \brief The dicom header of a Dicom file contains a set of such entries
37 * (when successfuly parsed against a given Dicom dictionary)
39 class GDCM_EXPORT DocEntry
43 virtual ~DocEntry() {};
45 /// Returns the Dicom Group number of the current Dicom Header Entry
46 uint16_t GetGroup() { return DicomDict->GetGroup(); };
48 /// Returns the Dicom Element number of the current Dicom Header Entry
49 uint16_t GetElement() { return DicomDict->GetElement();};
51 /// Returns the 'key' of the current Dicom Header Entry
52 void SetKey( TagKey const & key ) { Key = key; }
54 /// Returns the 'key' of the current Dicom Header Entry
55 std::string const & GetKey() const { return Key; }
57 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
58 /// Dictionnary of the current Dicom Header Entry
59 std::string const & GetName() const { return DicomDict->GetName(); };
61 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
62 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
63 /// Dictionnary, of the current Dicom Header Entry
64 std::string const & GetVR() const { return DicomDict->GetVR(); };
66 /// \brief Returns offset (since the beginning of the file, including
67 /// the File Preamble, if any) of the value of the current Dicom HeaderEntry
68 /// \warning offset of the *value*, not of the Dicom Header Entry
69 size_t GetOffset() { return Offset; };
71 /// \brief Returns the actual value length of the current Dicom Header Entry
72 /// \warning this value is not *always* the one stored in the Dicom Header
73 /// in case of well knowned bugs
74 uint32_t GetLength() { return UsableLength; };
76 /// \brief Returns the 'read length' of the current Dicom Header Entry
77 /// \warning this value is the one stored in the Dicom Header but not
78 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
79 /// the usable length is set to zero)
80 uint32_t GetReadLength() { return ReadLength; };
82 /// Sets the 'Value Representation' of the current Dicom Header Entry
83 void SetVR( TagName const & v) { DicomDict->SetVR(v); };
85 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
86 /// Dicom Header Entry
87 void SetLength(uint32_t l) { ReadLength = UsableLength = l; };
89 // The following 3 members, for internal use only !
91 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
92 /// Dicom Header Entry
93 void SetReadLength(uint32_t l) { ReadLength = l; };
95 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
96 /// Dicom Header Entry
97 void SetUsableLength(uint32_t l) { UsableLength = l; };
99 /// \brief Sets the offset of the Dicom Element
100 /// \warning use with caution !
101 /// @param of offset to be set
102 void SetOffset(size_t of) { Offset = of; };
104 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
105 void SetImplicitVR() { ImplicitVR = true; };
107 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
108 /// @return true if the current Dicom Element was checked as ImplicitVr
109 bool IsImplicitVR() { return ImplicitVR; };
111 /// \brief Tells us if the VR of the current Dicom Element is Unknown
112 /// @return true if the VR is unknown
113 bool IsVRUnknown() { return DicomDict->IsVRUnknown(); };
115 /// \brief Sets the DicEntry of the current Dicom Element
116 /// @param newEntry pointer to the DictEntry
117 void SetDictEntry(DictEntry *newEntry) { DicomDict = newEntry; };
119 /// \brief Gets the DicEntry of the current Dicom Element
120 /// @return The DicEntry of the current Dicom Element
121 DictEntry * GetDictEntry() { return DicomDict; };
123 /// \brief Sets the print level for the Dicom Header Elements
124 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
125 void SetPrintLevel(int level) { PrintLevel = level; };
127 /// \brief Gets the print level for the Dicom Header Elements
128 int GetPrintLevel() { return PrintLevel; };
130 virtual void Print (std::ostream & os = std::cout);
131 virtual void WriteContent(std::ofstream *fp, FileType filetype);
133 uint32_t GetFullLength();
135 void Copy(DocEntry *doc);
137 bool IsItemDelimitor();
138 bool IsSequenceDelimitor();
141 // FIXME: In fact we should be more specific and use :
142 // friend DocEntry * Header::ReadNextElement(void);
148 /// \brief pointer to the underlying Dicom dictionary element
149 DictEntry *DicomDict;
151 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
152 /// in the header or helping the parser going on
153 uint32_t UsableLength;
155 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
156 /// will be updated only when FixFoundLength actually fixes a bug in the
157 /// header, not when it performs a trick to help the Parser going on.
160 /// \brief Even when reading explicit vr files, some elements happen to
161 /// be implicit. Flag them here since we can't use the entry->vr without
162 /// breaking the underlying dictionary.
165 /// Offset from the begining of file for direct user access
168 /// How many details are to be printed (value : 0,1,2)
171 /// \brief Generalized key of this DocEntry (for details on
172 /// the generalized key refer to \ref TagKey documentation).
175 } // end namespace gdcm
176 //-----------------------------------------------------------------------------