Add a trace reference to the base event structure (fix for Bug360566)
authorFrancois Chouinard <fchouinard@gmail.com>
Tue, 11 Oct 2011 17:00:47 +0000 (13:00 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Tue, 11 Oct 2011 17:00:47 +0000 (13:00 -0400)
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngSyntheticEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java

index 704db6f6e6f0f341ff071b3bbbad9b1b22a70276..554ed21ee0483f6cda2b69e4e4bb351d9cb2916f 100644 (file)
@@ -45,7 +45,6 @@ import org.eclipse.linuxtools.tmf.trace.ITmfContext;
 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint;
 import org.eclipse.linuxtools.tmf.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.trace.TmfTrace;
 
 /**
  * @author alvaro
@@ -243,7 +242,7 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
                        private void handleIncomingData(LttngEvent e) {
                                long eventTime = e.getTimestamp().getValue();
 
-                               TmfTrace<LttngEvent> inTrace = e.getParentTrace();
+                               ITmfTrace inTrace = e.getParentTrace();
                                LttngTraceState traceModel = traceToTraceStateModel.get(inTrace);
                                
                                // queue the new event data
@@ -289,7 +288,7 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
                                        syntheticEvent = new LttngSyntheticEvent(e);
                                }
 
-                               TmfTrace<LttngEvent> inTrace = e.getParentTrace();
+                               ITmfTrace inTrace = e.getParentTrace();
                                LttngTraceState traceModel = traceToTraceStateModel.get(inTrace);
                                
                                // Trace model needed by application handlers
index ed73c7a2d0d9902ec5e053ff808c00d0c59cd1df..c07809a2eed1fcbf1dbcc74599045777666352f0 100644 (file)
@@ -18,8 +18,8 @@ public class LttngEvent extends TmfEvent {
     // Reference to the JNI JniEvent. Should only be used INTERNALLY
     private JniEvent jniEventReference = null;
     
-    // Reference to the parent trace that own this event
-    private TmfTrace<LttngEvent> parentTrace = null;
+//    // Reference to the parent trace that own this event
+//    private TmfTrace<LttngEvent> parentTrace = null;
     
     /**
      * Constructor with parameters.<p>
@@ -51,9 +51,10 @@ public class LttngEvent extends TmfEvent {
      * 
      * @param oldEvent         Event we want to copy from.
      */
+    @SuppressWarnings("unchecked")
     public LttngEvent(LttngEvent oldEvent) {
         this(  
-                       oldEvent.getParentTrace(),
+                       (TmfTrace<LttngEvent>) oldEvent.getParentTrace(),
                        (LttngTimestamp)oldEvent.getTimestamp(), 
                        (TmfEventSource)oldEvent.getSource(), 
                        (LttngEventType)oldEvent.getType(), 
@@ -63,23 +64,13 @@ public class LttngEvent extends TmfEvent {
                );
     }
     
-    
-    /**
-     * Return the parent trace associated with this event
-     * 
-     * @return Parent trace
-     */
-    public TmfTrace<LttngEvent> getParentTrace() {
-               return parentTrace;
-       }
-    
     /**
      * Set a new parent trace for this event
      * 
      * @param parentTrace      The new parent
      */
     public void setParentTrace(TmfTrace<LttngEvent> parentTrace) {
-               this.parentTrace = parentTrace;
+               fParentTrace = parentTrace;
        }
     
     
@@ -194,7 +185,6 @@ public class LttngEvent extends TmfEvent {
        public LttngEvent clone() {
        LttngEvent clone = (LttngEvent) super.clone();
        clone.getContent().setEvent(clone);
-               clone.parentTrace = parentTrace;
                clone.jniEventReference = jniEventReference;
        return clone;
     }
index 92a45a8cb37a10c4a00d5020ca7161f961cd2020..2f1526975f298888284ecbe934af42f27cc99411 100644 (file)
@@ -125,12 +125,13 @@ public class LttngSyntheticEvent extends LttngEvent {
         * 
         * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getParentTrace()
         */
-       @Override
+       @SuppressWarnings("unchecked")
+    @Override
    public TmfTrace<LttngEvent> getParentTrace() {
                if (baseEvent != null) {
-                       return baseEvent.getParentTrace();
+                       return (TmfTrace<LttngEvent>) baseEvent.getParentTrace();
                } else {
-                       return super.getParentTrace();
+                       return (TmfTrace<LttngEvent>) super.getParentTrace();
                }
        }
 
index 007316923f27735acb0812c5d03d1e2ecba31936..a7510c65acfd4261ebf8a1bc7c84aa8d8186f0cf 100644 (file)
@@ -461,9 +461,10 @@ class TextLttngEvent extends LttngEvent {
                super(parent, timestamp, source, type, content, reference, null);
        }
        
-       public TextLttngEvent(TextLttngEvent oldEvent) {
+       @SuppressWarnings("unchecked")
+    public TextLttngEvent(TextLttngEvent oldEvent) {
                this(
-                               oldEvent.getParentTrace(),
+                       (TmfTrace<LttngEvent>) oldEvent.getParentTrace(),
                                (LttngTimestamp)oldEvent.getTimestamp(), 
                                (LttngEventSource)oldEvent.getSource(), 
                                (LttngEventType)oldEvent.getType(), 
index c52fc495385240268b460414b3dbe8008026b3b1..597a4d94d2a7b8f8cdd70be9a55d4c8558138ea4 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.linuxtools.tmf.event;
 
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+
 /**
  * <b><u>TmfEvent</u></b>
  * <p>
@@ -41,6 +43,8 @@ public class TmfEvent extends TmfData implements Cloneable {
     // Attributes
     // ------------------------------------------------------------------------
 
+       protected ITmfTrace         fParentTrace;
+       protected long              fEventRank;
        protected TmfTimestamp      fEffectiveTimestamp;
        protected TmfTimestamp      fOriginalTimestamp;
        protected TmfEventSource    fSource;
@@ -55,6 +59,25 @@ public class TmfEvent extends TmfData implements Cloneable {
     // Constructors
     // ------------------------------------------------------------------------
 
+    /**
+     * @param originalTS the original timestamp
+     * @param effectiveTS the effective timestamp
+     * @param source the event source (generator)
+     * @param type the event type
+     * @param reference a free-form reference field
+     */
+    public TmfEvent(ITmfTrace trace, long rank, TmfTimestamp originalTS, TmfTimestamp effectiveTS,
+            TmfEventSource source, TmfEventType type, TmfEventReference reference)
+    {
+        fParentTrace        = trace;
+        fEventRank          = rank;
+        fOriginalTimestamp  = originalTS;
+        fEffectiveTimestamp = effectiveTS;
+        fSource             = source;
+        fType               = type;
+        fReference          = reference;
+    }
+
        /**
         * @param originalTS the original timestamp
         * @param effectiveTS the effective timestamp
@@ -65,11 +88,7 @@ public class TmfEvent extends TmfData implements Cloneable {
        public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS,
                        TmfEventSource source, TmfEventType type, TmfEventReference reference)
        {
-               fOriginalTimestamp  = originalTS;
-               fEffectiveTimestamp = effectiveTS;
-               fSource             = source;
-               fType               = type;
-               fReference          = reference;
+        this(null, -1, originalTS, effectiveTS, source, type, reference);
        }
 
        /**
@@ -81,7 +100,7 @@ public class TmfEvent extends TmfData implements Cloneable {
        public TmfEvent(TmfTimestamp timestamp, TmfEventSource source,
                        TmfEventType type, TmfEventReference reference)
        {
-               this(timestamp, timestamp, source, type, reference);
+               this(null, -1, timestamp, timestamp, source, type, reference);
        }
 
        /**
@@ -92,6 +111,8 @@ public class TmfEvent extends TmfData implements Cloneable {
        public TmfEvent(TmfEvent other) {
        if (other == null)
                throw new IllegalArgumentException();
+        fParentTrace        = other.fParentTrace;
+        fEventRank          = other.fEventRank;
                fOriginalTimestamp  = new TmfTimestamp(other.fOriginalTimestamp);
                fEffectiveTimestamp = new TmfTimestamp(other.fEffectiveTimestamp);
                fSource                         = new TmfEventSource(other.fSource);
@@ -112,6 +133,20 @@ public class TmfEvent extends TmfData implements Cloneable {
     // Accessors
     // ------------------------------------------------------------------------
 
+    /**
+     * @return the parent trace
+     */
+    public ITmfTrace getParentTrace() {
+        return fParentTrace;
+    }
+
+    /**
+     * @return the event rank
+     */
+    public long getEventRank() {
+        return fEventRank;
+    }
+
        /**
         * @return the effective event timestamp
         */
@@ -206,6 +241,8 @@ public class TmfEvent extends TmfData implements Cloneable {
                TmfEvent clone = null;
                try {
                        clone = (TmfEvent) super.clone();
+                       clone.fParentTrace        = fParentTrace;
+                       clone.fEventRank          = fEventRank;
                        clone.fOriginalTimestamp  = fOriginalTimestamp.clone();
                        clone.fEffectiveTimestamp = fEffectiveTimestamp.clone();
                        clone.fSource             = fSource.clone();
This page took 0.02857 seconds and 5 git commands to generate.