/*******************************************************************************
- * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: Matthew Khouzam - Initial API and implementation
- * Contributors: Alexandre Montplaisir - Initial API and implementation
+ * Contributors:
+ * Matthew Khouzam - Initial API and implementation
+ * Alexandre Montplaisir - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.ctf.core.trace;
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
import org.eclipse.linuxtools.internal.ctf.core.Activator;
-import org.eclipse.linuxtools.internal.ctf.core.trace.Stream;
-import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInput;
import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputReaderTimestampComparator;
/**
- * Reads the events of a trace.
+ * A CTF trace reader. Reads the events of a trace.
+ *
+ * @version 1.0
+ * @author Matthew Khouzam
+ * @author Alexandre Montplaisir
*/
-
public class CTFTraceReader {
// ------------------------------------------------------------------------
*/
private long endTime;
- protected void setEndTime(long endTime) {
- this.endTime = endTime;
- }
-
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
return newReader;
}
+ /**
+ * Dispose the CTFTraceReader
+ * @since 2.0
+ */
+ public void dispose() {
+ for (StreamInputReader reader : streamInputReaders) {
+ if (reader != null) {
+ reader.dispose();
+ }
+ }
+ streamInputReaders.clear();
+ }
+
// ------------------------------------------------------------------------
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
return this.startTime;
}
+ /**
+ * Set the trace's end time
+ *
+ * @param endTime
+ * The end time to use
+ */
+ protected void setEndTime(long endTime) {
+ this.endTime = endTime;
+ }
+
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
* Add it back in the queue.
*/
this.prio.add(top);
- final long topEnd = top.getCurrentEvent().getTimestamp()
- + this.getTrace().getOffset();
+ final long topEnd = this.trace.timestampCyclesToNanos(top.getCurrentEvent().getTimestamp());
this.setEndTime(Math.max(topEnd, this.getEndTime()));
this.eventCountPerTraceFile[top.getName()]++;
}
sb.append("]\t" + this.eventCountPerTraceFile[se.getName()] + " Events"); //$NON-NLS-1$//$NON-NLS-2$
- Activator.getDefault().log(sb.toString());
+ Activator.log(sb.toString());
}
}
final int prime = 31;
int result = 1;
result = (prime * result) + (int) (startTime ^ (startTime >>> 32));
- result = (prime * result)
- + ((streamInputReaders == null) ? 0 : streamInputReaders
- .hashCode());
+ result = (prime * result) + streamInputReaders.hashCode();
result = (prime * result) + ((trace == null) ? 0 : trace.hashCode());
return result;
}
return false;
}
CTFTraceReader other = (CTFTraceReader) obj;
- if (streamInputReaders == null) {
- if (other.streamInputReaders != null) {
- return false;
- }
- } else if (!streamInputReaders.equals(other.streamInputReaders)) {
+ if (!streamInputReaders.equals(other.streamInputReaders)) {
return false;
}
if (trace == null) {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
/* Only for debugging, shouldn't be externalized */