]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
* src/*.cxx *.h Reference to License.htm fixed to License.html.
[gdcm.git] / src / gdcmDictEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/09/27 08:39:06 $
7   Version:   $Revision: 1.23 $
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
22 #include <stdio.h>    // FIXME For sprintf
23
24 //-----------------------------------------------------------------------------
25 // Constructor / Destructor
26 /**
27  * \brief   Constructor
28  * @param   InGroup    DICOM-Group Number
29  * @param   InElement  DICOM-Element Number
30  * @param   InVr       Value Representatiion
31  * @param   InFourth  // DO NOT use any longer; 
32  *                       NOT part of the Dicom Standard
33  * @param   InName    description of the element
34 */
35
36 gdcmDictEntry::gdcmDictEntry(uint16_t InGroup, uint16_t InElement,
37                              std::string  InVr, std::string InFourth,
38                              std::string  InName)
39 {
40    group   = InGroup;
41    element = InElement;
42    vr      = InVr;
43    fourth  = InFourth;
44    name    = InName;
45    key     = TranslateToKey(group, element); /// \todo Frog MEMORY LEAK.
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    char trash[10];
63    gdcmTagKey key;
64    // CLEANME: better call the iostream<< with the hex manipulator on.
65    // This requires some reading of the stdlibC++ sources to make the
66    // proper call (or copy).
67    sprintf(trash, "%04x|%04x", group , element);
68    key = trash;  // Convertion through assignement
69    return key;
70 }
71
72 /**
73  * \brief       If-and only if-the V(alue) R(epresentation)
74  * \            is unset then overwrite it.
75  * @param NewVr New V(alue) R(epresentation) to be set.
76  */
77 void gdcmDictEntry::SetVR(std::string NewVr) 
78 {
79    if ( IsVRUnknown() )
80       vr = NewVr;
81    else 
82    {
83       dbg.Error(true, "gdcmDictEntry::SetVR",
84                        "Overwriting vr might compromise a dictionary");
85    }
86 }
87
88 //-----------------------------------------------------------------------------
89 // Protected
90
91 //-----------------------------------------------------------------------------
92 // Private
93
94 //-----------------------------------------------------------------------------
95