ctf: Fix lost events in a more elegant way
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / trace / StreamInputPacketIndexEntry.java
index f9968451ae8337c809b44b9dcc0deefd5e4c7b92..3a0379082351e5698953c6ca79820ec42fc9d9f4 100644 (file)
@@ -12,6 +12,9 @@
 
 package org.eclipse.linuxtools.internal.ctf.core.trace;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * <b><u>StreamInputPacketIndexEntry</u></b>
  * <p>
@@ -23,8 +26,6 @@ public class StreamInputPacketIndexEntry {
     // Attributes
     // ------------------------------------------------------------------------
 
-
-
     /**
      * Offset of the packet in the file, in bytes
      */
@@ -55,10 +56,22 @@ public class StreamInputPacketIndexEntry {
      */
     private long timestampEnd = 0;
 
+    /**
+     * How many lost events are there?
+     */
+    private long lostEvents = 0;
+
+    /**
+     * Which target is being traced
+     */
+    private String target ;
+    private long targetID;
 
-    private long indexBegin = Long.MAX_VALUE;
+    /**
+     * Attributes of this index entry
+     */
+    private final Map<String, Object> attributes = new HashMap<String, Object>();
 
-    private long indexEnd = Long.MAX_VALUE;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -91,18 +104,16 @@ public class StreamInputPacketIndexEntry {
         return (ts >= timestampBegin) && (ts <= timestampEnd);
     }
 
-    boolean includesIndex(long index){
-        return (index >= indexBegin) && (index <= indexEnd);
-    }
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     *
      * @see java.lang.Object#toString()
      */
     @Override
     public String toString() {
         return "StreamInputPacketIndexEntry [offsetBytes=" + offsetBytes //$NON-NLS-1$
                 + ", timestampBegin=" + timestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
-                + timestampEnd + ", indexBegin=" + indexBegin + ", indexEnd=" //$NON-NLS-1$ //$NON-NLS-2$
-                + indexEnd + "]"; //$NON-NLS-1$
+                + timestampEnd + "]"; //$NON-NLS-1$
     }
 
     // ------------------------------------------------------------------------
@@ -124,7 +135,8 @@ public class StreamInputPacketIndexEntry {
     }
 
     /**
-     * @param dataOffsetBits the dataOffsetBits to set
+     * @param dataOffsetBits
+     *            the dataOffsetBits to set
      */
     public void setDataOffsetBits(int dataOffsetBits) {
         this.dataOffsetBits = dataOffsetBits;
@@ -138,7 +150,8 @@ public class StreamInputPacketIndexEntry {
     }
 
     /**
-     * @param packetSizeBits the packetSizeBits to set
+     * @param packetSizeBits
+     *            the packetSizeBits to set
      */
     public void setPacketSizeBits(int packetSizeBits) {
         this.packetSizeBits = packetSizeBits;
@@ -152,7 +165,8 @@ public class StreamInputPacketIndexEntry {
     }
 
     /**
-     * @param contentSizeBits the contentSizeBits to set
+     * @param contentSizeBits
+     *            the contentSizeBits to set
      */
     public void setContentSizeBits(int contentSizeBits) {
         this.contentSizeBits = contentSizeBits;
@@ -166,7 +180,8 @@ public class StreamInputPacketIndexEntry {
     }
 
     /**
-     * @param timestampBegin the timestampBegin to set
+     * @param timestampBegin
+     *            the timestampBegin to set
      */
     public void setTimestampBegin(long timestampBegin) {
         this.timestampBegin = timestampBegin;
@@ -180,37 +195,72 @@ public class StreamInputPacketIndexEntry {
     }
 
     /**
-     * @param timestampEnd the timestampEnd to set
+     * @param timestampEnd
+     *            the timestampEnd to set
      */
     public void setTimestampEnd(long timestampEnd) {
         this.timestampEnd = timestampEnd;
     }
 
     /**
-     * @return the indexBegin
+     * @return the lostEvents in this packet
      */
-    public long getIndexBegin() {
-        return indexBegin;
+    public long getLostEvents() {
+        return lostEvents;
     }
 
     /**
-     * @param indexBegin the indexBegin to set
+     * @param lostEvents the lostEvents to set
      */
-    public void setIndexBegin(long indexBegin) {
-        this.indexBegin = indexBegin;
+    public void setLostEvents(long lostEvents) {
+        this.lostEvents = lostEvents;
     }
 
     /**
-     * @return the indexEnd
+     * Add an attribute to this index entry
+     *
+     * @param field
+     *            The name of the attribute
+     * @param value
+     *            The value to insert
+     */
+    public void addAttribute(String field, Object value) {
+        attributes.put(field, value);
+    }
+
+    /**
+     * Retrieve the value of an existing attribute
+     *
+     * @param field
+     *            The name of the attribute
+     * @return The value that was stored, or null if it wasn't found
+     */
+    public Object lookupAttribute(String field){
+        return attributes.get(field);
+    }
+
+    /**
+     * @return The target that is being traced
+     */
+    public String getTarget() {
+        return target;
+    }
+
+    /**
+     * Assign a target to this index entry
+     *
+     * @param target
+     *            The target to assign
      */
-    public long getIndexEnd() {
-        return indexEnd;
+    public void setTarget(String target) {
+        this.target = target;
+        this.targetID = Integer.parseInt(target.replaceAll("[\\D]", "")); //$NON-NLS-1$ //$NON-NLS-2$ // slow
     }
 
     /**
-     * @param indexEnd the indexEnd to set
+     * @return The ID of the target
      */
-    public void setIndexEnd(long indexEnd) {
-        this.indexEnd = indexEnd;
+    public long getTargetId(){
+        return targetID;
     }
 }
This page took 0.034655 seconds and 5 git commands to generate.