]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
* In order to fix memory leaks:
[gdcm.git] / src / gdcmDictEntry.cxx
1 // gdcmDictEntry.cxx
2 //-----------------------------------------------------------------------------
3 #include "gdcmDictEntry.h"
4 #include "gdcmDebug.h"
5
6 #include <stdio.h>    // FIXME For sprintf
7
8 //-----------------------------------------------------------------------------
9 // Constructor / Destructor
10 /**
11  * \brief   Constructor
12  * @param   InGroup    DICOM-Group Number
13  * @param   InElement  DICOM-Element Number
14  * @param   InVr       Value Representatiion
15  * @param   InFourth  // DO NOT use any longer; 
16  *                       NOT part of the Dicom Standard
17  * @param   InName    description of the element
18 */
19
20 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
21                              std::string  InVr, std::string InFourth,
22                              std::string  InName)
23 {
24    group   = InGroup;
25    element = InElement;
26    vr      = InVr;
27    fourth  = InFourth;
28    name    = InName;
29    key     = TranslateToKey(group, element); /// \todo Frog MEMORY LEAK.
30 }
31
32 //-----------------------------------------------------------------------------
33 // Print
34
35 //-----------------------------------------------------------------------------
36 // Public
37 /**
38  * \brief   concatenates 2 guint16 (supposed to be a Dicom group number 
39  *                                             and a Dicom element number)
40  * @param  group the Dicom group   number used to build the tag
41  * @param  element the Dicom element number used to build the tag
42  * @return the built tag
43  */
44 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element)
45 {
46         char trash[10];
47         TagKey key;
48         // CLEANME: better call the iostream<< with the hex manipulator on.
49         // This requires some reading of the stdlibC++ sources to make the
50         // proper call (or copy).
51         sprintf(trash, "%04x|%04x", group , element);
52         key = trash;  // Convertion through assignement
53         return key;
54 }
55
56 /**
57  * \brief       If-and only if-the V(alue) R(epresentation)
58  * \            is unset then overwrite it.
59  * @param NewVr New V(alue) R(epresentation) to be set.
60  */
61 void gdcmDictEntry::SetVR(std::string NewVr) 
62 {
63         if ( IsVRUnknown() )
64                 vr = NewVr;
65         else 
66    {
67                 dbg.Error(true, "gdcmDictEntry::SetVR",
68                           "Overwriting vr might compromise a dictionary");
69         }
70 }
71
72 //-----------------------------------------------------------------------------
73 // Protected
74
75 //-----------------------------------------------------------------------------
76 // Private
77
78 //-----------------------------------------------------------------------------
79