1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/06 15:36:48 $
7 Version: $Revision: 1.30 $
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 element 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 underlying DictEntry
97 * @param elem element number of the underlying DictEntry
99 ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group,uint16_t elem,
102 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
105 ValEntry *newEntry = new ValEntry(dictEntry);
108 dbg.Verbose(1, "Document::NewValEntryByNumber",
109 "failed to allocate ValEntry");
117 * \brief Build a new Bin Entry from all the low level arguments.
118 * Check for existence of dictionary entry, and build
119 * a default one when absent.
120 * @param group group number of the underlying DictEntry
121 * @param elem element number of the underlying DictEntry
123 BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,uint16_t elem,
126 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
129 BinEntry *newEntry = new BinEntry(dictEntry);
132 dbg.Verbose(1, "Document::NewBinEntryByNumber",
133 "failed to allocate BinEntry");
140 * \brief Build a new Seq Entry from all the low level arguments.
141 * Check for existence of dictionary entry, and build
142 * a default one when absent.
143 * @param Group group number of the underlying DictEntry
144 * @param Elem element number of the underlying DictEntry
146 SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t group,uint16_t elem)
148 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, "SQ");
151 SeqEntry *newEntry = new SeqEntry( dictEntry );
154 dbg.Verbose(1, "Document::NewSeqEntryByNumber",
155 "failed to allocate SeqEntry");
162 * Creates a new DocEntry (without any 'value' ...)
163 * @param group group number of the underlying DictEntry
164 * @param elem elem number of the underlying DictEntry
165 * @param vr V(alue) R(epresentation) of the Entry -if private Entry-
167 DocEntry* DocEntrySet::NewDocEntryByNumber(uint16_t group, uint16_t elem,
170 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
173 // Create the DocEntry
174 DocEntry *newEntry = new DocEntry(dictEntry);
177 dbg.Verbose(1, "SQItem::NewDocEntryByNumber",
178 "failed to allocate DocEntry");
185 * \brief Searches both the public and the shadow dictionary (when they
186 * exist) for the presence of the DictEntry with given name.
187 * The public dictionary has precedence on the shadow one.
188 * @param name Name of the searched DictEntry
189 * @return Corresponding DictEntry when it exists, NULL otherwise.
191 DictEntry *DocEntrySet::GetDictEntryByName(TagName const & name)
193 DictEntry *found = 0;
194 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
197 dbg.Verbose(0, "Document::GetDictEntry",
198 "we SHOULD have a default dictionary");
202 found = pubDict->GetDictEntryByName(name);
208 * \brief Searches both the public and the shadow dictionary (when they
209 * exist) for the presence of the DictEntry with given
210 * group and element. The public dictionary has precedence on the
212 * @param group group number of the searched DictEntry
213 * @param element element number of the searched DictEntry
214 * @return Corresponding DictEntry when it exists, NULL otherwise.
216 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,uint16_t elem)
218 DictEntry *found = 0;
219 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
222 dbg.Verbose(0, "Document::GetDictEntry",
223 "we SHOULD have a default dictionary");
227 found = pubDict->GetDictEntryByNumber(group, elem);
232 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group, uint16_t elem,
235 DictEntry *dictEntry = GetDictEntryByNumber(group,elem);
236 DictEntry *goodEntry = dictEntry;
237 std::string goodVR=vr;
243 if (goodEntry->GetVR() != goodVR && goodVR!=GDCM_UNKNOWN)
246 // Create a new virtual DictEntry if necessary
250 goodEntry = NewVirtualDictEntry(group, elem, goodVR,"FIXME",dictEntry->GetName());
252 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
258 //-----------------------------------------------------------------------------
261 } // end namespace gdcm
263 //-----------------------------------------------------------------------------