Merge master in TmfTraceModel
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfTrace.java
index e2c2cbfe9e27457e2ab4b3e742036c6b964d5be0..a4c7616eaf04deceefee545bb225549759b5ea25 100644 (file)
@@ -1,7 +1,6 @@
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
 import java.io.FileNotFoundException;
-import java.util.Vector;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -18,7 +17,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
 
 public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
         ITmfTrace<CtfTmfEvent> {
@@ -27,10 +25,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     // Constants
     // ------------------------------------------------------------------------
 
-    // The default number of events to cache
-    // TODO: Make the DEFAULT_CACHE_SIZE a preference
-    public static final int DEFAULT_INDEX_PAGE_SIZE = 50000;
-
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -38,12 +32,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     // the Ctf Trace
     private CTFTrace fTrace;
 
-    // The cache page size AND checkpoints interval
-    protected int fIndexPageSize = DEFAULT_INDEX_PAGE_SIZE;
-
-    // The set of event stream checkpoints (for random access)
-    private Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
-
     // The number of events collected
     protected long fNbEvents = 0;
 
@@ -69,6 +57,7 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
         super();
     }
 
+    @SuppressWarnings("unused")
     @Override
     public void initTrace(String name, String path, Class<CtfTmfEvent> eventType)
             throws FileNotFoundException {
@@ -80,7 +69,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
              * was not found or was not recognized as a CTF trace. Throw into
              * the new type of exception expected by the rest of TMF.
              */
-            System.err.println("Cannot find file " + path); //$NON-NLS-1$
             throw new FileNotFoundException(e.getMessage());
         }
         this.iterator = new CtfIterator(this, 0, 0);
@@ -95,25 +83,10 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
         // this.fEndTime.clone()));
     }
 
+    @SuppressWarnings("unused")
     @Override
-    public void initTrace(String name, String path,
-            Class<CtfTmfEvent> eventType, int cacheSize)
-            throws FileNotFoundException {
-        this.initTrace(name, path, eventType);
-    }
-
-    @Override
-    public void initTrace(String name, String path,
-            Class<CtfTmfEvent> eventType, boolean indexTrace)
-            throws FileNotFoundException {
-        this.initTrace(name, path, eventType);
-    }
-
-    @Override
-    public void initTrace(String name, String path,
-            Class<CtfTmfEvent> eventType, int cacheSize, boolean indexTrace)
-            throws FileNotFoundException {
-        this.initTrace(name, path, eventType);
+    public void indexTrace(boolean waitForCompletion) {
+        // do nothing
     }
 
     @Override
@@ -126,6 +99,7 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
         TmfSignalManager.dispatchSignal(signal);
     }
 
+    @SuppressWarnings("unused")
     @Override
     public boolean validate(IProject project, String path) {
         try {
@@ -141,23 +115,31 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     public CtfTmfTrace clone() throws CloneNotSupportedException {
         CtfTmfTrace clone = null;
         clone = (CtfTmfTrace) super.clone();
-        clone.setfCheckpoints(this.fCheckpoints);
         clone.fStartTime = this.fStartTime.clone();
         clone.fEndTime = this.fEndTime.clone();
         clone.fTrace = this.fTrace;
         return clone;
     }
 
-    @Override
-    public ITmfTrace<CtfTmfEvent> copy() {
-        // FIXME not yet implemented
-        return null;
-    }
-
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
 
+    public int getNbEnvVars() {
+        return this.fTrace.getEnvironment().size();
+    }
+
+
+    public String[] getEnvNames() {
+        String[] s = new String[getNbEnvVars()];
+        return this.fTrace.getEnvironment().keySet().toArray(s);
+    }
+
+    public String getEnvValue(String key)    {
+        return this.fTrace.getEnvironment().get(key);
+    }
+
+
     /**
      * @return the trace path
      */
@@ -177,8 +159,8 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     }
 
     @Override
-    public int getCacheSize() {
-        return this.fIndexPageSize;
+    public int getIndexPageSize() {
+        return 50000; // not true, but it works
     }
 
     @Override
@@ -236,10 +218,14 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     @Override
     public ITmfContext armRequest(ITmfDataRequest<CtfTmfEvent> request) {
         if ((request instanceof ITmfEventRequest<?>)
-                && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<CtfTmfEvent>) request).getRange().getStartTime())
+                && !TmfTimestamp.BIG_BANG
+                        .equals(((ITmfEventRequest<CtfTmfEvent>) request)
+                                .getRange().getStartTime())
                 && (request.getIndex() == 0)) {
-            ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request).getRange().getStartTime());
-            ((ITmfEventRequest<CtfTmfEvent>) request).setStartIndex((int) context.getRank());
+            ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request)
+                    .getRange().getStartTime());
+            ((ITmfEventRequest<CtfTmfEvent>) request)
+                    .setStartIndex((int) context.getRank());
             return context;
         }
         return seekEvent(request.getIndex());
@@ -248,13 +234,14 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     /**
      * The trace reader keeps its own iterator: the "context" parameter here
      * will be ignored.
-     * 
+     *
      * If you wish to specify a new context, instantiate a new CtfIterator and
      * seek() it to where you want, and use that to read events.
-     * 
+     *
      * FIXME merge with getNextEvent below once they both use the same parameter
      * type.
      */
+    @SuppressWarnings("unused")
     @Override
     public CtfTmfEvent getNext(ITmfContext context) {
         iterator.advance();
@@ -267,13 +254,21 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
 
     @Override
     public ITmfContext seekLocation(ITmfLocation<?> location) {
-        iterator.setLocation(location);
+        CtfLocation currentLocation = (CtfLocation) location;
+        if (currentLocation == null) {
+            currentLocation = new CtfLocation(0L);
+        }
+        iterator.setLocation(currentLocation);
         return iterator;
     }
 
     @Override
     public double getLocationRatio(ITmfLocation<?> location) {
-        return 0;
+        CtfLocation curLocation = (CtfLocation) location;
+        iterator.seek(curLocation.getLocation());
+        return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator
+                .getStartTime())
+                / (iterator.getEndTime() - iterator.getStartTime());
     }
 
     @Override
@@ -305,25 +300,19 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
         return iterator;
     }
 
+    @SuppressWarnings("unused")
     @Override
     public CtfTmfEvent getNextEvent(ITmfContext context) {
         iterator.advance();
         return iterator.getCurrentEvent();
     }
 
+    @SuppressWarnings("unused")
     @Override
     public CtfTmfEvent parseEvent(ITmfContext context) {
         return iterator.getCurrentEvent();
     }
 
-    public Vector<TmfCheckpoint> getfCheckpoints() {
-        return this.fCheckpoints;
-    }
-
-    public void setfCheckpoints(Vector<TmfCheckpoint> fCheckpoints) {
-        this.fCheckpoints = fCheckpoints;
-    }
-
     @Override
     public IResource getResource() {
         return this.fResource;
@@ -337,4 +326,7 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
     CTFTrace getCTFTrace() {
         return fTrace;
     }
+
+
+
 }
This page took 0.026555 seconds and 5 git commands to generate.