Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2014-03-12 16:52:01 -0400
committerMatthew Khouzam2014-05-09 13:44:57 -0400
commit5c47c9d842ab8445918311972f8f41e7588aca4b (patch)
treeeb023c1f01414131b60d4887c01713f2f54a0dfe
parent9a711c04622dab8ce942b448ad185d3a32a864e7 (diff)
downloadorg.eclipse.linuxtools-5c47c9d842ab8445918311972f8f41e7588aca4b.tar.gz
org.eclipse.linuxtools-5c47c9d842ab8445918311972f8f41e7588aca4b.tar.xz
org.eclipse.linuxtools-5c47c9d842ab8445918311972f8f41e7588aca4b.zip
ctf: get iterable of stream input readers
This patch adds a way to get all event declarations from a CTFTraceReader Change-Id: If12805ba6436ab5f5ce562686f5870c0fbf05261 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/23284
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java18
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java13
2 files changed, 31 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
index 75a042604c..e640bc32c7 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
@@ -20,9 +20,13 @@ import java.util.PriorityQueue;
import java.util.Set;
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
+import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
import org.eclipse.linuxtools.internal.ctf.core.Activator;
import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputReaderTimestampComparator;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
/**
* A CTF trace reader. Reads the events of a trace.
*
@@ -249,6 +253,20 @@ public class CTFTraceReader implements AutoCloseable {
}
/**
+ * Gets an iterable of the stream input readers, useful for foreaches
+ *
+ * @return the iterable of the stream input readers
+ * @since 3.0
+ */
+ public Iterable<IEventDeclaration> getEventDeclarations() {
+ ImmutableSet.Builder<IEventDeclaration> builder = new Builder<>();
+ for (StreamInputReader sir : fStreamInputReaders) {
+ builder.addAll(sir.getEventDeclarations());
+ }
+ return builder.build();
+ }
+
+ /**
* Initializes the priority queue used to choose the trace file with the
* lower next event timestamp.
*
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
index bcc65573d5..e0f7c1624e 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
@@ -15,9 +15,12 @@ package org.eclipse.linuxtools.ctf.core.trace;
import java.nio.ByteOrder;
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
+import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndexEntry;
+import com.google.common.collect.ImmutableSet;
+
/**
* A CTF trace event reader. Reads the events of a trace file.
*
@@ -166,6 +169,16 @@ public class StreamInputReader implements AutoCloseable {
}
/**
+ * Gets the event definition set for this StreamInput
+ *
+ * @return Unmodifiable set with the event definitions
+ * @since 3.0
+ */
+ public Iterable<IEventDeclaration> getEventDeclarations() {
+ return ImmutableSet.copyOf(fStreamInput.getStream().getEvents().values());
+ }
+
+ /**
* Set the trace to live mode
*
* @param live

Back to the top