Remove the generic location (replace by Comparable)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / ITmfTrace.java
index af9e741576271b1a5f1d3e7dcc21ef44adf45ac2..ec087bea23f05da4a3bf74fef847924f563fe7ee 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
  * Copyright (c) 2009, 2011, 2012 Ericsson
- * 
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Updated as per TMF Trace Model 1.0
 
 package org.eclipse.linuxtools.tmf.core.trace;
 
-import java.io.FileNotFoundException;
-
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 
 /**
- * <b><u>ITmfTrace</u></b>
- * <p>
  * The event stream structure in TMF. In its basic form, a trace has:
  * <ul>
  * <li> an associated Eclipse resource
@@ -36,7 +32,7 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * </ul>
  * Concrete ITmfTrace classes have to provide a parameter-less constructor and
  * an initialization method (<i>initTrace</i>) if they are to be opened from
- * the Project View. Also, a validation method (<i>validate</i>) has to be 
+ * the Project View. Also, a validation method (<i>validate</i>) has to be
  * provided to ensure that the trace is of the correct type.
  * <p>
  * A trace can be accessed simultaneously from multiple threads by various
@@ -50,21 +46,21 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * <b>Example 1</b>: Process a whole trace
  * <pre>
  * ITmfContext context = trace.seekEvent(0);
- * ITmfEvent event = trace.getEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null) {
  *     processEvent(event);
- *     event = trace.getEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * <b>Example 2</b>: Process 50 events starting from the 1000th event
  * <pre>
  * int nbEventsRead = 0;
  * ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.getEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null && nbEventsRead < 50) {
  *     nbEventsRead++;
  *     processEvent(event);
- *     event = trace.getEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * <b>Example 3</b>: Process the events between 2 timestamps (inclusive)
@@ -72,10 +68,10 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  * ITmfTimestamp startTime = ...;
  * ITmfTimestamp endTime = ...;
  * ITmfContext context = trace.seekEvent(startTime);
- * ITmfEvent event = trace.getEvent(context);
+ * ITmfEvent event = trace.getNext(context);
  * while (event != null && event.getTimestamp().compareTo(endTime) <= 0) {
  *     processEvent(event);
- *     event = trace.getEvent(context);
+ *     event = trace.getNext(context);
  * }
  * </pre>
  * A trace is also an event provider so it can process event requests
@@ -96,17 +92,31 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
  *         super.handleCompleted();
  *     }
  * };
- * 
+ *
  * fTrace.handleRequest(request);
  * if (youWant) {
  *     request.waitForCompletion();
- * } 
+ * }
  * </pre>
+ *
+ * @version 1.0
+ * @author Francois Chouinard
+ *
+ * @see ITmfContext
  * @see ITmfEvent
- * @see ITmfEventProvider
- * @see ITmfEventRequest
+ * @see ITmfTraceIndexer
+ * @see ITmfEventParser
  */
-public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
+public interface ITmfTrace extends ITmfDataProvider {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    /**
+     * The default trace cache size
+     */
+    public static final int DEFAULT_TRACE_CACHE_SIZE = 1000;
 
     // ------------------------------------------------------------------------
     // Initializers
@@ -119,20 +129,20 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * <p>
      * Typically, the parameterless constructor will provide the block size
      * and its associated parser and indexer.
-     * 
+     *
      * @param resource the trace resource
      * @param path the trace path
      * @param type the trace event type
-     * @throws FileNotFoundException
+     * @throws TmfTraceException If we couldn't open the trace
      */
-    public void initTrace(IResource resource, String path, Class<T> type) throws FileNotFoundException;
+    public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException;
 
     /**
      * Validate that the trace is of the correct type.
-     * 
+     *
      * @param project the eclipse project
      * @param path the trace path
-     * 
+     *
      * @return true if trace is valid
      */
     public boolean validate(IProject project, String path);
@@ -144,7 +154,7 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
     /**
      * @return the trace event type
      */
-    public Class<T> getType();
+    public Class<? extends ITmfEvent> getEventType();
 
     /**
      * @return the associated trace resource
@@ -185,6 +195,11 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      */
     public ITmfTimestamp getEndTime();
 
+    /**
+     * @return the streaming interval in ms (0 if not a streaming trace)
+     */
+    public long getStreamingInterval();
+
     // ------------------------------------------------------------------------
     // Trace positioning getters
     // ------------------------------------------------------------------------
@@ -192,15 +207,15 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
     /**
      * @return the current trace location
      */
-    public ITmfLocation<?> getCurrentLocation();
+    public ITmfLocation getCurrentLocation();
 
     /**
      * Returns the ratio (proportion) corresponding to the specified location.
-     * 
+     *
      * @param location a trace specific location
      * @return a floating-point number between 0.0 (beginning) and 1.0 (end)
      */
-    public double getLocationRatio(ITmfLocation<?> location);
+    public double getLocationRatio(ITmfLocation location);
 
     // ------------------------------------------------------------------------
     // SeekEvent operations (returning a trace context)
@@ -218,7 +233,7 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * @param location the trace specific location
      * @return a context which can later be used to read the corresponding event
      */
-    public ITmfContext seekEvent(ITmfLocation<?> location);
+    public ITmfContext seekEvent(ITmfLocation location);
 
     /**
      * Position the trace at the 'rank'th event in the trace.
@@ -228,7 +243,7 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * <p>
      * If the requested rank is beyond the last trace event, the context
      * returned will yield a null event if used in a subsequent read.
-     * 
+     *
      * @param rank the event rank
      * @return a context which can later be used to read the corresponding event
      */
@@ -244,7 +259,7 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * <p>
      * If the requested timestamp is beyond the last trace event, the context
      * returned will yield a null event if used in a subsequent read.
-     * 
+     *
      * @param timestamp the timestamp of desired event
      * @return a context which can later be used to read the corresponding event
      */
@@ -257,32 +272,10 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
      * voluntarily vague. Typically, it would refer to the event proportional
      * rank (arguably more intuitive) or timestamp in the trace file.
-     * 
+     *
      * @param ratio the proportional 'rank' in the trace
      * @return a context which can later be used to read the corresponding event
      */
     public ITmfContext seekEvent(double ratio);
 
-    // ------------------------------------------------------------------------
-    // Read operations (returning an actual event)
-    // ------------------------------------------------------------------------
-
-    /**
-     * Return the event pointed by the supplied context (or null if no event
-     * left) and updates the context to point the next event.
-     * 
-     * @param context the read context (will be updated)
-     * @return the event pointed to by the context
-     */
-    public ITmfEvent readEvent(ITmfContext context);
-
-    // ------------------------------------------------------------------------
-    //
-    // ------------------------------------------------------------------------
-
-    /**
-     * @return the streaming interval in ms (0 if not a streaming trace)
-     */
-    public long getStreamingInterval();
-
 }
This page took 0.027387 seconds and 5 git commands to generate.