Finalize ITmfTrace API
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / ITmfTrace.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2011, 2012 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 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.trace;
15
16 import java.io.FileNotFoundException;
17
18 import org.eclipse.core.resources.IProject;
19 import org.eclipse.core.resources.IResource;
20 import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
21 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
22 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
23 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
24
25 /**
26 * <b><u>ITmfTrace</u></b>
27 * <p>
28 * The basic event trace structure in TMF.
29 */
30 public interface ITmfTrace<T extends ITmfEvent> extends ITmfComponent {
31
32 // ------------------------------------------------------------------------
33 // Initializers
34 // ------------------------------------------------------------------------
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;
46
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);
56
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);
63
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);
78
79 // ------------------------------------------------------------------------
80 // Basic getters
81 // ------------------------------------------------------------------------
82
83 /**
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
94 /**
95 * @return the number of events in the trace
96 */
97 public long getNbEvents();
98
99 /**
100 * @return the trace time range
101 */
102 public TmfTimeRange getTimeRange();
103
104 /**
105 * @return the timestamp of the first trace event
106 */
107 public ITmfTimestamp getStartTime();
108
109 /**
110 * @return the timestamp of the last trace event
111 */
112 public ITmfTimestamp getEndTime();
113
114 /**
115 * @return the streaming interval in ms (0 if not streaming)
116 */
117 public long getStreamingInterval();
118
119 /**
120 * @return the trace index page size
121 */
122 public int getIndexPageSize();
123
124 // ------------------------------------------------------------------------
125 // Seek operations
126 // ------------------------------------------------------------------------
127
128 /**
129 * Position the trace at the specified location. The null location
130 * is used to indicate that the first trace event.
131 *
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
134 */
135 public ITmfContext seekLocation(ITmfLocation<?> location);
136
137 /**
138 * Position the trace at the event located at the specified ratio in the
139 * trace file.
140 *
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.
144 *
145 * @param ratio the proportional 'rank' in the trace
146 * @return a context which can later be used to read the corresponding event
147 */
148 public ITmfContext seekLocation(double ratio);
149
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
168 // ------------------------------------------------------------------------
169 // Read operations
170 // ------------------------------------------------------------------------
171
172 /**
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.
175 *
176 * @param context the read context
177 * @return the next event in the stream
178 */
179 public ITmfEvent getNextEvent(ITmfContext context);
180
181 /**
182 * Return the event pointed by the supplied context (or null if no event
183 * left) and *does not* update the context.
184 *
185 * @param context the read context
186 * @return the next event in the stream
187 */
188 public ITmfEvent parseEvent(ITmfContext context);
189
190
191 // ------------------------------------------------------------------------
192 // Location getters
193 // ------------------------------------------------------------------------
194
195 /**
196 * Returns the ratio (proportion) corresponding to the specified location.
197 *
198 * @param location a trace specific location
199 * @return a floating-point number between 0.0 (beginning) and 1.0 (end)
200 */
201 public double getLocationRatio(ITmfLocation<?> location);
202
203 /**
204 * @return the curretn trace location
205 */
206 public ITmfLocation<?> getCurrentLocation();
207
208 /**
209 * Returns the rank of the first event with the requested timestamp.
210 * If none, returns the index of the subsequent event (if any).
211 *
212 * @param timestamp the requested event timestamp
213 * @return the corresponding event rank
214 */
215 public long getRank(ITmfTimestamp timestamp);
216
217 }
This page took 0.042474 seconds and 6 git commands to generate.