Commit | Line | Data |
---|---|---|
165c977c FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.stream; | |
14 | ||
15 | import java.util.Map; | |
16 | ||
17 | import org.eclipse.linuxtools.tmf.event.TmfEvent; | |
18 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; | |
19 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; | |
165c977c FC |
20 | |
21 | /** | |
22 | * <b><u>ITmfEventStream</u></b> | |
23 | * <p> | |
24 | * TODO: Implement me. Please. | |
25 | */ | |
26 | public interface ITmfEventStream { | |
27 | ||
28 | public class StreamContext { | |
29 | Object location; | |
82b08e62 FC |
30 | int index; |
31 | ||
32 | public StreamContext(Object loc, int ind) { | |
165c977c | 33 | location = loc; |
82b08e62 FC |
34 | index = ind; |
35 | } | |
36 | ||
37 | public StreamContext(StreamContext other) { | |
38 | if (other != null) { | |
39 | location = other.location; | |
40 | index = other.index; | |
41 | } | |
165c977c FC |
42 | } |
43 | } | |
44 | ||
45 | public int getNbEvents(); | |
46 | ||
47 | public TmfTimeRange getTimeRange(); | |
48 | ||
49 | public Map<String, Object> getAttributes(); | |
50 | ||
51 | /** | |
52 | * Positions the stream at the first event with timestamp. | |
53 | * | |
54 | * @param timestamp | |
55 | * @return a context object for subsequent reads | |
56 | */ | |
57 | public StreamContext seekEvent(TmfTimestamp timestamp); | |
58 | ||
59 | /** | |
60 | * Positions the stream on the event at the wanted position. | |
61 | * | |
62 | * @param index | |
63 | * @return a context object for subsequent reads | |
64 | */ | |
65 | public StreamContext seekEvent(int index); | |
66 | ||
67 | /** | |
68 | * Reads and the next event on the stream and updates the context. | |
69 | * If there is no event left, return null. | |
70 | * | |
71 | * @return the next event in the stream | |
72 | */ | |
73 | public TmfEvent getNextEvent(StreamContext context); | |
74 | ||
75 | public TmfEvent getEvent(StreamContext context, TmfTimestamp timestamp); | |
76 | public TmfEvent getEvent(StreamContext context, int index); | |
77 | ||
78 | /** | |
79 | * Parse the stream and creates the checkpoint structure. | |
80 | * Normally performed once at the creation of the event stream. | |
81 | */ | |
82 | public void indexStream(boolean waitForCompletion); | |
83 | ||
84 | public Object getCurrentLocation(); | |
85 | public StreamContext seekLocation(Object location); | |
86 | ||
82b08e62 FC |
87 | /** |
88 | * Returns the index of the event at that timestamp | |
89 | * | |
90 | * @param timestamp | |
91 | * @return | |
92 | */ | |
93 | public int getIndex(TmfTimestamp timestamp); | |
165c977c | 94 | } |