import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
- ITmfTrace<CtfTmfEvent> {
+public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements ITmfTrace<CtfTmfEvent> {
// ------------------------------------------------------------------------
// Constants
}
@Override
- public void initTrace(String name, String path, Class<CtfTmfEvent> eventType)
+ public void initTrace(final IResource resource, final String path, final Class<CtfTmfEvent> eventType)
throws FileNotFoundException {
+ this.fResource = resource;
try {
this.fTrace = new CTFTrace(path);
- } catch (CTFReaderException e) {
+ } catch (final CTFReaderException e) {
/*
* If it failed at the init(), we can assume it's because the file
* 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);
// this.fEndTime.clone()));
}
-
-
- @Override
- public void indexTrace(boolean waitForCompletion) {
- }
-
@Override
public void dispose() {
TmfSignalManager.deregister(this);
}
@Override
- public void broadcast(TmfSignal signal) {
+ public void broadcast(final TmfSignal signal) {
TmfSignalManager.dispatchSignal(signal);
}
@Override
- public boolean validate(IProject project, String path) {
+ public boolean validate(final IProject project, final String path) {
try {
final CTFTrace temp = new CTFTrace(path);
return temp.majortIsSet(); // random test
- } catch (CTFReaderException e) {
+ } catch (final CTFReaderException e) {
/* Nope, not a CTF trace we can read */
return false;
}
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * @return the trace path
+ */
+ @Override
+ public Class<CtfTmfEvent> getType() {
+ return fType;
+ }
+
+ public int getNbEnvVars() {
+ return this.fTrace.getEnvironment().size();
+ }
+
+
+ public String[] getEnvNames() {
+ final String[] s = new String[getNbEnvVars()];
+ return this.fTrace.getEnvironment().keySet().toArray(s);
+ }
+
+ public String getEnvValue(final String key) {
+ return this.fTrace.getEnvironment().get(key);
+ }
+
+
/**
* @return the trace path
*/
@Override
public String getName() {
- String temp[] = this.fTrace.getPath().split(
+ final String temp[] = this.fTrace.getPath().split(
System.getProperty("file.separator")); //$NON-NLS-1$
- if (temp.length > 2) {
+ if (temp.length > 2)
return temp[temp.length - 1];
- }
return temp[0];
}
@Override
- public int getIndexPageSize() {
- return this.fIndexPageSize;
+ public int getCacheSize() {
+ return 50000; // not true, but it works
}
@Override
return iterator.getLocation();
}
- @Override
- public long getRank(ITmfTimestamp timestamp) {
- ITmfContext context = seekEvent(timestamp);
- return context.getRank();
- }
-
// ------------------------------------------------------------------------
// Operators
// ------------------------------------------------------------------------
- protected void setTimeRange(TmfTimeRange range) {
+ protected void setTimeRange(final TmfTimeRange range) {
this.fStartTime = range.getStartTime();
this.fEndTime = range.getEndTime();
}
- protected void setStartTime(ITmfTimestamp startTime) {
+ protected void setStartTime(final ITmfTimestamp startTime) {
this.fStartTime = startTime;
}
- protected void setEndTime(ITmfTimestamp endTime) {
+ protected void setEndTime(final ITmfTimestamp endTime) {
this.fEndTime = endTime;
}
// ------------------------------------------------------------------------
@Override
- public ITmfContext armRequest(ITmfDataRequest<CtfTmfEvent> request) {
+ public ITmfContext armRequest(final ITmfDataRequest<CtfTmfEvent> request) {
if ((request instanceof ITmfEventRequest<?>)
&& !TmfTimestamp.BIG_BANG
- .equals(((ITmfEventRequest<CtfTmfEvent>) request)
- .getRange().getStartTime())
- && (request.getIndex() == 0)) {
- ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request)
+ .equals(((ITmfEventRequest<CtfTmfEvent>) request)
+ .getRange().getStartTime())
+ && (request.getIndex() == 0)) {
+ final ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request)
.getRange().getStartTime());
((ITmfEventRequest<CtfTmfEvent>) request)
- .setStartIndex((int) context.getRank());
+ .setStartIndex((int) context.getRank());
return context;
}
return seekEvent(request.getIndex());
* type.
*/
@Override
- public CtfTmfEvent getNext(ITmfContext context) {
+ public CtfTmfEvent getNext(final ITmfContext context) {
iterator.advance();
return iterator.getCurrentEvent();
}
// ------------------------------------------------------------------------
@Override
- public ITmfContext seekLocation(ITmfLocation<?> location) {
- iterator.setLocation(location);
+ public ITmfContext seekLocation(final ITmfLocation<?> location) {
+ CtfLocation currentLocation = (CtfLocation) location;
+ if (currentLocation == null)
+ currentLocation = new CtfLocation(0L);
+ iterator.setLocation(currentLocation);
return iterator;
}
@Override
- public double getLocationRatio(ITmfLocation<?> location) {
- CtfIterator curLocation = (CtfIterator) location;
- return ((double) curLocation.getCurrentEvent().getTimestampValue() - curLocation
+ public double getLocationRatio(final ITmfLocation<?> location) {
+ final CtfLocation curLocation = (CtfLocation) location;
+ iterator.seek(curLocation.getLocation());
+ return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator
.getStartTime())
- / (curLocation.getEndTime() - curLocation.getStartTime());
+ / (iterator.getEndTime() - iterator.getStartTime());
}
@Override
}
@Override
- public ITmfContext seekEvent(ITmfTimestamp timestamp) {
+ public ITmfContext seekEvent(final ITmfTimestamp timestamp) {
iterator.seek(timestamp.getValue());
return iterator;
}
* Seek by rank
*/
@Override
- public ITmfContext seekEvent(long rank) {
+ public ITmfContext seekEvent(final long rank) {
iterator.setRank(rank);
return iterator;
}
* Seek rank ratio
*/
@Override
- public ITmfContext seekLocation(double ratio) {
+ public ITmfContext seekLocation(final double ratio) {
iterator.seek((long) (this.fNbEvents * ratio));
return iterator;
}
@Override
- public CtfTmfEvent getNextEvent(ITmfContext context) {
+ public CtfTmfEvent getNextEvent(final ITmfContext context) {
iterator.advance();
return iterator.getCurrentEvent();
}
@Override
- public CtfTmfEvent parseEvent(ITmfContext context) {
+ public CtfTmfEvent parseEvent(final ITmfContext context) {
return iterator.getCurrentEvent();
}
return this.fResource;
}
- @Override
- public void setResource(IResource fResource) {
- this.fResource = fResource;
- }
-
CTFTrace getCTFTrace() {
return fTrace;
}
+
+
}