1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
;
14 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.state
.model
.LttngTraceState
;
15 import org
.eclipse
.linuxtools
.lttng
.jni
.JniEvent
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
23 public class LttngSyntheticEvent
extends LttngEvent
{
25 public static final LttngSyntheticEvent NullEvent
= new LttngSyntheticEvent();
27 // ======================================================================+
29 // =======================================================================
32 * BEFORE: Before the update to the state system
35 * UPDATE: Proceed to update the state system
38 * AFTER: After the update of the state system
41 * ACK: Acknowledge indicator for any of the previous sequences
44 public enum SequenceInd
{
45 STARTREQ
, BEFORE
, UPDATE
, AFTER
, ENDREQ
48 private SequenceInd sequence
= SequenceInd
.BEFORE
;
49 private LttngEvent baseEvent
= null;
50 private LttngTraceState fTraceModel
= null;
51 // ======================================================================+
53 // =======================================================================
57 public LttngSyntheticEvent(ITmfEvent baseEvent
) {
59 this.baseEvent
= (LttngEvent
) baseEvent
;
71 public LttngSyntheticEvent(TmfTrace parent
,
72 LttngTimestamp timestamp
, String source
,
73 LttngEventType type
, LttngEventContent content
,
74 String reference
, JniEvent lttEvent
) {
75 super(parent
, timestamp
, source
, type
, content
, reference
, lttEvent
);
78 private LttngSyntheticEvent() {
79 this(null, null, null, null, null, null, null);
82 // ======================================================================+
84 // =======================================================================
87 * @return the sequence indicator
89 public SequenceInd
getSynType() {
95 * the sequence indicator to set
97 public void setSequenceInd(SequenceInd sequence
) {
98 this.sequence
= sequence
;
102 * @return the baseEvent
104 public LttngEvent
getBaseEvent() {
110 * the trace state-data-model associated to this event
112 public void setTraceModel(LttngTraceState traceModel
) {
113 this.fTraceModel
= traceModel
;
117 * @return the traceModel
119 public LttngTraceState
getTraceModel() {
126 * @see org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent#getTrace()
129 public TmfTrace
getTrace() {
130 if (baseEvent
!= null) {
131 return (TmfTrace
) baseEvent
.getTrace();
133 return (TmfTrace
) super.getTrace();
141 * org.eclipse.linuxtools.lttng.event.LttngEvent#setParentTrace(org.eclipse
142 * .linuxtools.tmf.trace.TmfTrace)
145 public void setParentTrace(TmfTrace parentTrace
) {
146 if (baseEvent
!= null) {
147 baseEvent
.setParentTrace(parentTrace
);
149 super.setParentTrace(parentTrace
);
156 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getChannelName()
159 public String
getChannelName() {
160 if (baseEvent
!= null) {
161 return baseEvent
.getChannelName();
163 return super.getChannelName();
170 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getCpuId()
173 public long getCpuId() {
174 if (baseEvent
!= null) {
175 return baseEvent
.getCpuId();
177 return super.getCpuId();
184 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getMarkerName()
187 public String
getMarkerName() {
188 if (baseEvent
!= null) {
189 return baseEvent
.getMarkerName();
191 return super.getMarkerName();
198 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getContent()
201 public LttngEventContent
getContent() {
202 if (baseEvent
!= null) {
203 return baseEvent
.getContent();
205 return super.getContent();
213 * org.eclipse.linuxtools.lttng.event.LttngEvent#setContent(org.eclipse.
214 * linuxtools.lttng.event.LttngEventContent)
217 public void setContent(LttngEventContent newContent
) {
218 if (baseEvent
!= null) {
219 baseEvent
.setContent(newContent
);
221 super.setContent(newContent
);
228 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#getType()
231 public LttngEventType
getType() {
232 if (baseEvent
!= null) {
233 return baseEvent
.getType();
235 return super.getType();
243 * org.eclipse.linuxtools.lttng.event.LttngEvent#setType(org.eclipse.linuxtools
244 * .lttng.event.LttngEventType)
247 public void setType(LttngEventType newType
) {
248 if (baseEvent
!= null) {
249 baseEvent
.setType(newType
);
251 super.setType(newType
);
259 * org.eclipse.linuxtools.lttng.event.LttngEvent#updateJniEventReference
260 * (org.eclipse.linuxtools.lttng.jni.JniEvent)
263 public void updateJniEventReference(JniEvent newJniEventReference
) {
264 if (baseEvent
!= null) {
265 baseEvent
.updateJniEventReference(newJniEventReference
);
267 super.updateJniEventReference(newJniEventReference
);
274 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#convertEventTmfToJni()
277 public JniEvent
convertEventTmfToJni() {
278 if (baseEvent
!= null) {
279 return baseEvent
.convertEventTmfToJni();
281 return super.convertEventTmfToJni();
288 * @see org.eclipse.linuxtools.lttng.event.LttngEvent#toString()
291 public String
toString() {
292 if (baseEvent
!= null) {
293 return baseEvent
.toString();
295 return super.toString();
300 * @see java.lang.Object#hashCode()
303 public int hashCode() {
304 final int prime
= 31;
305 int result
= super.hashCode();
306 result
= prime
* result
+ ((baseEvent
== null) ?
0 : baseEvent
.hashCode());
307 result
= prime
* result
+ ((fTraceModel
== null) ?
0 : fTraceModel
.hashCode());
308 result
= prime
* result
+ ((sequence
== null) ?
0 : sequence
.hashCode());
313 * @see java.lang.Object#equals(java.lang.Object)
316 public boolean equals(Object obj
) {
320 if (!super.equals(obj
)) {
323 if (!(obj
instanceof LttngSyntheticEvent
)) {
326 LttngSyntheticEvent other
= (LttngSyntheticEvent
) obj
;
327 if (baseEvent
== null) {
328 if (other
.baseEvent
!= null) {
331 } else if (!baseEvent
.equals(other
.baseEvent
)) {
334 if (fTraceModel
== null) {
335 if (other
.fTraceModel
!= null) {
338 } else if (!fTraceModel
.equals(other
.fTraceModel
)) {
341 if (sequence
!= other
.sequence
) {