X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Fctfadaptor%2FCtfTmfTrace.java;h=9481d2d3e237be7c1855f5cea161db4d40dacfed;hb=2065894741f9e2ad30265d0ffe7ccf00fe40e67d;hp=71838854c72f63ff1de3f70b24df5de03781f30f;hpb=4dbe1f0ee4eaade63d05842b28d5b39f4b1c85ab;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index 71838854c7..9481d2d3e2 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -18,8 +18,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -public class CtfTmfTrace extends TmfEventProvider implements - ITmfTrace { +public class CtfTmfTrace extends TmfEventProvider implements ITmfTrace { // ------------------------------------------------------------------------ // Constants @@ -58,17 +57,17 @@ public class CtfTmfTrace extends TmfEventProvider implements } @Override - public void initTrace(String name, String path, Class eventType) + public void initTrace(final IResource resource, final String path, final Class 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); @@ -83,26 +82,22 @@ public class CtfTmfTrace extends TmfEventProvider implements // 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; } @@ -122,6 +117,29 @@ public class CtfTmfTrace extends TmfEventProvider implements // Accessors // ------------------------------------------------------------------------ + /** + * @return the trace path + */ + @Override + public Class 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 */ @@ -132,17 +150,16 @@ public class CtfTmfTrace extends TmfEventProvider implements @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 @@ -170,26 +187,20 @@ public class CtfTmfTrace extends TmfEventProvider implements 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; } @@ -198,16 +209,16 @@ public class CtfTmfTrace extends TmfEventProvider implements // ------------------------------------------------------------------------ @Override - public ITmfContext armRequest(ITmfDataRequest request) { + public ITmfContext armRequest(final ITmfDataRequest request) { if ((request instanceof ITmfEventRequest) && !TmfTimestamp.BIG_BANG - .equals(((ITmfEventRequest) request) - .getRange().getStartTime()) - && (request.getIndex() == 0)) { - ITmfContext context = seekEvent(((ITmfEventRequest) request) + .equals(((ITmfEventRequest) request) + .getRange().getStartTime()) + && (request.getIndex() == 0)) { + final ITmfContext context = seekEvent(((ITmfEventRequest) request) .getRange().getStartTime()); ((ITmfEventRequest) request) - .setStartIndex((int) context.getRank()); + .setStartIndex((int) context.getRank()); return context; } return seekEvent(request.getIndex()); @@ -224,7 +235,7 @@ public class CtfTmfTrace extends TmfEventProvider implements * type. */ @Override - public CtfTmfEvent getNext(ITmfContext context) { + public CtfTmfEvent getNext(final ITmfContext context) { iterator.advance(); return iterator.getCurrentEvent(); } @@ -234,17 +245,21 @@ public class CtfTmfTrace extends TmfEventProvider implements // ------------------------------------------------------------------------ @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.getStartTime()) - / (curLocation.getEndTime() - curLocation.getStartTime()); + public double getLocationRatio(final ITmfLocation location) { + final CtfLocation curLocation = (CtfLocation) location; + iterator.seek(curLocation.getLocation()); + return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator + .getStartTime()) + / (iterator.getEndTime() - iterator.getStartTime()); } @Override @@ -253,7 +268,7 @@ public class CtfTmfTrace extends TmfEventProvider implements } @Override - public ITmfContext seekEvent(ITmfTimestamp timestamp) { + public ITmfContext seekEvent(final ITmfTimestamp timestamp) { iterator.seek(timestamp.getValue()); return iterator; } @@ -262,7 +277,7 @@ public class CtfTmfTrace extends TmfEventProvider implements * Seek by rank */ @Override - public ITmfContext seekEvent(long rank) { + public ITmfContext seekEvent(final long rank) { iterator.setRank(rank); return iterator; } @@ -271,19 +286,19 @@ public class CtfTmfTrace extends TmfEventProvider implements * 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(); } @@ -292,13 +307,10 @@ public class CtfTmfTrace extends TmfEventProvider implements return this.fResource; } - @Override - public void setResource(IResource fResource) { - this.fResource = fResource; - } - CTFTrace getCTFTrace() { return fTrace; } + + }