Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | package org.eclipse.linuxtools.lttng.event; |
2 | ||
5d10d135 | 3 | import org.eclipse.linuxtools.tmf.event.TmfEvent; |
146a887c FC |
4 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; |
5 | import org.eclipse.linuxtools.lttng.jni.JniEvent; | |
5d10d135 ASL |
6 | |
7 | /** | |
146a887c FC |
8 | * <b><u>LttngEvent</u></b> |
9 | * <p> | |
10 | * Lttng specific TmfEvent implementation | |
11 | * <p> | |
12 | * The main difference from the basic Tmf implementation is that we keep an internal reference to the Jni JniEvent<br> | |
13 | * The conversion from this LttngEvent to the JniEvent is then possible. | |
14 | * </ul> | |
5d10d135 | 15 | */ |
146a887c | 16 | @SuppressWarnings("unused") |
5d10d135 | 17 | public class LttngEvent extends TmfEvent { |
146a887c FC |
18 | // Reference to the JNI JniEvent. Should only used INTERNALLY |
19 | JniEvent jniEventReference = null; | |
5d10d135 | 20 | |
5d10d135 | 21 | /** |
146a887c FC |
22 | * Constructor with parameters <br> |
23 | * <br> | |
5d10d135 ASL |
24 | * |
25 | * @param timestamp The timestamp of this event | |
26 | * @param source The source of this event | |
27 | * @param type The type of this event | |
28 | * @param content The content of this event | |
29 | * @param reference The reference of this event | |
30 | * @param lttEvent A reference to a valid JniEvent object | |
31 | * | |
32 | * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp | |
146a887c | 33 | * @see org.eclipse.linuxtools.lttng.event.LttngEventSource |
5d10d135 ASL |
34 | * @see org.eclipse.linuxtools.lttng.event.LttngEventType |
35 | * @see org.eclipse.linuxtools.lttng.event.LttngEventContent | |
36 | * @see org.eclipse.linuxtools.lttng.event.LttngEventReference | |
146a887c FC |
37 | * @see org.eclipse.linuxtools.lttng.jni.JniEvent |
38 | * | |
5d10d135 | 39 | */ |
146a887c FC |
40 | public LttngEvent(LttngTimestamp timestamp, LttngEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { |
41 | super(timestamp, source, type, content, reference); | |
5d10d135 | 42 | |
5d10d135 | 43 | jniEventReference = lttEvent; |
5d10d135 ASL |
44 | } |
45 | ||
46 | /** | |
146a887c | 47 | * Return the channel name of this event<br> |
5d10d135 | 48 | * |
146a887c | 49 | * @return String The name of the channel |
5d10d135 ASL |
50 | */ |
51 | public String getChannelName() { | |
146a887c FC |
52 | String returnedValue = ""; |
53 | ||
54 | if ( this.getType() instanceof LttngEventType ) { | |
55 | returnedValue = ( (LttngEventType)this.getType() ).getChannelName(); | |
56 | } | |
57 | ||
58 | return returnedValue; | |
5d10d135 ASL |
59 | } |
60 | ||
61 | /** | |
146a887c | 62 | * Return the cpu id number of this event<br> |
5d10d135 | 63 | * |
146a887c | 64 | * @return long The cpu id |
5d10d135 ASL |
65 | */ |
66 | public long getCpuId() { | |
146a887c FC |
67 | long returnedValue =-1; |
68 | ||
69 | if ( this.getType() instanceof LttngEventType ) { | |
70 | returnedValue = ( (LttngEventType)this.getType() ).getCpuId(); | |
71 | } | |
72 | ||
73 | return returnedValue; | |
5d10d135 ASL |
74 | } |
75 | ||
76 | /** | |
146a887c | 77 | * Return the marker name of this event<br> |
5d10d135 | 78 | * |
146a887c | 79 | * @return String The marker name |
5d10d135 ASL |
80 | */ |
81 | public String getMarkerName() { | |
146a887c FC |
82 | String returnedValue = ""; |
83 | ||
84 | if ( this.getType() instanceof LttngEventType ) { | |
85 | returnedValue = ( (LttngEventType)this.getType() ).getMarkerName(); | |
86 | } | |
87 | ||
88 | return returnedValue; | |
5d10d135 ASL |
89 | } |
90 | ||
5d10d135 | 91 | /** |
146a887c FC |
92 | * Convert this event into a Jni JniEvent<br> |
93 | * <br> | |
94 | * Note : Some verification are done to make sure the event is still valid on the Jni side.<br> | |
95 | * If it is not the case, null will be returned. | |
5d10d135 | 96 | * |
146a887c FC |
97 | * @return JniEvent The converted event |
98 | * @see org.eclipse.linuxtools.lttng.jni.JniEvent | |
5d10d135 | 99 | */ |
88144d4a | 100 | public JniEvent convertEventTmfToJni() { |
5d10d135 ASL |
101 | JniEvent tmpEvent = null; |
102 | ||
5d10d135 ASL |
103 | // We don't want to send away events that are outdated as their informations could be invalid |
104 | // If the timestamp between the event and the trace are not coherent we will not perform the conversion | |
105 | if ( jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) { | |
106 | tmpEvent = jniEventReference; | |
107 | } | |
146a887c | 108 | |
5d10d135 ASL |
109 | return tmpEvent; |
110 | } | |
5d10d135 | 111 | } |