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 | 48 | |
b0a282fb FC |
49 | /** |
50 | * @return the trace path | |
51 | */ | |
52 | public String getPath(); | |
53 | ||
8c8bf09f | 54 | /** |
146a887c | 55 | * @return the trace name |
8c8bf09f ASL |
56 | */ |
57 | public String getName(); | |
b0a282fb | 58 | |
8c8bf09f | 59 | /** |
146a887c | 60 | * @return the number of events in the trace |
8c8bf09f | 61 | */ |
62d1696a | 62 | public int getNbEvents(); |
8c8bf09f ASL |
63 | |
64 | /** | |
146a887c | 65 | * Trace time range handlers |
8c8bf09f | 66 | */ |
146a887c FC |
67 | public void setTimeRange(TmfTimeRange range); |
68 | public void setStartTime(TmfTimestamp startTime); | |
69 | public void setEndTime(TmfTimestamp endTime); | |
8c8bf09f | 70 | |
146a887c FC |
71 | public TmfTimeRange getTimeRange(); |
72 | public TmfTimestamp getStartTime(); | |
73 | public TmfTimestamp getEndTime(); | |
62d1696a FC |
74 | |
75 | /** | |
146a887c FC |
76 | * Positions the trace at the first event with the specified |
77 | * timestamp or index (i.e. the nth event in the trace) | |
8c8bf09f | 78 | * |
62d1696a | 79 | * @param timestamp |
146a887c | 80 | * @param index |
8c8bf09f ASL |
81 | * @return a context object for subsequent reads |
82 | */ | |
146a887c FC |
83 | public TmfTraceContext seekEvent(TmfTimestamp timestamp); |
84 | public TmfTraceContext seekEvent(int index); | |
8c8bf09f ASL |
85 | |
86 | /** | |
146a887c FC |
87 | * These functions handle the mapping between an abstract trace |
88 | * and the actual implementation. | |
89 | * | |
90 | * <code>parseEvent()</code> parses the event at the current | |
91 | * trace location. | |
92 | * | |
93 | * <code>processEvent()</code> is a hook for application | |
94 | * specific processing once the event has been read. | |
95 | */ | |
96 | public Object getCurrentLocation(); | |
97 | public TmfTraceContext seekLocation(Object location); | |
98 | public TmfEvent parseNextEvent(); | |
99 | public void processEvent(TmfEvent event); | |
100 | ||
101 | /** | |
102 | * These functions return the event pointed by the supplied context | |
103 | * (or null if no event left). | |
104 | * | |
105 | * The context is updated to point to the next trace event, expect | |
106 | * for tpeekEvent() which doesn't update the context. | |
8c8bf09f ASL |
107 | * |
108 | * @return the next event in the stream | |
109 | */ | |
146a887c FC |
110 | public TmfEvent peekEvent(TmfTraceContext context); |
111 | public TmfEvent getEvent(TmfTraceContext context, TmfTimestamp timestamp); | |
112 | public TmfEvent getEvent(TmfTraceContext context, int index); | |
113 | public TmfEvent getNextEvent(TmfTraceContext context); | |
62d1696a FC |
114 | |
115 | /** | |
146a887c | 116 | * Index the stream and creates the checkpoint structure. |
62d1696a FC |
117 | * Normally invoked once at the creation of the event stream. |
118 | */ | |
146a887c | 119 | public void indexStream(); |
8c8bf09f ASL |
120 | |
121 | /** | |
146a887c FC |
122 | * Returns the index of the first event at the supplied timestamp. |
123 | * If there is no such event, return the next one (null if none left). | |
8c8bf09f | 124 | * |
62d1696a FC |
125 | * @param timestamp |
126 | * @return | |
8c8bf09f | 127 | */ |
62d1696a | 128 | public int getIndex(TmfTimestamp timestamp); |
8c8bf09f | 129 | |
62d1696a FC |
130 | /** |
131 | * Returns the timestamp of the event at position [index] | |
146a887c | 132 | * (null if none left). |
62d1696a FC |
133 | * |
134 | * @param index the event index | |
135 | * @return the corresponding timestamp | |
136 | */ | |
137 | public TmfTimestamp getTimestamp(int index); | |
8c8bf09f | 138 | } |