1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/24 14:14:11 $
7 Version: $Revision: 1.44 $
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 "gdcmDocEntry.h"
25 #include "gdcmSeqEntry.h"
26 #include "gdcmValEntry.h"
27 #include "gdcmBinEntry.h"
32 //-----------------------------------------------------------------------------
37 * \brief Request a new virtual dict entry to the dict set
38 * @param group group number of the underlying DictEntry
39 * @param elem element number of the underlying DictEntry
40 * @param vr VR (Value Representation) of the underlying DictEntry
41 * @param vm VM (Value Multiplicity) of the underlying DictEntry
42 * @param name english name
44 DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem,
47 TagName const & name )
49 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
52 //-----------------------------------------------------------------------------
55 * \brief Build a new Val Entry from all the low level arguments.
56 * Check for existence of dictionary entry, and build
57 * a default one when absent.
58 * @param group group number of the new Entry
59 * @param elem element number of the new Entry
60 * @param vr VR of the new Entry
62 ValEntry *DocEntrySet::NewValEntry(uint16_t group,uint16_t elem,
65 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
66 gdcmAssertMacro(dictEntry);
68 ValEntry *newEntry = new ValEntry(dictEntry);
71 gdcmVerboseMacro( "Failed to allocate ValEntry");
79 * \brief Build a new Bin Entry from all the low level arguments.
80 * Check for existence of dictionary entry, and build
81 * a default one when absent.
82 * @param group group number of the new Entry
83 * @param elem element number of the new Entry
84 * @param vr VR of the new Entry
86 BinEntry *DocEntrySet::NewBinEntry(uint16_t group,uint16_t elem,
89 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
90 gdcmAssertMacro(dictEntry);
92 BinEntry *newEntry = new BinEntry(dictEntry);
95 gdcmVerboseMacro( "Failed to allocate BinEntry");
102 * \brief Build a new Seq Entry from all the low level arguments.
103 * Check for existence of dictionary entry, and build
104 * a default one when absent.
105 * @param group group number of the new Entry
106 * @param elem element number of the new Entry
108 SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group,uint16_t elem)
110 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
111 gdcmAssertMacro(dictEntry);
113 SeqEntry *newEntry = new SeqEntry( dictEntry );
116 gdcmVerboseMacro( "Failed to allocate SeqEntry");
123 * \brief Searches [both] the public [and the shadow dictionary (when they
124 * exist)] for the presence of the DictEntry with given
125 * group and element. The public dictionary has precedence on the
127 * @param group group number of the searched DictEntry
128 * @param elem element number of the searched DictEntry
129 * @return Corresponding DictEntry when it exists, NULL otherwise.
131 DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem)
133 DictEntry *found = 0;
134 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
137 gdcmVerboseMacro( "We SHOULD have a default dictionary");
141 found = pubDict->GetEntry(group, elem);
148 * \brief Searches both the public and the shadow dictionary (when they
149 * exist) for the presence of the DictEntry with given
150 * group and element, and create a new virtual DictEntry if necessary
151 * @param group group number of the searched DictEntry
152 * @param elem element number of the searched DictEntry
153 * @param vr Value Representation to use, if necessary
154 * @return Corresponding DictEntry when it exists, NULL otherwise.
156 DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
159 DictEntry *dictEntry = GetDictEntry(group,elem);
160 DictEntry *goodEntry = dictEntry;
161 std::string goodVR = vr;
163 if (elem == 0x0000) goodVR="UL";
167 if ( goodVR != goodEntry->GetVR()
168 && goodVR != GDCM_UNKNOWN )
174 // Create a new virtual DictEntry if necessary
179 goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME",
180 dictEntry->GetName() );
184 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
192 //-----------------------------------------------------------------------------
195 } // end namespace gdcm
197 //-----------------------------------------------------------------------------