]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
:ENH: carefully one at a time modify gdcm src. For now rewrite gdcmDictEntry. Modify...
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/10/09 02:57:11 $
7   Version:   $Revision: 1.24 $
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
24 //-----------------------------------------------------------------------------
25 // Constructor / Destructor
26 /**
27  * \brief   Constructor
28  * @param   group      DICOM-Group Number
29  * @param   element    DICOM-Element Number
30  * @param   vr         Value Representatiion
31  * @param   fourth    // DO NOT use any longer; 
32  *                       NOT part of the Dicom Standard
33  * @param   name      description of the element
34 */
35
36 gdcmDictEntry::gdcmDictEntry(uint16_t group, uint16_t element,
37                              std::string vr, std::string fourth,
38                              std::string name)
39 {
40    Group   = group;
41    Element = element;
42    VR      = vr;
43    Fourth  = fourth;
44    Name    = name;
45    Key     = TranslateToKey(group, element);
46 }
47
48 //-----------------------------------------------------------------------------
49 // Print
50
51 //-----------------------------------------------------------------------------
52 // Public
53 /**
54  * \brief   concatenates 2 uint16_t (supposed to be a Dicom group number 
55  *                                              and a Dicom element number)
56  * @param  group the Dicom group number used to build the tag
57  * @param  element the Dicom element number used to build the tag
58  * @return the built tag
59  */
60 gdcmTagKey gdcmDictEntry::TranslateToKey(uint16_t group, uint16_t element)
61 {
62    gdcmTagKey key = Format("%04x|%04x", group , element);
63
64    return key;
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 gdcmDictEntry::SetVR(std::string const & vr) 
74 {
75    if ( IsVRUnknown() )
76    {
77       VR = vr;
78    }
79    else 
80    {
81       dbg.Error(true, "gdcmDictEntry::SetVR",
82                        "Overwriting VR might compromise a dictionary");
83    }
84 }
85
86 //-----------------------------------------------------------------------------
87 // Protected
88
89 //-----------------------------------------------------------------------------
90 // Private
91
92 //-----------------------------------------------------------------------------