1 package org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
;
3 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
4 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.StreamInputReader
;
5 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
6 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
8 public class CtfIterator
extends CTFTraceReader
implements ITmfContext
,
9 Comparable
<CtfIterator
> {
11 private final CtfTmfTrace ctfTmfTrace
;
13 final public static CtfLocation nullLocation
= new CtfLocation(
14 CtfLocation
.INVALID_LOCATION
);
15 private CtfLocation curLocation
;
19 * Create a new CTF trace iterator, which initially points at the first
24 public CtfIterator(final CtfTmfTrace trace
) {
25 super(trace
.getCTFTrace());
26 this.ctfTmfTrace
= trace
;
27 if (this.hasMoreEvents()) {
29 this.curLocation
= new CtfLocation(trace
.getStartTime());
39 private void setUnknownLocation() {
40 this.curLocation
= nullLocation
;
41 this.curRank
= UNKNOWN_RANK
;
44 public CtfIterator(final CtfTmfTrace trace
, final long timestampValue
,
46 super(trace
.getCTFTrace());
48 this.ctfTmfTrace
= trace
;
49 if (this.hasMoreEvents()) {
50 this.curLocation
= (new CtfLocation(this.getCurrentEvent()
51 .getTimestampValue()));
52 if (this.getCurrentEvent().getTimestampValue() != timestampValue
) {
53 this.seek(timestampValue
);
62 public CtfTmfTrace
getCtfTmfTrace() {
66 public CtfTmfEvent
getCurrentEvent() {
67 final StreamInputReader top
= super.prio
.peek();
69 return new CtfTmfEvent(top
.getCurrentEvent(), top
.getFilename(),
76 public boolean seek(final long timestamp
) {
78 final long offsetTimestamp
= timestamp
79 - this.getCtfTmfTrace().getCTFTrace().getOffset();
80 if (offsetTimestamp
< 0) {
81 ret
= super.seek(timestamp
);
83 ret
= super.seek(offsetTimestamp
);
87 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
92 public boolean seekRank(final long rank
) {
94 ret
= super.seekIndex(rank
);
97 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
103 public long getRank() {
104 return super.getIndex();
108 public void setRank(final long rank
) {
109 if(!this.curLocation
.equals(nullLocation
)) {
117 * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#clone()
120 public CtfIterator
clone() {
121 CtfIterator clone
= null;
122 clone
= new CtfIterator(ctfTmfTrace
, this.getCurrentEvent()
123 .getTimestampValue(), curRank
);
128 public void dispose() {
129 // FIXME add dispose() stuff to CTFTrace and call it here...
134 public void setLocation(final ITmfLocation
<?
> location
) {
135 // FIXME alex: isn't there a cleaner way than a cast here?
136 this.curLocation
= (CtfLocation
) location
;
137 seek(((CtfLocation
) location
).getLocation());
141 public CtfLocation
getLocation() {
146 public void increaseRank() {
151 public boolean hasValidRank() {
152 return (getRank() >= 0);
156 public boolean advance() {
157 return super.advance();
161 public int compareTo(final CtfIterator o
) {
162 if (this.getRank() < o
.getRank()) {
164 } else if (this.getRank() > o
.getRank()) {
This page took 0.03656 seconds and 6 git commands to generate.