import java.util.Collections;
import java.util.Vector;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
// Flag to initialize only once
private boolean fInitialized = false;
- // The experiment resource
+ // The experiment bookmarks file
+ private IFile fBookmarksFile;
+
+ // The properties resource
private IResource fResource;
// ------------------------------------------------------------------------
}
@Override
- public void initTrace(String name, String path, Class<T> eventType) {
- }
-
- @Override
- public void initTrace(String name, String path, Class<T> eventType, boolean indexTrace) {
- if (indexTrace) {
- initializeStreamingMonitor();
- }
- }
-
- @Override
- public void initTrace(String name, String path, Class<T> eventType, int cacheSize) {
- }
-
- @Override
- public void initTrace(String name, String path, Class<T> eventType, int cacheSize, boolean indexTrace) {
- if (indexTrace) {
- initializeStreamingMonitor();
- }
+ public void initTrace(String name, String path, Class<T> eventType, int pageSize) {
}
/**
fTimeRange = TmfTimeRange.NULL_RANGE;
if (preIndexExperiment) {
- indexExperiment(true);
+ indexExperiment(true, 0, TmfTimeRange.ETERNITY);
updateTimeRange();
}
-
}
protected TmfExperiment(String id, Class<T> type) {
this(type, id, traces, TmfTimestamp.ZERO, indexPageSize);
}
- /**
- * Copy constructor
- *
- * @param other
- */
- @SuppressWarnings("unchecked")
- public TmfExperiment(TmfExperiment<T> other) {
- super(other.getName() + "(clone)", other.fType); //$NON-NLS-1$
-
- fEpoch = other.fEpoch;
- fIndexPageSize = other.fIndexPageSize;
-
- fTraces = new ITmfTrace[other.fTraces.length];
- for (int trace = 0; trace < other.fTraces.length; trace++) {
- fTraces[trace] = other.fTraces[trace].copy();
- }
-
- fNbEvents = other.fNbEvents;
- fTimeRange = other.fTimeRange;
- }
-
- @Override
- public TmfExperiment<T> copy() {
- TmfExperiment<T> experiment = new TmfExperiment<T>(this);
- TmfSignalManager.deregister(experiment);
- return experiment;
- }
-
/**
* Clears the experiment
*/
* Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event
* (if any).
*
- * @param timestamp
- * @return
+ * @param timestamp the event timestamp
+ * @return the corresponding event rank
*/
@Override
public long getRank(ITmfTimestamp timestamp) {
/**
* Returns the timestamp of the event at the requested index. If none, returns null.
*
- * @param index
- * @return
+ * @param index the event index (rank)
+ * @return the corresponding event timestamp
*/
public ITmfTimestamp getTimestamp(int index) {
TmfExperimentContext context = seekEvent(index);
rank += traceRank;
// Set the trace location and read the corresponding event
- expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone();
+ /* The (TmfContext) cast should be safe since we created 'context'
+ * ourselves higher up. */
+ expLocation.getLocation().locations[i] = ((TmfContext) context.getContexts()[i]).getLocation().clone();
context.getEvents()[i] = fTraces[i].getNextEvent(context.getContexts()[i]);
}
return null;
}
- /**
- * Scan the next events from all traces and return the next one in chronological order.
- *
- * @param context
- * @return
- */
-
// private void dumpContext(TmfExperimentContext context, boolean isBefore) {
// TmfContext context0 = context.getContexts()[0];
// Tracer.trace(result.toString());
// }
+ /**
+ * Scan the next events from all traces and return the next one in chronological order.
+ *
+ * @param context the trace context
+ * @return the next event
+ */
+ @SuppressWarnings("unchecked")
@Override
- public synchronized ITmfEvent getNextEvent(TmfContext context) {
+ public synchronized ITmfEvent getNextEvent(ITmfContext context) {
// Validate the context
if (!(context instanceof TmfExperimentContext)) {
// If an event was consumed previously, get the next one from that trace
int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
- TmfContext traceContext = expContext.getContexts()[lastTrace];
+ ITmfContext traceContext = expContext.getContexts()[lastTrace];
expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
}
if (trace != TmfExperimentContext.NO_TRACE) {
updateIndex(expContext, timestamp);
- TmfContext traceContext = expContext.getContexts()[trace];
+ ITmfContext traceContext = expContext.getContexts()[trace];
TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
// expLocation.getLocation()[trace] = traceContext.getLocation().clone();
- expLocation.getLocation().locations[trace] = traceContext.getLocation().clone();
+ expLocation.getLocation().locations[trace] = (ITmfLocation<? extends Comparable<?>>) traceContext.getLocation().clone();
// updateIndex(expContext, timestamp);
* @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
*/
@Override
- public ITmfEvent parseEvent(TmfContext context) {
+ public ITmfEvent parseEvent(ITmfContext context) {
// Validate the context
if (!(context instanceof TmfExperimentContext)) {
// If an event was consumed previously, get the next one from that trace
int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
- TmfContext traceContext = expContext.getContexts()[lastTrace];
+ ITmfContext traceContext = expContext.getContexts()[lastTrace];
expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
fExperimentContext = (TmfExperimentContext) context;
}
}
- protected void indexExperiment(boolean waitForCompletion) {
- indexExperiment(waitForCompletion, 0, TmfTimeRange.ETERNITY);
+ @Override
+ public void indexTrace(boolean waitForCompletion) {
+ if (waitForCompletion) {
+ initializeStreamingMonitor();
+ }
}
@SuppressWarnings("unchecked")
}
/**
- * Set the resource to be used for bookmarks on this experiment
- * @param resource the bookmarks resource
+ * Set the file to be used for bookmarks on this experiment
+ * @param file the bookmarks file
*/
+ public void setBookmarksFile(IFile file) {
+ fBookmarksFile = file;
+ }
+
+ /**
+ * Get the file used for bookmarks on this experiment
+ * @return the bookmarks file or null if none is set
+ */
+ public IFile getBookmarksFile() {
+ return fBookmarksFile;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#setResource(org.eclipse.core.resources.IResource)
+ */
+ @Override
public void setResource(IResource resource) {
fResource = resource;
}
- /**
- * Get the resource used for bookmarks on this experiment
- * @return the bookmarks resource or null if none is set
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getResource()
*/
+ @Override
public IResource getResource() {
return fResource;
}