Finalize ITmfTrace API
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / ITmfTrace.java
CommitLineData
8c8bf09f 1/*******************************************************************************
8636b448 2 * Copyright (c) 2009, 2011, 2012 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
8636b448 11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
8c8bf09f
ASL
12 *******************************************************************************/
13
6c13869b 14package org.eclipse.linuxtools.tmf.core.trace;
8c8bf09f 15
12c155f5
FC
16import java.io.FileNotFoundException;
17
18import org.eclipse.core.resources.IProject;
a1091415 19import org.eclipse.core.resources.IResource;
6c13869b 20import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
72f1e62a 21import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
4df4581d 22import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
6c13869b 23import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
8c8bf09f
ASL
24
25/**
146a887c 26 * <b><u>ITmfTrace</u></b>
8c8bf09f 27 * <p>
3118edf1 28 * The basic event trace structure in TMF.
8c8bf09f 29 */
72f1e62a 30public interface ITmfTrace<T extends ITmfEvent> extends ITmfComponent {
12c155f5 31
8636b448
FC
32 // ------------------------------------------------------------------------
33 // Initializers
34 // ------------------------------------------------------------------------
3118edf1
FC
35
36 /**
37 * Initialize a newly instantiated "empty" trace object. This is used to
38 * parameterize an ITmfTrace instantiated with its parameterless constructor.
39 *
40 * @param name the trace name
41 * @param path the trace path
42 * @param eventType the trace event type
43 * @throws FileNotFoundException
44 */
45 public void initTrace(String name, String path, Class<T> eventType) throws FileNotFoundException;
12c155f5 46
3118edf1
FC
47 /**
48 * Validate that the trace is of the correct type.
49 *
50 * @param project the eclipse project
51 * @param path the trace path
52 *
53 * @return true if trace is valid
54 */
55 public boolean validate(IProject project, String path);
12c155f5 56
3118edf1
FC
57 /**
58 * Set the resource used for persistent properties on this trace
59 *
60 * @param resource the properties resource
61 */
62 public void setResource(IResource resource);
96c6806f 63
3118edf1
FC
64 /**
65 * Get the resource used for persistent properties on this trace
66 *
67 * @return the properties resource or null if none is set
68 */
69 public IResource getResource();
70
71 /**
72 * Start the trace indexing, optionally wait for the index to be fully
73 * built before returning.
74 *
75 * @param waitForCompletion
76 */
77 public void indexTrace(boolean waitForCompletion);
12c155f5 78
8636b448 79 // ------------------------------------------------------------------------
3118edf1 80 // Basic getters
8636b448 81 // ------------------------------------------------------------------------
b0a282fb 82
abfad0aa 83 /**
12c155f5
FC
84 * @return the trace path
85 */
86 public String getPath();
87
88 /**
89 * @return the trace name
90 */
91 @Override
92 public String getName();
93
12c155f5
FC
94 /**
95 * @return the number of events in the trace
96 */
97 public long getNbEvents();
98
99 /**
3118edf1 100 * @return the trace time range
12c155f5
FC
101 */
102 public TmfTimeRange getTimeRange();
103
3118edf1
FC
104 /**
105 * @return the timestamp of the first trace event
106 */
4df4581d 107 public ITmfTimestamp getStartTime();
12c155f5 108
3118edf1
FC
109 /**
110 * @return the timestamp of the last trace event
111 */
4df4581d 112 public ITmfTimestamp getEndTime();
62d1696a 113
1b70b6dc
PT
114 /**
115 * @return the streaming interval in ms (0 if not streaming)
116 */
117 public long getStreamingInterval();
118
3118edf1
FC
119 /**
120 * @return the trace index page size
121 */
122 public int getIndexPageSize();
123
8636b448
FC
124 // ------------------------------------------------------------------------
125 // Seek operations
126 // ------------------------------------------------------------------------
127
12c155f5 128 /**
3118edf1
FC
129 * Position the trace at the specified location. The null location
130 * is used to indicate that the first trace event.
4e3aa37d 131 *
3118edf1
FC
132 * @param location the trace specific location (null for 1st event)
133 * @return a context which can later be used to read the corresponding event
8c8bf09f 134 */
34ccf9a9 135 public ITmfContext seekLocation(ITmfLocation<?> location);
12c155f5 136
c76c54bb 137 /**
3118edf1
FC
138 * Position the trace at the event located at the specified ratio in the
139 * trace file.
c76c54bb 140 *
3118edf1
FC
141 * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
142 * voluntarily vague. Typically, it would refer to the event proportional
143 * rank or timestamp in the trace file.
c76c54bb 144 *
3118edf1
FC
145 * @param ratio the proportional 'rank' in the trace
146 * @return a context which can later be used to read the corresponding event
c76c54bb 147 */
34ccf9a9 148 public ITmfContext seekLocation(double ratio);
12c155f5 149
3118edf1
FC
150 /**
151 * Position the trace at the first event with the specified timestamp. If
152 * there is no event with the requested timestamp, a context pointing to
153 * the chronologically next event is returned.
154 *
155 * @param timestamp the timestamp of desired event
156 * @return a context which can later be used to read the corresponding event
157 */
158 public ITmfContext seekEvent(ITmfTimestamp timestamp);
159
160 /**
161 * Position the trace at the Nth event in the trace.
162 *
163 * @param rank the event rank
164 * @return a context which can later be used to read the corresponding event
165 */
166 public ITmfContext seekEvent(long rank);
167
8636b448
FC
168 // ------------------------------------------------------------------------
169 // Read operations
170 // ------------------------------------------------------------------------
171
172 /**
3118edf1
FC
173 * Return the event pointed by the supplied context (or null if no event
174 * left) and updates the context to point the next event.
8636b448 175 *
3118edf1 176 * @param context the read context
8636b448
FC
177 * @return the next event in the stream
178 */
179 public ITmfEvent getNextEvent(ITmfContext context);
180
181 /**
3118edf1
FC
182 * Return the event pointed by the supplied context (or null if no event
183 * left) and *does not* update the context.
8636b448 184 *
3118edf1 185 * @param context the read context
8636b448
FC
186 * @return the next event in the stream
187 */
188 public ITmfEvent parseEvent(ITmfContext context);
189
190
191 // ------------------------------------------------------------------------
3118edf1 192 // Location getters
8636b448
FC
193 // ------------------------------------------------------------------------
194
c76c54bb 195 /**
3118edf1 196 * Returns the ratio (proportion) corresponding to the specified location.
c76c54bb 197 *
3118edf1 198 * @param location a trace specific location
c76c54bb
FC
199 * @return a floating-point number between 0.0 (beginning) and 1.0 (end)
200 */
201 public double getLocationRatio(ITmfLocation<?> location);
12c155f5 202
3118edf1
FC
203 /**
204 * @return the curretn trace location
205 */
c76c54bb
FC
206 public ITmfLocation<?> getCurrentLocation();
207
abfad0aa 208 /**
3118edf1
FC
209 * Returns the rank of the first event with the requested timestamp.
210 * If none, returns the index of the subsequent event (if any).
12c155f5 211 *
0d9a6d76
FC
212 * @param timestamp the requested event timestamp
213 * @return the corresponding event rank
abfad0aa 214 */
4df4581d 215 public long getRank(ITmfTimestamp timestamp);
12c155f5 216
8c8bf09f 217}
This page took 0.059957 seconds and 5 git commands to generate.