]> Creatis software - gdcm.git/blobdiff - src/gdcmDictEntry.cxx
* More memmory link related corrections and documentation fixes.
[gdcm.git] / src / gdcmDictEntry.cxx
index ddfd3e00ec7d45d626835bcab614bbde805558fe..8823ac731748069d4a1df6b941f02fefc44f746e 100644 (file)
@@ -1,14 +1,19 @@
-#include "gdcm.h"
+// gdcmDictEntry.cxx
+
+#include <stdio.h>    // FIXME For sprintf
+#include "gdcmDictEntry.h"
+#include "gdcmUtil.h"
+
 
 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
-                             string  InVr, string InFourth, string InName) 
-{
-       group = InGroup;
-       element = InElement;
-       vr = InVr;
-       fourth = InFourth;
-       name = InName;
-       key = TranslateToKey(group, element);
+                             string  InVr, string InFourth,
+                             string  InName) {
+       group           = InGroup;
+       element         = InElement;
+       vr              = InVr;
+       fourth          = InFourth;
+       name            = InName;
+       key             = TranslateToKey(group, element);
 }
 
 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
@@ -21,3 +26,23 @@ TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
        key = trash;  // Convertion through assignement
        return key;
 }
+
+/**
+ * \ingroup     gdcmDictEntry
+ * \brief       If-and only if-the vr is unset then overwrite it.
+ * @param NewVr New vr to be set.
+ */
+void gdcmDictEntry::SetVR(string NewVr) {
+       if ( IsVrUnknown() )
+               vr = NewVr;
+       else {
+               dbg.Error(true, "gdcmDictEntry::SetVR",
+                         "Overwriting vr might compromise a dictionary");
+       }
+}
+
+bool gdcmDictEntry::IsVrUnknown() {
+       if ( vr == "Unknown" )
+               return true;
+       return false;
+}