1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.cxx,v $
6 Date: $Date: 2005/01/07 22:03:30 $
7 Version: $Revision: 1.37 $
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 gdcmVerboseMacro( "Failed to allocate ValEntry");
82 * \brief Build a new Bin Entry from all the low level arguments.
83 * Check for existence of dictionary entry, and build
84 * a default one when absent.
85 * @param group group number of the new Entry
86 * @param elem element number of the new Entry
87 * @param vr VR of the new Entry
89 BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,uint16_t elem,
92 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, vr);
95 BinEntry *newEntry = new BinEntry(dictEntry);
98 gdcmVerboseMacro( "Failed to allocate BinEntry");
105 * \brief Build a new Seq Entry from all the low level arguments.
106 * Check for existence of dictionary entry, and build
107 * a default one when absent.
108 * @param group group number of the new Entry
109 * @param elem element number of the new Entry
111 SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t group,uint16_t elem)
113 DictEntry *dictEntry = GetDictEntryByNumber(group, elem, "SQ");
116 SeqEntry *newEntry = new SeqEntry( dictEntry );
119 gdcmVerboseMacro( "Failed to allocate SeqEntry");
126 * \brief Searches both the public and the shadow dictionary (when they
127 * exist) for the presence of the DictEntry with given
128 * group and element. The public dictionary has precedence on the
130 * @param group group number of the searched DictEntry
131 * @param elem element number of the searched DictEntry
132 * @return Corresponding DictEntry when it exists, NULL otherwise.
134 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,uint16_t elem)
136 DictEntry *found = 0;
137 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
140 gdcmVerboseMacro( "We SHOULD have a default dictionary");
144 found = pubDict->GetDictEntryByNumber(group, elem);
149 DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group, uint16_t elem,
152 DictEntry *dictEntry = GetDictEntryByNumber(group,elem);
153 DictEntry *goodEntry = dictEntry;
154 std::string goodVR=vr;
160 if (goodEntry->GetVR() != goodVR && goodVR!=GDCM_UNKNOWN)
163 // Create a new virtual DictEntry if necessary
167 goodEntry = NewVirtualDictEntry(group, elem, goodVR,"FIXME",dictEntry->GetName());
169 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
175 //-----------------------------------------------------------------------------
178 } // end namespace gdcm
180 //-----------------------------------------------------------------------------