]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
ENH: hum I guess this one slept through my cleaning
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/10/18 02:35:35 $
7   Version:   $Revision: 1.28 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDictEntry.h"
20 #include "gdcmDebug.h"
21 #include "gdcmUtil.h"
22
23 namespace gdcm 
24 {
25
26 //-----------------------------------------------------------------------------
27 // Constructor / Destructor
28 /**
29  * \brief   Constructor
30  * @param   group      DICOM-Group Number
31  * @param   element    DICOM-Element Number
32  * @param   vr         Value Representatiion
33  * @param   fourth    // DO NOT use any longer; 
34  *                       NOT part of the Dicom Standard
35  * @param   name      description of the element
36 */
37
38 DictEntry::DictEntry(uint16_t group, uint16_t element,
39                      TagName const & vr, TagName const & fourth,
40                      TagName const & name)
41 {
42    Group   = group;
43    Element = element;
44    VR      = vr;
45    Fourth  = fourth;
46    Name    = name;
47    Key     = TranslateToKey(group, element);
48 }
49
50 //-----------------------------------------------------------------------------
51 // Print
52
53 //-----------------------------------------------------------------------------
54 // Public
55 /**
56  * \brief   concatenates 2 uint16_t (supposed to be a Dicom group number 
57  *                                              and a Dicom element number)
58  * @param  group the Dicom group number used to build the tag
59  * @param  element the Dicom element number used to build the tag
60  * @return the built tag
61  */
62 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t element)
63 {
64    TagKey key = Util::Format("%04x|%04x", group , element);
65
66    return key;
67 }
68
69 //-----------------------------------------------------------------------------
70 /**
71  * \brief       If-and only if-the V(alue) R(epresentation)
72  * \            is unset then overwrite it.
73  * @param vr    New V(alue) R(epresentation) to be set.
74  */
75 void DictEntry::SetVR(TagName const & vr) 
76 {
77    if ( IsVRUnknown() )
78    {
79       VR = vr;
80    }
81    else 
82    {
83       dbg.Error(true, "DictEntry::SetVR",
84                        "Overwriting VR might compromise a dictionary");
85    }
86 }
87
88 //-----------------------------------------------------------------------------
89 // Protected
90
91 //-----------------------------------------------------------------------------
92 // Private
93
94 //-----------------------------------------------------------------------------
95 } // end namespace gdcm
96