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 private CtfLocation curLocation
;
14 private final long curRank
;
17 * Create a new CTF trace iterator, which initially points at the first
22 public CtfIterator(CtfTmfTrace trace
) {
23 super(trace
.getCTFTrace());
24 this.ctfTmfTrace
= trace
;
26 // FIXME put the real stuff here...
27 this.curLocation
= new CtfLocation(trace
.getStartTime());
31 public CtfIterator(CtfTmfTrace trace
, long timestampValue
, long rank
) {
32 super(trace
.getCTFTrace());
33 this.ctfTmfTrace
= trace
;
34 this.curLocation
= (new CtfLocation(this.getCurrentEvent()
35 .getTimestampValue()));
36 if (this.getCurrentEvent().getTimestampValue() != timestampValue
) {
37 this.seek(timestampValue
);
43 public CtfTmfTrace
getCtfTmfTrace() {
47 public CtfTmfEvent
getCurrentEvent() {
48 StreamInputReader top
= super.prio
.peek();
50 return new CtfTmfEvent(top
.getCurrentEvent(), top
, ctfTmfTrace
);
56 public boolean seek(long timestamp
) {
58 long offsetTimestamp
= timestamp
- this.getCtfTmfTrace().getCTFTrace().getOffset();
59 if( offsetTimestamp
< 0 ) {
60 ret
= super.seek(timestamp
);
62 ret
= super.seek(offsetTimestamp
);
66 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
71 public boolean seekRank(long rank
) {
73 ret
= super.seekIndex(rank
);
76 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
82 public long getRank() {
83 return super.getIndex();
87 public void setRank(long rank
) {
94 * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#clone()
97 public CtfIterator
clone() {
98 CtfIterator clone
= null;
99 clone
= new CtfIterator(ctfTmfTrace
, this.getCurrentEvent()
100 .getTimestampValue(), curRank
);
105 public void dispose() {
106 // FIXME add dispose() stuff to CTFTrace and call it here...
111 public void setLocation(ITmfLocation
<?
> location
) {
112 // FIXME alex: isn't there a cleaner way than a cast here?
113 this.curLocation
= (CtfLocation
) location
;
114 seek(((CtfLocation
)location
).getLocation());
118 public CtfLocation
getLocation() {
122 @SuppressWarnings("unused")
124 public void updateRank(int rank
) {
125 // not needed I think
129 public boolean isValidRank() {
130 return (getRank() > -1);
134 public boolean advance() {
135 return super.advance();
139 public int compareTo(CtfIterator o
) {
140 if (this.getRank() < o
.getRank()) {
142 } else if (this.getRank() > o
.getRank()) {
This page took 0.071783 seconds and 5 git commands to generate.