ctf: make CtfTmfEvent expose packet context attributes
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 2 Dec 2015 21:04:59 +0000 (16:04 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 17 Dec 2015 00:54:36 +0000 (19:54 -0500)
This patch allows acces to the packet context of an event from that
event.

Change-Id: I8409c8fbcb7766a2d7be4104159a7d7de6aa188d
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/61817
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 9d3048ba9da2592e4d27773c473b0fcd692ba286..29f0d6a14e430c5c7c02cf4abcc599f444afcda1 100644 (file)
@@ -16,8 +16,10 @@ package org.eclipse.tracecompass.tmf.ctf.core.event;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -84,6 +86,7 @@ public class CtfTmfEvent extends TmfEvent
     private transient @Nullable CtfTmfEventType fEventType;
 
     private final @Nullable ICTFStream fStream;
+    private final Map<String, Object> fPacketAttributes;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -139,6 +142,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = eventDefinition;
         fChannel = channel;
         fStream = fEvent.getDeclaration().getStream();
+        fPacketAttributes = eventDefinition.getPacketAttributes();
     }
 
     /**
@@ -164,6 +168,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
         fStream = null;
+        fPacketAttributes = Collections.EMPTY_MAP;
     }
 
     /**
@@ -182,6 +187,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
         fStream = null;
+        fPacketAttributes = Collections.EMPTY_MAP;
     }
 
     // ------------------------------------------------------------------------
@@ -333,6 +339,19 @@ public class CtfTmfEvent extends TmfEvent
         return getCustomAttribute(CtfConstants.MODEL_URI_KEY);
     }
 
+    /**
+     * Gets the packet attributes. The result is an instance of one of
+     * the following classes: <code>Entry<String, Long></code>, <code>Long</code>,
+     * <code>String</code> or <code>Double</code>. The map contains pairs of key and
+     * values where the key and value can never be null.
+     *
+     * @return gets the packet attributes
+     * @since 2.0
+     */
+    public Map<String, Object> getPacketAttributes() {
+        return fPacketAttributes;
+    }
+
     // ------------------------------------------------------------------------
     // Object
     // ------------------------------------------------------------------------
This page took 0.026854 seconds and 5 git commands to generate.