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