1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.h,v $
6 Date: $Date: 2005/01/07 16:45:51 $
7 Version: $Revision: 1.37 $
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
23 #include "gdcmDictEntry.h"
35 //-----------------------------------------------------------------------------
37 * \brief The dicom header of a Dicom file contains a set of such entries
38 * (when successfuly parsed against a given Dicom dictionary)
40 class GDCM_EXPORT DocEntry : public Base
44 virtual ~DocEntry() {};
46 /// Returns the Dicom Group number of the current Dicom Header Entry
47 uint16_t GetGroup() { return DicomDict->GetGroup(); };
49 /// Returns the Dicom Element number of the current Dicom Header Entry
50 uint16_t GetElement() { return DicomDict->GetElement();};
52 /// Returns the 'key' of the current Dicom Header Entry
53 void SetKey( TagKey const &key ) { Key = key; }
55 /// Returns the 'key' of the current Dicom Header Entry
56 std::string const &GetKey() const { return Key; }
58 /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
59 /// Dictionnary of the current Dicom Header Entry
60 std::string const &GetName() const { return DicomDict->GetName(); };
62 /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
63 /// "SL" : Signed Long), found in the Dicom Header or in the Dicom
64 /// Dictionnary, of the current Dicom Header Entry
65 std::string const &GetVR() const { return DicomDict->GetVR(); };
67 /// \brief Returns the 'Value Multiplicity' (e.g. "1", "1-n", "6"),
68 /// found in the Dicom Header or in the Dicom Dictionnary
69 /// of the current Dicom Header Entry
70 std::string const &GetVM() const { return DicomDict->GetVM(); };
72 /// Sets the 'Value Representation' of the current Dicom Header Entry
73 void SetVR( TagName const &v) { DicomDict->SetVR(v); };
75 /// Sets the 'Value Multiplicity' of the current Dicom Header Entry
76 void SetVM( TagName const &v) { DicomDict->SetVM(v); };
78 /// \brief Returns offset (since the beginning of the file, including
79 /// the File Preamble, if any) of the value of the current Dicom HeaderEntry
80 /// \warning offset of the *value*, not of the Dicom Header Entry
81 size_t GetOffset() { return Offset; };
84 /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
85 /// Dicom Header Entry
86 void SetReadLength(uint32_t l) { ReadLength = l; };
88 /// \brief Returns the 'read length' of the current Dicom Header Entry
89 /// \warning this value is the one stored in the Dicom Header but not
90 /// mandatoryly the one thats's used (in case on SQ, or delimiters,
91 /// the usable length is set to zero)
92 uint32_t GetReadLength() { return ReadLength; };
94 /// \brief Sets both 'Read Length' and 'Usable Length' of the current
95 /// Dicom Header Entry
96 void SetLength(uint32_t l) { Length = l; };
98 /// \brief Returns the actual value length of the current Dicom Header Entry
99 /// \warning this value is not *always* the one stored in the Dicom Header
100 /// in case of well knowned bugs
101 uint32_t GetLength() { return Length; };
104 // The following 3 members, for internal use only !
106 /// \brief Sets the offset of the Dicom Element
107 /// \warning use with caution !
108 /// @param of offset to be set
109 void SetOffset(size_t of) { Offset = of; };
111 /// Sets to TRUE the ImplicitVr flag of the current Dicom Element
112 void SetImplicitVR() { ImplicitVR = true; };
114 /// \brief Tells us if the current Dicom Element was checked as ImplicitVr
115 /// @return true if the current Dicom Element was checked as ImplicitVr
116 bool IsImplicitVR() { return ImplicitVR; };
118 /// \brief Tells us if the VR of the current Dicom Element is Unknown
119 /// @return true if the VR is unknown
120 bool IsVRUnknown() { return DicomDict->IsVRUnknown(); };
122 /// \brief Tells us if the VM of the current Dicom Element is Unknown
123 /// @return true if the VM is unknown
124 bool IsVMUnknown() { return DicomDict->IsVMUnknown(); };
126 /// \brief Sets the DicEntry of the current Dicom Element
127 /// @param newEntry pointer to the DictEntry
128 void SetDictEntry(DictEntry *newEntry) { DicomDict = newEntry; };
130 /// \brief Gets the DicEntry of the current Dicom Element
131 /// @return The DicEntry of the current Dicom Element
132 DictEntry * GetDictEntry() { return DicomDict; };
134 virtual void WriteContent(std::ofstream *fp, FileType filetype);
136 uint32_t GetFullLength();
138 void Copy(DocEntry *doc);
140 bool IsItemDelimitor();
141 bool IsSequenceDelimitor();
143 virtual void Print (std::ostream &os = std::cout);
148 /// \brief pointer to the underlying Dicom dictionary element
149 DictEntry *DicomDict;
151 /// \brief Correspond to the real length of the datas
152 /// This length might always be even
155 /// \brief Length to read in the file to obtain datas.
158 /// \brief Even when reading explicit vr files, some elements happen to
159 /// be implicit. Flag them here since we can't use the entry->vr without
160 /// breaking the underlying dictionary.
163 /// Offset from the begining of file for direct user access
166 /// \brief Generalized key of this DocEntry (for details on
167 /// the generalized key refer to \ref TagKey documentation).
171 // FIXME: In fact we should be more specific and use :
172 // friend DocEntry * Header::ReadNextElement(void);
175 } // end namespace gdcm
176 //-----------------------------------------------------------------------------