1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
19 import org
.eclipse
.tracecompass
.ctf
.core
.event
.EventDefinition
;
20 import org
.eclipse
.tracecompass
.ctf
.core
.event
.IEventDeclaration
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfLostEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
24 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
26 import com
.google
.common
.primitives
.Longs
;
29 * An implementation of {@link ITmfLostEvent} for use in the CTF adaptor.
31 * @author Alexandre Montplaisir
34 public class CtfTmfLostEvent
extends CtfTmfEvent
implements ITmfLostEvent
{
36 private final TmfTimeRange fTimeRange
;
37 private final long fNbLost
;
40 * Constructor. Only {@link CtfTmfEventFactory} should call this.
45 * The rank of the event in the trace
47 * The event's payload (fields). In case this event has some.
49 * The name of the trace file from which this event comes
51 * The CPU on which this event happened
53 * The CTF Event Declaration object that created this event
55 * The time range of lost events indicated by this one
57 * The number of lost events in the range
59 CtfTmfLostEvent(CtfTmfTrace trace
,
63 IEventDeclaration declaration
,
64 TmfTimeRange timeRange
,
66 EventDefinition def
) {
68 * Only the factory should call this method, the cast to
69 * (TmfNanoTimestamp) should be safe.
71 super(trace
, rank
, (TmfNanoTimestamp
) timeRange
.getStartTime(), fileName
, cpu
, declaration
, def
);
72 fTimeRange
= timeRange
;
77 public TmfTimeRange
getTimeRange() {
82 public long getNbLostEvents() {
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 public int hashCode() {
93 int result
= super.hashCode();
94 result
= prime
* result
+ getTimeRange().hashCode();
95 result
= prime
* result
+ Longs
.hashCode(getNbLostEvents());
100 public boolean equals(@Nullable Object obj
) {
101 if (!super.equals(obj
)) {
104 /* super.equals() checks that the classes are the same */
105 CtfTmfLostEvent other
= checkNotNull((CtfTmfLostEvent
) obj
);
106 if (!getTimeRange().equals(other
.getTimeRange())) {
109 if (getNbLostEvents() != other
.getNbLostEvents()) {