]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
ENH: update gdcmDebug after Benoit comments
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/07 19:20:38 $
7   Version:   $Revision: 1.36 $
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 Representation
33  * @param   vm         Value Mutlplicity 
34  * @param   name      description of the element
35 */
36
37 DictEntry::DictEntry(uint16_t group, uint16_t element,
38                      TagName const &vr, 
39                      TagName const &vm,
40                      TagName const &name)
41 {
42    Group   = group;
43    Element = element;
44    VR      = vr;
45    VM      = vm;
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    return Util::Format("%04x|%04x", group, element);
65 }
66
67 //-----------------------------------------------------------------------------
68 /**
69  * \brief       If-and only if-the V(alue) R(epresentation)
70  * \            is unset then overwrite it.
71  * @param vr    New V(alue) R(epresentation) to be set.
72  */
73 void DictEntry::SetVR(TagName const &vr) 
74 {
75    if ( IsVRUnknown() )
76    {
77       VR = vr;
78    }
79    else 
80    {
81       gdcmErrorMacro("DictEntry::SetVR"
82                 "Overwriting VR might compromise a dictionary");
83    }
84 }
85
86 //-----------------------------------------------------------------------------
87 /**
88  * \brief       If-and only if-the V(alue) M(ultiplicity)
89  * \            is unset then overwrite it.
90  * @param vr    New V(alue) M(ultiplicity) to be set.
91  */
92 void DictEntry::SetVM(TagName const &vm) 
93 {
94    if ( IsVMUnknown() )
95    {
96       VM = vm;
97    }
98    else 
99    {
100       gdcmErrorMacro( "DictEntry::SetVM"
101                  "Overwriting VM might compromise a dictionary");
102    }
103 }
104 //-----------------------------------------------------------------------------
105 // Protected
106
107 //-----------------------------------------------------------------------------
108 // Private
109
110 //-----------------------------------------------------------------------------
111 } // end namespace gdcm
112