ctf: expose stream in CtfTmfEvent
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 16 Dec 2015 03:16:11 +0000 (22:16 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 17 Dec 2015 00:54:31 +0000 (19:54 -0500)
This allows one to access the stream number. It may lead to improved UX later.
The stream ID can allow analyses to know which stream an event is coming
from. If a trace has a control channel and a data channel, this will
allow the events to be easily filtered into the appropriate views.

Change-Id: Iba9de10d9f1f633deed6df81c0d849acf5a3aceb
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/62779
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java

index a856e0835807e26ef8f1de1a8832db509dc483c0..9d3048ba9da2592e4d27773c473b0fcd692ba286 100644 (file)
@@ -27,6 +27,7 @@ import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
 import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
+import org.eclipse.tracecompass.ctf.core.trace.ICTFStream;
 import org.eclipse.tracecompass.tmf.core.event.ITmfCustomAttributes;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
@@ -71,7 +72,9 @@ public class CtfTmfEvent extends TmfEvent
     private final int fSourceCpu;
     private final String fChannel;
 
-    /** Field to override {@link TmfEvent#getName()}, to bypass the type-getting */
+    /**
+     * Field to override {@link TmfEvent#getName()}, to bypass the type-getting
+     */
     private final String fEventName;
 
     /** Lazy-loaded field containing the event's payload */
@@ -80,6 +83,8 @@ public class CtfTmfEvent extends TmfEvent
     /** Lazy-loaded field for the type, overriding TmfEvent's field */
     private transient @Nullable CtfTmfEventType fEventType;
 
+    private final @Nullable ICTFStream fStream;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -133,6 +138,7 @@ public class CtfTmfEvent extends TmfEvent
         fEventName = checkNotNull(declaration.getName());
         fEvent = eventDefinition;
         fChannel = channel;
+        fStream = fEvent.getDeclaration().getStream();
     }
 
     /**
@@ -157,6 +163,7 @@ public class CtfTmfEvent extends TmfEvent
         fEventDeclaration = null;
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
+        fStream = null;
     }
 
     /**
@@ -174,6 +181,7 @@ public class CtfTmfEvent extends TmfEvent
         fEventDeclaration = null;
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
+        fStream = null;
     }
 
     // ------------------------------------------------------------------------
@@ -210,6 +218,20 @@ public class CtfTmfEvent extends TmfEvent
         return getChannel();
     }
 
+    /**
+     * Get the stream Id
+     *
+     * @return the stream ID or -1 if the stream is null
+     * @since 2.0
+     */
+    public long getStreamId() {
+        ICTFStream stream = fStream;
+        if (stream == null) {
+            return -1;
+        }
+        return stream.getId();
+    }
+
     // ------------------------------------------------------------------------
     // TmfEvent
     // ------------------------------------------------------------------------
This page took 0.025708 seconds and 5 git commands to generate.