Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
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.trace; | |
14 | ||
8c8bf09f ASL |
15 | import org.eclipse.linuxtools.tmf.event.TmfEvent; |
16 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; | |
17 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; | |
18 | ||
19 | /** | |
146a887c | 20 | * <b><u>ITmfTrace</u></b> |
8c8bf09f | 21 | * <p> |
62d1696a | 22 | * TODO: Implement me. Please. |
8c8bf09f | 23 | */ |
62d1696a FC |
24 | public interface ITmfTrace { |
25 | ||
8c8bf09f | 26 | /** |
62d1696a FC |
27 | * <b><u>StreamContext</u></b> |
28 | * <p> | |
146a887c FC |
29 | * Stream context keeper. Used to prevent conflicting, concurrent accesses |
30 | * to the underlying trace. | |
8c8bf09f | 31 | */ |
146a887c | 32 | public class TmfTraceContext { |
62d1696a FC |
33 | public Object location; |
34 | public int index; | |
35 | ||
146a887c | 36 | public TmfTraceContext(Object loc, int ind) { |
62d1696a FC |
37 | location = loc; |
38 | index = ind; | |
39 | } | |
40 | ||
146a887c | 41 | public TmfTraceContext(TmfTraceContext other) { |
62d1696a FC |
42 | if (other != null) { |
43 | location = other.location; | |
44 | index = other.index; | |
45 | } | |
46 | } | |
47 | } | |
8c8bf09f ASL |
48 | |
49 | /** | |
146a887c | 50 | * @return the trace name |
8c8bf09f ASL |
51 | */ |
52 | public String getName(); | |
62d1696a | 53 | |
8c8bf09f | 54 | /** |
146a887c | 55 | * @return the number of events in the trace |
8c8bf09f | 56 | */ |
62d1696a | 57 | public int getNbEvents(); |
8c8bf09f ASL |
58 | |
59 | /** | |
146a887c | 60 | * Trace time range handlers |
8c8bf09f | 61 | */ |
146a887c FC |
62 | public void setTimeRange(TmfTimeRange range); |
63 | public void setStartTime(TmfTimestamp startTime); | |
64 | public void setEndTime(TmfTimestamp endTime); | |
8c8bf09f | 65 | |
146a887c FC |
66 | public TmfTimeRange getTimeRange(); |
67 | public TmfTimestamp getStartTime(); | |
68 | public TmfTimestamp getEndTime(); | |
62d1696a FC |
69 | |
70 | /** | |
146a887c FC |
71 | * Positions the trace at the first event with the specified |
72 | * timestamp or index (i.e. the nth event in the trace) | |
8c8bf09f | 73 | * |
62d1696a | 74 | * @param timestamp |
146a887c | 75 | * @param index |
8c8bf09f ASL |
76 | * @return a context object for subsequent reads |
77 | */ | |
146a887c FC |
78 | public TmfTraceContext seekEvent(TmfTimestamp timestamp); |
79 | public TmfTraceContext seekEvent(int index); | |
8c8bf09f ASL |
80 | |
81 | /** | |
146a887c FC |
82 | * These functions handle the mapping between an abstract trace |
83 | * and the actual implementation. | |
84 | * | |
85 | * <code>parseEvent()</code> parses the event at the current | |
86 | * trace location. | |
87 | * | |
88 | * <code>processEvent()</code> is a hook for application | |
89 | * specific processing once the event has been read. | |
90 | */ | |
91 | public Object getCurrentLocation(); | |
92 | public TmfTraceContext seekLocation(Object location); | |
93 | public TmfEvent parseNextEvent(); | |
94 | public void processEvent(TmfEvent event); | |
95 | ||
96 | /** | |
97 | * These functions return the event pointed by the supplied context | |
98 | * (or null if no event left). | |
99 | * | |
100 | * The context is updated to point to the next trace event, expect | |
101 | * for tpeekEvent() which doesn't update the context. | |
8c8bf09f ASL |
102 | * |
103 | * @return the next event in the stream | |
104 | */ | |
146a887c FC |
105 | public TmfEvent peekEvent(TmfTraceContext context); |
106 | public TmfEvent getEvent(TmfTraceContext context, TmfTimestamp timestamp); | |
107 | public TmfEvent getEvent(TmfTraceContext context, int index); | |
108 | public TmfEvent getNextEvent(TmfTraceContext context); | |
62d1696a FC |
109 | |
110 | /** | |
146a887c | 111 | * Index the stream and creates the checkpoint structure. |
62d1696a FC |
112 | * Normally invoked once at the creation of the event stream. |
113 | */ | |
146a887c | 114 | public void indexStream(); |
8c8bf09f ASL |
115 | |
116 | /** | |
146a887c FC |
117 | * Returns the index of the first event at the supplied timestamp. |
118 | * If there is no such event, return the next one (null if none left). | |
8c8bf09f | 119 | * |
62d1696a FC |
120 | * @param timestamp |
121 | * @return | |
8c8bf09f | 122 | */ |
62d1696a | 123 | public int getIndex(TmfTimestamp timestamp); |
8c8bf09f | 124 | |
62d1696a FC |
125 | /** |
126 | * Returns the timestamp of the event at position [index] | |
146a887c | 127 | * (null if none left). |
62d1696a FC |
128 | * |
129 | * @param index the event index | |
130 | * @return the corresponding timestamp | |
131 | */ | |
132 | public TmfTimestamp getTimestamp(int index); | |
8c8bf09f | 133 | } |