]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
* python/testSuite.py unittest test suite added (uses Data)
[gdcm.git] / src / gdcmDictEntry.cxx
1 #include "gdcm.h"
2 #include "gdcmUtil.h"
3
4 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
5                              string  InVr, string InFourth, string InName) 
6 {
7         group = InGroup;
8         element = InElement;
9         vr = InVr;
10         fourth = InFourth;
11         name = InName;
12         key = TranslateToKey(group, element);
13 }
14
15 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
16         char trash[10];
17         TagKey key;
18         // CLEAN ME: better call the iostream<< with the hex manipulator on.
19         // This requires some reading of the stdlibC++ sources to make the
20         // proper call (or copy).
21         sprintf(trash, "%04x|%04x", group , element);
22         key = trash;  // Convertion through assignement
23         return key;
24 }
25
26 /**
27  * \ingroup     gdcmDictEntry
28  * \brief       If-and only if-the vr is unset then overwrite it.
29  * @param NewVr New vr to be set.
30  */
31 void gdcmDictEntry::SetVR(string NewVr) {
32         if ( IsVrUnknown() )
33                 vr = NewVr;
34         else {
35                 dbg.Error(true, "gdcmDictEntry::SetVR",
36                           "Overwriting vr might compromise a dictionary");
37         }
38 }
39
40 bool gdcmDictEntry::IsVrUnknown() {
41         if ( vr == "Unknown" )
42                 return true;
43         return false;
44 }