diff options
author | Francois Chouinard | 2012-03-08 22:52:16 +0000 |
---|---|---|
committer | Francois Chouinard | 2012-03-08 22:52:16 +0000 |
commit | 01a431464928d1f6af099cd35109dd4eeb1accae (patch) | |
tree | ac9d4fafa4b7713b1976b385a5339a7a310d083c | |
parent | a523b613248983b8f968a49757506ab29fda22da (diff) | |
download | org.eclipse.linuxtools-01a431464928d1f6af099cd35109dd4eeb1accae.tar.gz org.eclipse.linuxtools-01a431464928d1f6af099cd35109dd4eeb1accae.tar.xz org.eclipse.linuxtools-01a431464928d1f6af099cd35109dd4eeb1accae.zip |
Generalize ITmfTrace API (part 1)
15 files changed, 33 insertions, 27 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngExperiment.java b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngExperiment.java index 9eb3f036ff..c56ec33e1e 100644 --- a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngExperiment.java +++ b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngExperiment.java @@ -29,6 +29,7 @@ import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; @@ -108,7 +109,7 @@ public class LTTngExperiment<T extends ITmfEvent> extends TmfExperiment<T> { // ------------------------------------------------------------------------ @Override - public synchronized ITmfEvent getNextEvent(TmfContext context) { + public synchronized ITmfEvent getNextEvent(ITmfContext context) { // Validate the context if (!(context instanceof TmfExperimentContext)) { diff --git a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java index 29f884c46b..0691a7521d 100644 --- a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java +++ b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java @@ -24,6 +24,7 @@ import org.eclipse.linuxtools.lttng.core.event.LttngEventType; import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; @@ -201,7 +202,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> { return 0; } - private LttngEvent parseMyNextEvent(TmfContext context) { + private LttngEvent parseMyNextEvent(ITmfContext context) { // All parsing variables declared here so to be able to print them into the catch if needed String tmpContent = null; @@ -428,7 +429,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> { } @Override - public LttngEvent parseEvent(TmfContext context) { + public LttngEvent parseEvent(ITmfContext context) { context = seekLocation(context.getLocation()); return parseMyNextEvent(context); diff --git a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTrace.java b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTrace.java index 1c3ec8f7fc..5e0dea3527 100644 --- a/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTrace.java +++ b/lttng/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTrace.java @@ -648,7 +648,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> { public int nbEventsRead = 0; @Override - public synchronized LttngEvent getNextEvent(TmfContext context) { + public synchronized LttngEvent getNextEvent(ITmfContext context) { if (PrintDebug) { System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$ @@ -706,7 +706,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> { } // this method was extracted for profiling purposes - private void setPreviousAndCurrentTimes(TmfContext context, LttngEvent returnedEvent, LttngLocation curLocation) { + private void setPreviousAndCurrentTimes(ITmfContext context, LttngEvent returnedEvent, LttngLocation curLocation) { ITmfTimestamp eventTimestamp = returnedEvent.getTimestamp(); // long eventTime = eventTimestamp.getValue(); @@ -758,7 +758,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> { } // this method was extracted for profiling purposes - private LttngLocation getCurrentLocation(TmfContext context) { + private LttngLocation getCurrentLocation(ITmfContext context) { LttngLocation curLocation; curLocation = new LttngLocation(); context.setLocation(curLocation); @@ -779,7 +779,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> { * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext */ @Override - public synchronized LttngEvent parseEvent(TmfContext context) { + public synchronized LttngEvent parseEvent(ITmfContext context) { if (PrintDebug) { System.out.println("parseEvent(context) context.getLocation() -> " //$NON-NLS-1$ diff --git a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java index 19cdb761f9..fa02e933d9 100644 --- a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java +++ b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java @@ -17,8 +17,8 @@ import java.io.IOException; import org.eclipse.linuxtools.lttng.core.event.LttngEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfContext; /** * <b><u>TmfEventParserStub</u></b> @@ -31,7 +31,7 @@ public class LTTngEventParserStub implements ITmfEventParser<LttngEvent> { * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext) */ @Override - public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, TmfContext context) + public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, ITmfContext context) throws IOException { // TODO Auto-generated method stub return null; diff --git a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java index 34545326de..8612fffff8 100644 --- a/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java +++ b/lttng/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java @@ -19,6 +19,7 @@ import java.io.RandomAccessFile; import org.eclipse.linuxtools.lttng.core.event.LttngEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; +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.TmfContext; @@ -145,7 +146,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> { * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent() */ @Override - public ITmfEvent parseEvent(TmfContext context) { + public ITmfEvent parseEvent(ITmfContext context) { try { // paserNextEvent updates the context LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context); diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java index a6a8128984..ea246f00c2 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java +++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java @@ -24,8 +24,8 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; /** @@ -68,7 +68,7 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> { static final String typePrefix = "Type-"; @Override @SuppressWarnings("unchecked") - public ITmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, TmfContext context) throws IOException { + public ITmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, ITmfContext context) throws IOException { if (! (eventStream instanceof TmfTraceStub)) { return null; diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfTraceStub.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfTraceStub.java index df3c312067..47750f8e4d 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfTraceStub.java +++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfTraceStub.java @@ -223,7 +223,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> { } @Override - public ITmfEvent parseEvent(TmfContext context) { + public ITmfEvent parseEvent(ITmfContext context) { fLock.lock(); try { // parseNextEvent will update the context diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java index b7197a3034..864cd9c03c 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java @@ -557,7 +557,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl // } @Override - public synchronized ITmfEvent getNextEvent(TmfContext context) { + public synchronized ITmfEvent getNextEvent(ITmfContext context) { // Validate the context if (!(context instanceof TmfExperimentContext)) { @@ -655,7 +655,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl * @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)) { diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java index 6c955d97cd..0ba4f3180b 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java @@ -15,8 +15,8 @@ package org.eclipse.linuxtools.tmf.core.parser; import java.io.IOException; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfContext; /** * <b><u>ITmfEventParser</u></b> @@ -29,5 +29,5 @@ public interface ITmfEventParser<T extends ITmfEvent> { * @return * @throws IOException */ - public ITmfEvent parseNextEvent(ITmfTrace<T> stream, TmfContext context) throws IOException; + public ITmfEvent parseNextEvent(ITmfTrace<T> stream, ITmfContext context) throws IOException; } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfContext.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfContext.java index caca47b86b..4606ef1eeb 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfContext.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfContext.java @@ -17,7 +17,7 @@ package org.eclipse.linuxtools.tmf.core.trace; * <p> * This is a place-holder for the context objects. */ -public interface ITmfContext { +public interface ITmfContext extends Cloneable { public long UNKNOWN_RANK = -2L; public long INITIAL_RANK = -1L; @@ -36,4 +36,7 @@ public interface ITmfContext { public void updateRank(int rank); public boolean isValidRank(); + + public ITmfContext clone(); + } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java index c79e215600..d798b1ba73 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java @@ -128,13 +128,13 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfComponent { * * @return the next event in the stream */ - public ITmfEvent getNextEvent(TmfContext context); + public ITmfEvent getNextEvent(ITmfContext context); /** * Return the event pointed by the supplied context (or null if no event left) and *does not* update the context. * * @return the next event in the stream */ - public ITmfEvent parseEvent(TmfContext context); + public ITmfEvent parseEvent(ITmfContext context); } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java index caa07fca9c..25a662f58f 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java @@ -408,7 +408,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T> * linuxtools.tmf.trace.ITmfTrace.TraceContext) */ @Override - public synchronized ITmfEvent getNextEvent(TmfContext context) { + public synchronized ITmfEvent getNextEvent(ITmfContext context) { // parseEvent() does not update the context ITmfEvent event = parseEvent(context); if (event != null) { diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java index 98b6e6dc23..a0df87c855 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java @@ -21,8 +21,8 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; +import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; import org.eclipse.linuxtools.tmf.stubs.trace.TmfTraceStub; @@ -30,7 +30,7 @@ public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> { @Override @SuppressWarnings({ "unchecked", "nls" }) - public TmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, TmfContext context) throws IOException { + public TmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, ITmfContext context) throws IOException { if (! (eventStream instanceof TmfTraceStub)) { return null; } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java index 63f4876e09..7f4a0b3424 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -147,7 +147,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> { }
@Override
- public synchronized TmfEvent getNextEvent(TmfContext context) {
+ public synchronized TmfEvent getNextEvent(ITmfContext context) {
ITmfContext savedContext = context.clone();
TmfEvent event = parseEvent(context);
if (event != null) {
@@ -158,7 +158,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> { }
@Override
- public TmfEvent parseEvent(TmfContext tmfContext) {
+ public TmfEvent parseEvent(ITmfContext tmfContext) {
if (!(tmfContext instanceof CustomTxtTraceContext)) {
return null;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java index 5db3458595..9c5ec541d7 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -157,7 +157,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> { }
@Override
- public synchronized TmfEvent getNextEvent(TmfContext context) {
+ public synchronized TmfEvent getNextEvent(ITmfContext context) {
ITmfContext savedContext = context.clone();
TmfEvent event = parseEvent(context);
if (event != null) {
@@ -168,7 +168,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> { }
@Override
- public TmfEvent parseEvent(TmfContext tmfContext) {
+ public TmfEvent parseEvent(ITmfContext tmfContext) {
if (!(tmfContext instanceof CustomXmlTraceContext)) {
return null;
}
|