- Minor modification of the FW API (better trace/parser integration)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / event / LttngEvent.java
1 package org.eclipse.linuxtools.lttng.event;
2
3 import org.eclipse.linuxtools.tmf.event.TmfEvent;
4 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
5 import org.eclipse.linuxtools.lttng.jni.JniEvent;
6
7 /**
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>
15 */
16 @SuppressWarnings("unused")
17 public class LttngEvent extends TmfEvent {
18 // Reference to the JNI JniEvent. Should only used INTERNALLY
19 JniEvent jniEventReference = null;
20
21 /**
22 * Constructor with parameters <br>
23 * <br>
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
33 * @see org.eclipse.linuxtools.lttng.event.LttngEventSource
34 * @see org.eclipse.linuxtools.lttng.event.LttngEventType
35 * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
36 * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
37 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
38 *
39 */
40 public LttngEvent(LttngTimestamp timestamp, LttngEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) {
41 super(timestamp, source, type, content, reference);
42
43 jniEventReference = lttEvent;
44 }
45
46 /**
47 * Return the channel name of this event<br>
48 *
49 * @return String The name of the channel
50 */
51 public String getChannelName() {
52 String returnedValue = "";
53
54 if ( this.getType() instanceof LttngEventType ) {
55 returnedValue = ( (LttngEventType)this.getType() ).getChannelName();
56 }
57
58 return returnedValue;
59 }
60
61 /**
62 * Return the cpu id number of this event<br>
63 *
64 * @return long The cpu id
65 */
66 public long getCpuId() {
67 long returnedValue =-1;
68
69 if ( this.getType() instanceof LttngEventType ) {
70 returnedValue = ( (LttngEventType)this.getType() ).getCpuId();
71 }
72
73 return returnedValue;
74 }
75
76 /**
77 * Return the marker name of this event<br>
78 *
79 * @return String The marker name
80 */
81 public String getMarkerName() {
82 String returnedValue = "";
83
84 if ( this.getType() instanceof LttngEventType ) {
85 returnedValue = ( (LttngEventType)this.getType() ).getMarkerName();
86 }
87
88 return returnedValue;
89 }
90
91 /**
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.
96 *
97 * @return JniEvent The converted event
98 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
99 */
100 public JniEvent convertEventTmfToJni() {
101 JniEvent tmpEvent = null;
102
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 }
108
109 return tmpEvent;
110 }
111 }
This page took 0.033582 seconds and 5 git commands to generate.