1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/08 15:03:59 $
7 Version: $Revision: 1.41 $
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"
33 //-----------------------------------------------------------------------------
38 * \brief Request a new virtual dict entry to the dict set
39 * @param group group number of the underlying DictEntry
40 * @param elem element number of the underlying DictEntry
41 * @param vr VR (Value Representation) of the underlying DictEntry
42 * @param vm VM (Value Multiplicity) of the underlying DictEntry
43 * @param name english name
45 DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem,
48 TagName const & name )
50 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
53 //-----------------------------------------------------------------------------
56 * \brief Build a new Val Entry from all the low level arguments.
57 * Check for existence of dictionary entry, and build
58 * a default one when absent.
59 * @param group group number of the new Entry
60 * @param elem element number of the new Entry
61 * @param vr VR of the new Entry
63 ValEntry *DocEntrySet::NewValEntry(uint16_t group,uint16_t elem,
66 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
67 gdcmAssertMacro(dictEntry);
69 ValEntry *newEntry = new ValEntry(dictEntry);
72 gdcmVerboseMacro( "Failed to allocate ValEntry");
80 * \brief Build a new Bin Entry from all the low level arguments.
81 * Check for existence of dictionary entry, and build
82 * a default one when absent.
83 * @param group group number of the new Entry
84 * @param elem element number of the new Entry
85 * @param vr VR of the new Entry
87 BinEntry *DocEntrySet::NewBinEntry(uint16_t group,uint16_t elem,
90 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
91 gdcmAssertMacro(dictEntry);
93 BinEntry *newEntry = new BinEntry(dictEntry);
96 gdcmVerboseMacro( "Failed to allocate BinEntry");
103 * \brief Build a new Seq Entry from all the low level arguments.
104 * Check for existence of dictionary entry, and build
105 * a default one when absent.
106 * @param group group number of the new Entry
107 * @param elem element number of the new Entry
109 SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group,uint16_t elem)
111 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
112 gdcmAssertMacro(dictEntry);
114 SeqEntry *newEntry = new SeqEntry( dictEntry );
117 gdcmVerboseMacro( "Failed to allocate SeqEntry");
124 * \brief Searches both the public and the shadow dictionary (when they
125 * exist) for the presence of the DictEntry with given
126 * group and element. The public dictionary has precedence on the
128 * @param group group number of the searched DictEntry
129 * @param elem element number of the searched DictEntry
130 * @return Corresponding DictEntry when it exists, NULL otherwise.
132 DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem)
134 DictEntry *found = 0;
135 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
138 gdcmVerboseMacro( "We SHOULD have a default dictionary");
142 found = pubDict->GetDictEntry(group, elem);
147 DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
150 DictEntry *dictEntry = GetDictEntry(group,elem);
151 DictEntry *goodEntry = dictEntry;
152 std::string goodVR = vr;
154 if (elem == 0x0000) goodVR="UL";
158 if ( goodVR != goodEntry->GetVR()
159 && goodVR != GDCM_UNKNOWN )
165 // Create a new virtual DictEntry if necessary
170 goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME",
171 dictEntry->GetName() );
175 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
182 //-----------------------------------------------------------------------------
185 } // end namespace gdcm
187 //-----------------------------------------------------------------------------