* Lightweight Context for CtfTmf traces. Should only use 3 references, 1 ref to
* a boxed Long, a long and an int.
*
- * @versionj 1.0
+ * @version 1.0
* @author Matthew Khouzam
*/
public class CtfTmfLightweightContext implements ITmfContext {
public CtfTmfLightweightContext(ArrayList<CtfIterator> iters,
ListIterator<CtfIterator> pos) {
fTrace = iters.get(0).getCtfTmfTrace();
- curLocation = new CtfLocation((Long) null);
+ curLocation = new CtfLocation(new CtfLocationData(0, 0));
}
/**
*/
public CtfTmfLightweightContext(CtfTmfTrace ctfTmfTrace) {
fTrace = ctfTmfTrace;
- curLocation = new CtfLocation((Long) null);
+ curLocation = new CtfLocation(new CtfLocationData(0, 0));
}
// -------------------------------------------
@Override
public boolean hasValidRank() {
- return curRank != CtfLocation.INVALID_LOCATION;
+ return curRank != CtfLocation.INVALID_LOCATION.getTimestamp();
}
@Override
* @return success or not
*/
public synchronized boolean advance() {
+ final CtfLocationData curLocationData = this.curLocation.getLocation();
boolean retVal = getIterator().advance();
CtfTmfEvent currentEvent = getIterator().getCurrentEvent();
+
if (currentEvent != null) {
- curLocation.setLocation(currentEvent.getTimestampValue());
+ final long timestampValue = currentEvent.getTimestampValue();
+ if (curLocationData.getTimestamp() == timestampValue) {
+ curLocation.setLocation(timestampValue, curLocationData.getIndex() + 1);
+ } else {
+ curLocation.setLocation(timestampValue, 0L);
+ }
} else {
curLocation.setLocation(CtfLocation.INVALID_LOCATION);
}
* @return success or not
*/
public synchronized boolean seek(final long timestamp) {
- curLocation.setLocation(timestamp);
+ curLocation.setLocation(timestamp, 0);
return getIterator().seek(timestamp);
}
+ /**
+ * Seeks to a given location. Wrapper to help CtfTmfTrace
+ * @param location
+ * unique location to find the event.
+ *
+ * @return success or not
+ * @since 2.0
+ */
+ public synchronized boolean seek(final CtfLocationData location) {
+ curLocation.setLocation(location);
+ return getIterator().seek(location);
+ }
+
/*
* (non-Javadoc)
*