1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/06 17:20:53 $
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 =========================================================================*/
18 #include "gdcmDocEntrySet.h"
20 #include "gdcmDebug.h"
21 #include "gdcmCommon.h"
22 #include "gdcmDictSet.h"
23 #include "gdcmGlobal.h"
24 #include "gdcmException.h"
25 #include "gdcmDocEntry.h"
26 #include "gdcmSeqEntry.h"
27 #include "gdcmValEntry.h"
28 #include "gdcmBinEntry.h"
35 //-----------------------------------------------------------------------------
38 * \brief Gets a Dicom Element inside a SQ Item Entry, by name
39 * @param name of the element to be found.
42 DocEntry* DocEntrySet::GetDocEntryByName( TagName const & name )
44 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
45 DictEntry *dictEntry = pubDict->GetDictEntryByName(name);
51 return GetDocEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
56 * \brief Get the value of a Dicom Element inside a SQ Item Entry, by name
57 * @param name : name of the searched element.
61 std::string DocEntrySet::GetEntryByName(TagName const & name)
63 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
64 DictEntry *dictEntry = pubDict->GetDictEntryByName(name);
71 return GetEntryByNumber(dictEntry->GetGroup(), dictEntry->GetElement());
75 * \brief Request a new virtual dict entry to the dict set
76 * @param group group number of the underlying DictEntry
77 * @param elem element number of the underlying DictEntry
78 * @param vr VR of the underlying DictEntry
79 * @param fourth owner group
80 * @param name english name
82 DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem,
84 TagName const & fourth,
85 TagName const & name )
87 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,fourth,name);
90 //-----------------------------------------------------------------------------
93 * \brief Build a new Val Entry from all the low level arguments.
94 * Check for existence of dictionary entry, and build
95 * a default one when absent.
96 * @param group group number of the new Entry
97 * @param elem element number of the new Entry
98 * @param vr VR of the new Entry
100 ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group,uint16_t elem,
103 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
106 ValEntry *newEntry = new ValEntry(dictEntry);
109 dbg.Verbose(1, "Document::NewValEntryByNumber",
110 "failed to allocate ValEntry");
118 * \brief Build a new Bin Entry from all the low level arguments.
119 * Check for existence of dictionary entry, and build
120 * a default one when absent.
121 * @param group group number of the new Entry
122 * @param elem element number of the new Entry
123 * @param vr VR of the new Entry
125 BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,uint16_t elem,
128 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
131 BinEntry *newEntry = new BinEntry(dictEntry);
134 dbg.Verbose(1, "Document::NewBinEntryByNumber",
135 "failed to allocate BinEntry");
142 * \brief Build a new Seq Entry from all the low level arguments.
143 * Check for existence of dictionary entry, and build
144 * a default one when absent.
145 * @param group group number of the new Entry
146 * @param elem element number of the new Entry
148 SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t group,uint16_t elem)
150 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, "SQ");
153 SeqEntry *newEntry = new SeqEntry( dictEntry );
156 dbg.Verbose(1, "Document::NewSeqEntryByNumber",
157 "failed to allocate SeqEntry");
164 * \brief Searches both the public and the shadow dictionary (when they
165 * exist) for the presence of the DictEntry with given name.
166 * The public dictionary has precedence on the shadow one.
167 * @param name Name of the searched DictEntry
168 * @return Corresponding DictEntry when it exists, NULL otherwise.
170 DictEntry *DocEntrySet::GetDictEntryByName(TagName const & name)
172 DictEntry *found = 0;
173 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
176 dbg.Verbose(0, "Document::GetDictEntry",
177 "we SHOULD have a default dictionary");
181 found = pubDict->GetDictEntryByName(name);
187 * \brief Searches both the public and the shadow dictionary (when they
188 * exist) for the presence of the DictEntry with given
189 * group and element. The public dictionary has precedence on the
191 * @param group group number of the searched DictEntry
192 * @param elem element number of the searched DictEntry
193 * @return Corresponding DictEntry when it exists, NULL otherwise.
195 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,uint16_t elem)
197 DictEntry *found = 0;
198 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
201 dbg.Verbose(0, "Document::GetDictEntry",
202 "we SHOULD have a default dictionary");
206 found = pubDict->GetDictEntryByNumber(group, elem);
211 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group, uint16_t elem,
214 DictEntry *dictEntry = GetDictEntryByNumber(group,elem);
215 DictEntry *goodEntry = dictEntry;
216 std::string goodVR=vr;
222 if (goodEntry->GetVR() != goodVR && goodVR!=GDCM_UNKNOWN)
225 // Create a new virtual DictEntry if necessary
229 goodEntry = NewVirtualDictEntry(group, elem, goodVR,"FIXME",dictEntry->GetName());
231 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
237 //-----------------------------------------------------------------------------
240 } // end namespace gdcm
242 //-----------------------------------------------------------------------------