1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2004/11/30 16:24:31 $
7 Version: $Revision: 1.31 $
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"
33 //-----------------------------------------------------------------------------
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 DocEntry
42 virtual ~DocEntry() {};
44 /// Returns the Dicom Group number of the current Dicom Header Entry
45 uint16_t GetGroup() { return DicomDict->GetGroup(); };
47 /// Returns the Dicom Element number of the current Dicom Header Entry
48 uint16_t GetElement() { return DicomDict->GetElement();};
50 /// Returns the 'key' of the current Dicom Header Entry
51 void SetKey( TagKey const & key ) { Key = key; }
53 /// Returns the 'key' of the current Dicom Header Entry
54 std::string const & GetKey() const { return Key; }
56 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
57 /// Dictionnary of the current Dicom Header Entry
58 std::string const & GetName() const { return DicomDict->GetName(); };
60 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
61 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
62 /// Dictionnary, of the current Dicom Header Entry
63 std::string const & GetVR() const { return DicomDict->GetVR(); };
65 /// \brief Returns offset (since the beginning of the file, including
66 /// the File Preamble, if any) of the value of the current Dicom HeaderEntry
67 /// \warning offset of the *value*, not of the Dicom Header Entry
68 size_t GetOffset() { return Offset; };
70 /// \brief Returns the actual value length of the current Dicom Header Entry
71 /// \warning this value is not *always* the one stored in the Dicom Header
72 /// in case of well knowned bugs
73 uint32_t GetLength() { return UsableLength; };
75 /// \brief Returns the 'read length' of the current Dicom Header Entry
76 /// \warning this value is the one stored in the Dicom Header but not
77 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
78 /// the usable length is set to zero)
79 uint32_t GetReadLength() { return ReadLength; };
81 /// Sets the 'Value Representation' of the current Dicom Header Entry
82 void SetVR( TagName const & v) { DicomDict->SetVR(v); };
84 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
85 /// Dicom Header Entry
86 void SetLength(uint32_t l) { ReadLength = UsableLength = l; };
88 // The following 3 members, for internal use only !
90 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
91 /// Dicom Header Entry
92 void SetReadLength(uint32_t l) { ReadLength = l; };
94 /// \brief Sets only 'Usable Length' (*not* 'Read Length') of the current
95 /// Dicom Header Entry
96 void SetUsableLength(uint32_t l) { UsableLength = l; };
98 /// \brief Sets the offset of the Dicom Element
99 /// \warning use with caution !
100 /// @param of offset to be set
101 void SetOffset(size_t of) { Offset = of; };
103 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
104 void SetImplicitVR() { ImplicitVR = true; };
106 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
107 /// @return true if the current Dicom Element was checked as ImplicitVr
108 bool IsImplicitVR() { return ImplicitVR; };
110 /// \brief Tells us if the VR of the current Dicom Element is Unknown
111 /// @return true if the VR is unknown
112 bool IsVRUnknown() { return DicomDict->IsVRUnknown(); };
114 /// \brief Sets the DicEntry of the current Dicom Element
115 /// @param newEntry pointer to the DictEntry
116 void SetDictEntry(DictEntry *newEntry) { DicomDict = newEntry; };
118 /// \brief Gets the DicEntry of the current Dicom Element
119 /// @return The DicEntry of the current Dicom Element
120 DictEntry * GetDictEntry() { return DicomDict; };
122 /// \brief Sets the print level for the Dicom Header Elements
123 /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
124 void SetPrintLevel(int level) { PrintLevel = level; };
126 /// \brief Gets the print level for the Dicom Header Elements
127 int GetPrintLevel() { return PrintLevel; };
129 virtual void Print (std::ostream & os = std::cout);
130 virtual void WriteContent(std::ofstream *fp, FileType filetype);
132 uint32_t GetFullLength();
134 void Copy(DocEntry *doc);
136 bool IsItemDelimitor();
137 bool IsSequenceDelimitor();
140 // FIXME: In fact we should be more specific and use :
141 // friend DocEntry * Header::ReadNextElement(void);
147 /// \brief pointer to the underlying Dicom dictionary element
148 DictEntry *DicomDict;
150 /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug
151 /// in the header or helping the parser going on
152 uint32_t UsableLength;
154 /// \brief Length actually read on disk (before FixFoundLength). ReadLength
155 /// will be updated only when FixFoundLength actually fixes a bug in the
156 /// header, not when it performs a trick to help the Parser going on.
159 /// \brief Even when reading explicit vr files, some elements happen to
160 /// be implicit. Flag them here since we can't use the entry->vr without
161 /// breaking the underlying dictionary.
164 /// Offset from the begining of file for direct user access
167 /// How many details are to be printed (value : 0,1,2)
170 /// \brief Generalized key of this DocEntry (for details on
171 /// the generalized key refer to \ref TagKey documentation).
174 } // end namespace gdcm
175 //-----------------------------------------------------------------------------