1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/07 12:29:17 $
7 Version: $Revision: 1.34 $
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 //-----------------------------------------------------------------------------
40 * \brief Request a new virtual dict entry to the dict set
41 * @param group group number of the underlying DictEntry
42 * @param elem element number of the underlying DictEntry
43 * @param vr VR (Value Representation) of the underlying DictEntry
44 * @param vm VM (Value Multiplicity) of the underlying DictEntry
45 * @param name english name
47 DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem,
50 TagName const & name )
52 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
55 //-----------------------------------------------------------------------------
58 * \brief Build a new Val Entry from all the low level arguments.
59 * Check for existence of dictionary entry, and build
60 * a default one when absent.
61 * @param group group number of the new Entry
62 * @param elem element number of the new Entry
63 * @param vr VR of the new Entry
65 ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group,uint16_t elem,
68 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
71 ValEntry *newEntry = new ValEntry(dictEntry);
74 dbg.Verbose(1, "Document::NewValEntryByNumber",
75 "failed to allocate ValEntry");
83 * \brief Build a new Bin Entry from all the low level arguments.
84 * Check for existence of dictionary entry, and build
85 * a default one when absent.
86 * @param group group number of the new Entry
87 * @param elem element number of the new Entry
88 * @param vr VR of the new Entry
90 BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,uint16_t elem,
93 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
96 BinEntry *newEntry = new BinEntry(dictEntry);
99 dbg.Verbose(1, "Document::NewBinEntryByNumber",
100 "failed to allocate BinEntry");
107 * \brief Build a new Seq Entry from all the low level arguments.
108 * Check for existence of dictionary entry, and build
109 * a default one when absent.
110 * @param group group number of the new Entry
111 * @param elem element number of the new Entry
113 SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t group,uint16_t elem)
115 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, "SQ");
118 SeqEntry *newEntry = new SeqEntry( dictEntry );
121 dbg.Verbose(1, "Document::NewSeqEntryByNumber",
122 "failed to allocate SeqEntry");
129 * \brief Searches both the public and the shadow dictionary (when they
130 * exist) for the presence of the DictEntry with given
131 * group and element. The public dictionary has precedence on the
133 * @param group group number of the searched DictEntry
134 * @param elem element number of the searched DictEntry
135 * @return Corresponding DictEntry when it exists, NULL otherwise.
137 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,uint16_t elem)
139 DictEntry *found = 0;
140 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
143 dbg.Verbose(0, "Document::GetDictEntry",
144 "we SHOULD have a default dictionary");
148 found = pubDict->GetDictEntryByNumber(group, elem);
153 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group, uint16_t elem,
156 DictEntry *dictEntry = GetDictEntryByNumber(group,elem);
157 DictEntry *goodEntry = dictEntry;
158 std::string goodVR=vr;
164 if (goodEntry->GetVR() != goodVR && goodVR!=GDCM_UNKNOWN)
167 // Create a new virtual DictEntry if necessary
171 goodEntry = NewVirtualDictEntry(group, elem, goodVR,"FIXME",dictEntry->GetName());
173 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
179 //-----------------------------------------------------------------------------
182 } // end namespace gdcm
184 //-----------------------------------------------------------------------------