btf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / trace / StreamInputPacketIndexEntry.java
index aa1baf2ac1109f7b4d45cc6efc764f731179230d..5074216fd7faf9300981e6238466fa9771517601 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
  *
  * All rights reserved. This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License v1.0 which
@@ -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,36 +26,52 @@ public class StreamInputPacketIndexEntry {
     // Attributes
     // ------------------------------------------------------------------------
 
-
     /**
      * Offset of the packet in the file, in bytes
      */
-    final private long offsetBytes;
+    final private long fOffsetBytes;
 
     /**
      * Offset of the data in the packet, in bits
      */
-    private int dataOffsetBits = 0;
+    private long fDataOffsetBits = 0;
 
     /**
      * Packet size, in bits
      */
-    private int packetSizeBits = 0;
+    private long fPacketSizeBits = 0;
 
     /**
      * Content size, in bits
      */
-    private int contentSizeBits = 0;
+    private long fContentSizeBits = 0;
 
     /**
      * Begin timestamp
      */
-    private long timestampBegin = 0;
+    private long fTimestampBegin = 0;
 
     /**
      * End timestamp
      */
-    private long timestampEnd = 0;
+    private long fTimestampEnd = 0;
+
+    /**
+     * How many lost events are there?
+     */
+    private long fLostEvents = 0;
+
+    /**
+     * Which target is being traced
+     */
+    private String fTarget ;
+    private long fTargetID;
+
+    /**
+     * Attributes of this index entry
+     */
+    private final Map<String, Object> fAttributes = new HashMap<>();
+
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -66,7 +85,7 @@ public class StreamInputPacketIndexEntry {
      */
 
     public StreamInputPacketIndexEntry(long offset) {
-        this.offsetBytes = offset;
+        fOffsetBytes = offset;
     }
 
     // ------------------------------------------------------------------------
@@ -82,19 +101,14 @@ public class StreamInputPacketIndexEntry {
      * @return True if the packet includes the timestamp.
      */
     boolean includes(long ts) {
-        return (ts >= timestampBegin) && (ts <= timestampEnd);
+        return (ts >= fTimestampBegin) && (ts <= fTimestampEnd);
     }
 
-    /*
-     * (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 + "]"; //$NON-NLS-1$
+        return "StreamInputPacketIndexEntry [offsetBytes=" + fOffsetBytes //$NON-NLS-1$
+                + ", timestampBegin=" + fTimestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
+                + fTimestampEnd + "]"; //$NON-NLS-1$
     }
 
     // ------------------------------------------------------------------------
@@ -105,59 +119,59 @@ public class StreamInputPacketIndexEntry {
      * @return the offsetBytes
      */
     public long getOffsetBytes() {
-        return offsetBytes;
+        return fOffsetBytes;
     }
 
     /**
      * @return the dataOffsetBits
      */
-    public int getDataOffsetBits() {
-        return dataOffsetBits;
+    public long getDataOffsetBits() {
+        return fDataOffsetBits;
     }
 
     /**
      * @param dataOffsetBits
      *            the dataOffsetBits to set
      */
-    public void setDataOffsetBits(int dataOffsetBits) {
-        this.dataOffsetBits = dataOffsetBits;
+    public void setDataOffsetBits(long dataOffsetBits) {
+        fDataOffsetBits = dataOffsetBits;
     }
 
     /**
      * @return the packetSizeBits
      */
-    public int getPacketSizeBits() {
-        return packetSizeBits;
+    public long getPacketSizeBits() {
+        return fPacketSizeBits;
     }
 
     /**
      * @param packetSizeBits
      *            the packetSizeBits to set
      */
-    public void setPacketSizeBits(int packetSizeBits) {
-        this.packetSizeBits = packetSizeBits;
+    public void setPacketSizeBits(long packetSizeBits) {
+        fPacketSizeBits = packetSizeBits;
     }
 
     /**
      * @return the contentSizeBits
      */
-    public int getContentSizeBits() {
-        return contentSizeBits;
+    public long getContentSizeBits() {
+        return fContentSizeBits;
     }
 
     /**
      * @param contentSizeBits
      *            the contentSizeBits to set
      */
-    public void setContentSizeBits(int contentSizeBits) {
-        this.contentSizeBits = contentSizeBits;
+    public void setContentSizeBits(long contentSizeBits) {
+        fContentSizeBits = contentSizeBits;
     }
 
     /**
      * @return the timestampBegin
      */
     public long getTimestampBegin() {
-        return timestampBegin;
+        return fTimestampBegin;
     }
 
     /**
@@ -165,14 +179,14 @@ public class StreamInputPacketIndexEntry {
      *            the timestampBegin to set
      */
     public void setTimestampBegin(long timestampBegin) {
-        this.timestampBegin = timestampBegin;
+        fTimestampBegin = timestampBegin;
     }
 
     /**
      * @return the timestampEnd
      */
     public long getTimestampEnd() {
-        return timestampEnd;
+        return fTimestampEnd;
     }
 
     /**
@@ -180,7 +194,68 @@ public class StreamInputPacketIndexEntry {
      *            the timestampEnd to set
      */
     public void setTimestampEnd(long timestampEnd) {
-        this.timestampEnd = timestampEnd;
+        fTimestampEnd = timestampEnd;
+    }
+
+    /**
+     * @return the lostEvents in this packet
+     */
+    public long getLostEvents() {
+        return fLostEvents;
+    }
+
+    /**
+     * @param lostEvents the lostEvents to set
+     */
+    public void setLostEvents(long lostEvents) {
+        fLostEvents = lostEvents;
     }
 
+    /**
+     * 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) {
+        fAttributes.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 fAttributes.get(field);
+    }
+
+    /**
+     * @return The target that is being traced
+     */
+    public String getTarget() {
+        return fTarget;
+    }
+
+    /**
+     * Assign a target to this index entry
+     *
+     * @param target
+     *            The target to assign
+     */
+    public void setTarget(String target) {
+        fTarget = target;
+        fTargetID = Integer.parseInt(target.replaceAll("[\\D]", "")); //$NON-NLS-1$ //$NON-NLS-2$ // slow
+    }
+
+    /**
+     * @return The ID of the target
+     */
+    public long getTargetId(){
+        return fTargetID;
+    }
 }
This page took 0.033733 seconds and 5 git commands to generate.