Added reference to parent tracefile in events to ease operation in the state system
authorWilliam Bourque <william.bourque@polymtl.ca>
Tue, 23 Mar 2010 18:22:05 +0000 (18:22 +0000)
committerWilliam Bourque <william.bourque@polymtl.ca>
Tue, 23 Mar 2010 18:22:05 +0000 (18:22 +0000)
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java

index a257b3b80c1309beaa162928510d8cb884d38f2c..44f161ac51330fd3bdfba96a9774f5953e7d8bec 100644 (file)
@@ -3,6 +3,7 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.lttng.jni.JniEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
+import org.eclipse.linuxtools.tmf.trace.TmfTrace;
 
 /**
  * <b><u>LttngEvent</u></b><p>
@@ -16,7 +17,10 @@ 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;
+    
     /**
      * Constructor with parameters.<p>
      * 
@@ -34,11 +38,12 @@ public class LttngEvent extends TmfEvent {
      * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
      * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
      */
-    public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { 
+    public LttngEvent(TmfTrace<LttngEvent> parent, LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { 
         super(timestamp, source, type, reference);
         
         fContent = content;
         jniEventReference = lttEvent;
+        setParentTrace(parent);
     }
     
     /**
@@ -47,7 +52,9 @@ public class LttngEvent extends TmfEvent {
      * @param oldEvent         Event we want to copy from.
      */
     public LttngEvent(LttngEvent oldEvent) {
-        this(  (LttngTimestamp)oldEvent.getTimestamp(), 
+        this(  
+                       oldEvent.getParentTrace(),
+                       (LttngTimestamp)oldEvent.getTimestamp(), 
                        (TmfEventSource)oldEvent.getSource(), 
                        (LttngEventType)oldEvent.getType(), 
                        (LttngEventContent)oldEvent.getContent(), 
@@ -58,6 +65,25 @@ public class LttngEvent extends TmfEvent {
     
     
     /**
+     * Return the parent trace asoociated 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;
+       }
+    
+    
+       /**
      * Return the channel name of this event.<p>
      * 
      * @return Channel (tracefile) for this event
@@ -84,19 +110,6 @@ public class LttngEvent extends TmfEvent {
         return ( (LttngEventType)this.getType() ).getMarkerName();
     }
     
-    /**
-     * Set a new JniReference for this event.<p>
-     * 
-     * Note : Reference is used to get back to the Jni during event parsing and need to be consistent.
-     * 
-     * @param newJniEventReference     New reference
-     * 
-     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
-     */
-    public void updateJniEventReference(JniEvent newJniEventReference) {
-        this.jniEventReference = newJniEventReference;
-    }
-    
     @Override
     public LttngEventContent getContent() {
         return (LttngEventContent)fContent;
@@ -115,6 +128,18 @@ public class LttngEvent extends TmfEvent {
         fType = newType;
     }
     
+    /**
+     * Set a new JniReference for this event.<p>
+     * 
+     * Note : Reference is used to get back to the Jni during event parsing and need to be consistent.
+     * 
+     * @param newJniEventReference     New reference
+     * 
+     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+     */
+    public void updateJniEventReference(JniEvent newJniEventReference) {
+        this.jniEventReference = newJniEventReference;
+    }
     
     /**
      * Convert this event into a Jni JniEvent.<p>
index 5c3595ab636cd74dd8e9ed44dbbaf5a1d4217d22..5b09ffbdc2f98e8fd239f44bf2d2076cec43e2e3 100644 (file)
@@ -71,7 +71,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> implements ITmfTrace {
         eventContent          = new TextLttngEventContent(currentLttngEvent);
         eventReference        = new LttngEventReference(this.getName());
         
-        currentLttngEvent = new TextLttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference);
+        currentLttngEvent = new TextLttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference);
         eventContent.setEvent(currentLttngEvent);
         
         if ( positionToFirstEvent() == false ) {
@@ -425,17 +425,19 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> implements ITmfTrace {
 // Redefine event to override method we know won't work with a Text tracefile 
 class TextLttngEvent extends LttngEvent {
        
-       public TextLttngEvent(  LttngTimestamp timestamp, 
+       public TextLttngEvent(  TmfTrace<LttngEvent> parent,
+                                                       LttngTimestamp timestamp, 
                                                        LttngEventSource source, 
                                                        LttngEventType type, 
                                                        LttngEventContent content, 
                                                        LttngEventReference reference) 
        {
-               super(timestamp, source, type, content, reference, null);
+               super(parent, timestamp, source, type, content, reference, null);
        }
        
        public TextLttngEvent(TextLttngEvent oldEvent) {
                this(
+                               oldEvent.getParentTrace(),
                                (LttngTimestamp)oldEvent.getTimestamp(), 
                                (LttngEventSource)oldEvent.getSource(), 
                                (LttngEventType)oldEvent.getType(), 
index 395b3aff720cc0ab5abec950f734358e624c4337..bd6a0213919628982201da0b5f48156deeeeed5a 100644 (file)
@@ -147,7 +147,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         eventReference        = new LttngEventReference(this.getName());
         
         // Create the skeleton event
-        currentLttngEvent = new LttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
+        currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
         
         // Create a new current location
         previousLocation = new LttngLocation();
@@ -729,7 +729,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         eventReference        = new LttngEventReference(jniEvent.getParentTracefile().getTracefilePath(), this.getName());
         eventType             = new LttngEventType(traceTypes.get( EventTypeKey.getEventTypeKey(jniEvent) ));
         eventContent          = new LttngEventContent(currentLttngEvent);
-        currentLttngEvent = new LttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
+        currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
         
         // The jni reference is no longer reliable but we will keep it anyhow
         currentLttngEvent.updateJniEventReference(jniEvent);
This page took 0.030614 seconds and 5 git commands to generate.