ctf: Fix API inconsistencies
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / EnumDefinition.java
index e7824197d74280f763865df9cc96c5518f3bc0fc..f04f1d118cfcc789b1328cb9b50a4992781b6d6f 100644 (file)
 
 package org.eclipse.linuxtools.ctf.core.event.types;
 
-import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
+import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
 
 /**
- * <b><u>EnumDefinition</u></b>
+ * A CTF enum definition.
+ *
+ * The definition of a enum point basic data type. It will take the data
+ * from a trace and store it (and make it fit) as an integer and a string.
+ *
+ * @version 1.0
+ * @author Matthew Khouzam
+ * @author Simon Marchi
  */
-public class EnumDefinition extends Definition {
+public class EnumDefinition extends SimpleDatatypeDefinition {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -33,6 +40,12 @@ public class EnumDefinition extends Definition {
     // Constructors
     // ------------------------------------------------------------------------
 
+    /**
+     * Constructor
+     * @param declaration the parent declaration
+     * @param definitionScope the parent scope
+     * @param fieldName the field name
+     */
     public EnumDefinition(EnumDeclaration declaration,
             IDefinitionScope definitionScope, String fieldName) {
         super(definitionScope, fieldName);
@@ -48,25 +61,51 @@ public class EnumDefinition extends Definition {
     // Getters/Setters/Predicates
     // ------------------------------------------------------------------------
 
+    /**
+     * Gets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will return "DAY"
+     * @return the value of the enum.
+     */
     public String getValue() {
         return value;
     }
 
-    public long getIntegerValue() {
+    @Override
+    public String getStringValue(){
+        return getValue();
+    }
+
+    /**
+     * Gets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will return 0
+     * @return the value of the enum.
+     */
+    @Override
+    public Long getIntegerValue() {
         return integerValue.getValue();
     }
 
+    /**
+     * Sets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will set 0
+     * @param Value The value of the enum.
+     */
     public void setIntegerValue(long Value) {
         integerValue.setValue(Value);
         value = ((Long) integerValue.getValue()).toString();
     }
 
+    @Override
+    public EnumDeclaration getDeclaration() {
+        return declaration;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
 
     @Override
     public void read(BitBuffer input) {
+        int align = (int) declaration.getAlignment();
+        int pos = input.position() + ((align-(input.position() % align))%align);
+        input.position(pos);
         integerValue.read(input);
         long val = integerValue.getValue();
 
This page took 0.025153 seconds and 5 git commands to generate.