1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2004/11/16 10:25:53 $
7 Version: $Revision: 1.26 $
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 "gdcmGlobal.h"
23 #include "gdcmException.h"
24 #include "gdcmDocEntry.h"
25 #include "gdcmSeqEntry.h"
26 #include "gdcmValEntry.h"
27 #include "gdcmBinEntry.h"
32 //-----------------------------------------------------------------------------
36 * \brief Build a new Val Entry from all the low level arguments.
37 * Check for existence of dictionary entry, and build
38 * a default one when absent.
39 * @param group group number of the underlying DictEntry
40 * @param elem element number of the underlying DictEntry
42 ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group,
45 // Find out if the tag we encountered is in the dictionaries:
46 DictEntry *dictEntry = GetDictEntryByNumber(group, elem);
49 dictEntry = NewVirtualDictEntry(group, elem);
52 ValEntry *newEntry = new ValEntry(dictEntry);
55 dbg.Verbose(1, "Document::NewValEntryByNumber",
56 "failed to allocate ValEntry");
64 * \brief Build a new Bin Entry from all the low level arguments.
65 * Check for existence of dictionary entry, and build
66 * a default one when absent.
67 * @param group group number of the underlying DictEntry
68 * @param elem element number of the underlying DictEntry
70 BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,
73 // Find out if the tag we encountered is in the dictionaries:
74 DictEntry *dictEntry = GetDictEntryByNumber(group, elem);
77 dictEntry = NewVirtualDictEntry(group, elem);
80 BinEntry *newEntry = new BinEntry(dictEntry);
83 dbg.Verbose(1, "Document::NewBinEntryByNumber",
84 "failed to allocate BinEntry");
91 * \brief Build a new Seq Entry from all the low level arguments.
92 * Check for existence of dictionary entry, and build
93 * a default one when absent.
94 * @param Group group number of the underlying DictEntry
95 * @param Elem element number of the underlying DictEntry
97 SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t Group,
100 // Find out if the tag we encountered is in the dictionaries:
101 DictEntry* DictEntry = GetDictEntryByNumber( Group, Elem );
104 DictEntry = NewVirtualDictEntry(Group, Elem);
107 SeqEntry *NewEntry = new SeqEntry( DictEntry );
110 dbg.Verbose(1, "Document::NewSeqEntryByNumber",
111 "failed to allocate SeqEntry");
117 //-----------------------------------------------------------------------------
121 * \brief Gets a Dicom Element inside a SQ Item Entry, by name
122 * @param name of the element to be found.
125 DocEntry* DocEntrySet::GetDocEntryByName( TagName const & name )
127 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
128 DictEntry *dictEntry = pubDict->GetDictEntryByName(name);
134 return GetDocEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
139 * \brief Get the value of a Dicom Element inside a SQ Item Entry, by name
140 * @param name : name of the searched element.
144 std::string DocEntrySet::GetEntryByName(TagName const & name)
146 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
147 DictEntry *dictEntry = pubDict->GetDictEntryByName(name);
154 return GetEntryByNumber(dictEntry->GetGroup(), dictEntry->GetElement());
159 * \brief Request a new virtual dict entry to the dict set
160 * @param group group number of the underlying DictEntry
161 * @param element element number of the underlying DictEntry
162 * @param vr VR of the underlying DictEntry
163 * @param fourth owner group
164 * @param name english name
166 DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,
169 TagName const & fourth,
170 TagName const & name )
172 return Global::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name);
176 * Creates a new DocEntry (without any 'value' ...)
177 * @param group group number of the underlying DictEntry
178 * @param elem elem number of the underlying DictEntry
180 DocEntry* DocEntrySet::NewDocEntryByNumber(uint16_t group,
183 // Find out if the tag we encountered is in the dictionaries:
184 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
185 DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem);
188 dictEntry = NewVirtualDictEntry(group, elem);
191 DocEntry *newEntry = new DocEntry(dictEntry);
194 dbg.Verbose(1, "SQItem::NewDocEntryByNumber",
195 "failed to allocate DocEntry");
203 * Creates a new DocEntry (without any 'value' ...)
204 * @param group group number of the underlying DictEntry
205 * @param elem elem number of the underlying DictEntry
206 * @param vr V(alue) R(epresentation) of the Entry -if private Entry-
208 DocEntry* DocEntrySet::NewDocEntryByNumber(uint16_t group, uint16_t elem,
211 // Find out if the tag we encountered is in the dictionaries:
212 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
213 DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem);
216 dictEntry = NewVirtualDictEntry(group, elem, vr);
219 DocEntry *newEntry = new DocEntry(dictEntry);
222 dbg.Verbose(1, "SQItem::NewDocEntryByNumber",
223 "failed to allocate DocEntry");
229 * Probabely move, as is, to DocEntrySet, as a non virtual method
230 * and remove Document::NewDocEntryByName
232 DocEntry *DocEntrySet::NewDocEntryByName(TagName const & name)
234 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
235 DictEntry *newTag = pubDict->GetDictEntryByName(name);
238 newTag = NewVirtualDictEntry(0xffff, 0xffff, "LO", "unkn", name);
241 DocEntry* newEntry = new DocEntry(newTag);
244 dbg.Verbose(1, "SQItem::ObtainDocEntryByName",
245 "failed to allocate DocEntry");
254 * \brief Searches both the public and the shadow dictionary (when they
255 * exist) for the presence of the DictEntry with given name.
256 * The public dictionary has precedence on the shadow one.
257 * @param name Name of the searched DictEntry
258 * @return Corresponding DictEntry when it exists, NULL otherwise.
260 DictEntry *DocEntrySet::GetDictEntryByName(TagName const & name)
262 DictEntry *found = 0;
263 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
266 dbg.Verbose(0, "Document::GetDictEntry",
267 "we SHOULD have a default dictionary");
271 found = pubDict->GetDictEntryByName(name);
277 * \brief Searches both the public and the shadow dictionary (when they
278 * exist) for the presence of the DictEntry with given
279 * group and element. The public dictionary has precedence on the
281 * @param group group number of the searched DictEntry
282 * @param element element number of the searched DictEntry
283 * @return Corresponding DictEntry when it exists, NULL otherwise.
285 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,
288 DictEntry *found = 0;
289 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
292 dbg.Verbose(0, "Document::GetDictEntry",
293 "we SHOULD have a default dictionary");
297 found = pubDict->GetDictEntryByNumber(group, element);
303 //-----------------------------------------------------------------------------
306 } // end namespace gdcm
308 //-----------------------------------------------------------------------------