Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
12c155f5 | 2 | * Copyright (c) 2009, 2011 Ericsson |
8c8bf09f ASL |
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 | ||
6c13869b | 13 | package org.eclipse.linuxtools.tmf.core.trace; |
8c8bf09f | 14 | |
12c155f5 FC |
15 | import java.io.FileNotFoundException; |
16 | ||
17 | import org.eclipse.core.resources.IProject; | |
a1091415 | 18 | import org.eclipse.core.resources.IResource; |
6c13869b | 19 | import org.eclipse.linuxtools.tmf.core.component.ITmfComponent; |
72f1e62a | 20 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
4df4581d | 21 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
6c13869b | 22 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; |
8c8bf09f ASL |
23 | |
24 | /** | |
146a887c | 25 | * <b><u>ITmfTrace</u></b> |
8c8bf09f ASL |
26 | * <p> |
27 | */ | |
72f1e62a | 28 | public interface ITmfTrace<T extends ITmfEvent> extends ITmfComponent { |
12c155f5 FC |
29 | |
30 | // initTrace variants | |
0710697b | 31 | public void initTrace(String name, String path, Class<T> eventType) throws FileNotFoundException; |
12c155f5 | 32 | |
0710697b | 33 | public void initTrace(String name, String path, Class<T> eventType, int cacheSize) throws FileNotFoundException; |
12c155f5 | 34 | |
0710697b | 35 | public void initTrace(String name, String path, Class<T> eventType, boolean indexTrace) throws FileNotFoundException; |
12c155f5 | 36 | |
0710697b | 37 | public void initTrace(String name, String path, Class<T> eventType, int cacheSize, boolean indexTrace) throws FileNotFoundException; |
96c6806f | 38 | |
12c155f5 FC |
39 | // Trace type validation |
40 | public boolean validate(IProject project, String path); | |
41 | ||
42 | public ITmfTrace<T> copy(); | |
b0a282fb | 43 | |
abfad0aa | 44 | /** |
12c155f5 FC |
45 | * @return the trace path |
46 | */ | |
47 | public String getPath(); | |
48 | ||
49 | /** | |
50 | * @return the trace name | |
51 | */ | |
52 | @Override | |
53 | public String getName(); | |
54 | ||
55 | /** | |
56 | * @return the cache size | |
abfad0aa FC |
57 | */ |
58 | public int getCacheSize(); | |
59 | ||
12c155f5 FC |
60 | /** |
61 | * @return the number of events in the trace | |
62 | */ | |
63 | public long getNbEvents(); | |
64 | ||
65 | /** | |
66 | * Trace time range accesses | |
67 | */ | |
68 | public TmfTimeRange getTimeRange(); | |
69 | ||
4df4581d | 70 | public ITmfTimestamp getStartTime(); |
12c155f5 | 71 | |
4df4581d | 72 | public ITmfTimestamp getEndTime(); |
62d1696a | 73 | |
1b70b6dc PT |
74 | /** |
75 | * @return the streaming interval in ms (0 if not streaming) | |
76 | */ | |
77 | public long getStreamingInterval(); | |
78 | ||
12c155f5 FC |
79 | /** |
80 | * Positions the trace at the first event with the specified timestamp or index (i.e. the nth event in the trace). | |
4e3aa37d FC |
81 | * |
82 | * Returns a context which can later be used to read the event. | |
8c8bf09f | 83 | * |
12c155f5 | 84 | * @param location |
8c8bf09f ASL |
85 | * @return a context object for subsequent reads |
86 | */ | |
34ccf9a9 | 87 | public ITmfContext seekLocation(ITmfLocation<?> location); |
12c155f5 | 88 | |
34ccf9a9 | 89 | public ITmfContext seekEvent(ITmfTimestamp timestamp); |
12c155f5 | 90 | |
34ccf9a9 | 91 | public ITmfContext seekEvent(long rank); |
146a887c | 92 | |
c76c54bb FC |
93 | /** |
94 | * Positions the trace at the event located at the specified ratio. | |
95 | * | |
96 | * Returns a context which can later be used to read the event. | |
97 | * | |
12c155f5 FC |
98 | * @param ratio |
99 | * a floating-point number between 0.0 (beginning) and 1.0 (end) | |
c76c54bb FC |
100 | * @return a context object for subsequent reads |
101 | */ | |
34ccf9a9 | 102 | public ITmfContext seekLocation(double ratio); |
12c155f5 | 103 | |
c76c54bb FC |
104 | /** |
105 | * Returns the ratio corresponding to the specified location. | |
106 | * | |
12c155f5 FC |
107 | * @param location |
108 | * a trace location | |
c76c54bb FC |
109 | * @return a floating-point number between 0.0 (beginning) and 1.0 (end) |
110 | */ | |
111 | public double getLocationRatio(ITmfLocation<?> location); | |
12c155f5 | 112 | |
c76c54bb FC |
113 | public ITmfLocation<?> getCurrentLocation(); |
114 | ||
abfad0aa | 115 | /** |
12c155f5 FC |
116 | * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event |
117 | * (if any). | |
118 | * | |
0d9a6d76 FC |
119 | * @param timestamp the requested event timestamp |
120 | * @return the corresponding event rank | |
abfad0aa | 121 | */ |
4df4581d | 122 | public long getRank(ITmfTimestamp timestamp); |
12c155f5 | 123 | |
146a887c | 124 | /** |
12c155f5 FC |
125 | * Return the event pointed by the supplied context (or null if no event left) and updates the context to the next |
126 | * event. | |
8c8bf09f ASL |
127 | * |
128 | * @return the next event in the stream | |
129 | */ | |
a1440d1f | 130 | public ITmfEvent getNextEvent(ITmfContext context); |
62d1696a | 131 | |
e31e01e8 | 132 | /** |
12c155f5 | 133 | * Return the event pointed by the supplied context (or null if no event left) and *does not* update the context. |
e31e01e8 FC |
134 | * |
135 | * @return the next event in the stream | |
136 | */ | |
a1440d1f | 137 | public ITmfEvent parseEvent(ITmfContext context); |
e31e01e8 | 138 | |
a1091415 PT |
139 | /** |
140 | * Set the resource used for persistent properties on this trace | |
141 | * @param resource the properties resource | |
142 | */ | |
143 | public void setResource(IResource resource); | |
144 | ||
145 | /** | |
146 | * Get the resource used for persistent properties on this trace | |
147 | * @return the properties resource or null if none is set | |
148 | */ | |
149 | public IResource getResource(); | |
8c8bf09f | 150 | } |