de1458b98619780cba8906c7c51880031f99d52b
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
;
17 * Create a new CTF trace iterator, which initially points at the first
22 public CtfIterator(final 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(final CtfTmfTrace trace
, final long timestampValue
, final 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
);
42 public CtfTmfTrace
getCtfTmfTrace() {
46 public CtfTmfEvent
getCurrentEvent() {
47 final StreamInputReader top
= super.prio
.peek();
49 return new CtfTmfEvent(top
.getCurrentEvent(), top
.getFilename(), ctfTmfTrace
);
54 public boolean seek(final long timestamp
) {
56 final long offsetTimestamp
= timestamp
- this.getCtfTmfTrace().getCTFTrace().getOffset();
57 if( offsetTimestamp
< 0 )
58 ret
= super.seek(timestamp
);
60 ret
= super.seek(offsetTimestamp
);
63 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
67 public boolean seekRank(final long rank
) {
69 ret
= super.seekIndex(rank
);
72 curLocation
.setLocation(getCurrentEvent().getTimestampValue());
77 public long getRank() {
78 return super.getIndex();
82 public void setRank(final long rank
) {
89 * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#clone()
92 public CtfIterator
clone() {
93 CtfIterator clone
= null;
94 clone
= new CtfIterator(ctfTmfTrace
, this.getCurrentEvent()
95 .getTimestampValue(), curRank
);
100 public void dispose() {
101 // FIXME add dispose() stuff to CTFTrace and call it here...
106 public void setLocation(final ITmfLocation
<?
> location
) {
107 // FIXME alex: isn't there a cleaner way than a cast here?
108 this.curLocation
= (CtfLocation
) location
;
109 seek(((CtfLocation
)location
).getLocation());
113 public CtfLocation
getLocation() {
117 @SuppressWarnings("unused")
119 public void increaseRank() {
124 public boolean hasValidRank() {
125 return (getRank() > -1);
129 public boolean advance() {
130 return super.advance();
134 public int compareTo(final CtfIterator o
) {
135 if (this.getRank() < o
.getRank())
137 else if (this.getRank() > o
.getRank())
This page took 0.032278 seconds and 5 git commands to generate.