Merge branch 'master' into TmfTraceModel-new
[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, Cloneable {
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 type the trace event type
43 * @throws FileNotFoundException
44 */
45 public void initTrace(String name, String path, Class<T> type) 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 // Basic getters
66 // ------------------------------------------------------------------------
67
68 /**
69 * @return the trace path
70 */
71 public String getPath();
72
73 /**
74 * @return the properties resource or null if none is set
75 */
76 public IResource getResource();
77
78 /**
79 * @return the number of events in the trace
80 */
81 public long getNbEvents();
82
83 /**
84 * @return the trace time range
85 */
86 public TmfTimeRange getTimeRange();
87
88 /**
89 * @return the timestamp of the first trace event
90 */
91 public ITmfTimestamp getStartTime();
92
93 /**
94 * @return the timestamp of the last trace event
95 */
96 public ITmfTimestamp getEndTime();
97
98 /**
99 * @return the streaming interval in ms (0 if not streaming)
100 */
101 public long getStreamingInterval();
102
103 /**
104 * @return the trace index page size
105 */
106 public int getIndexPageSize();
107
108 // ------------------------------------------------------------------------
109 // Indexing
110 // ------------------------------------------------------------------------
111
112 /**
113 * Start the trace indexing, optionally wait for the index to be fully
114 * built before returning.
115 *
116 * @param waitForCompletion true for synchronous indexing
117 */
118 public void indexTrace(boolean waitForCompletion);
119
120 // ------------------------------------------------------------------------
121 // Seek operations
122 // ------------------------------------------------------------------------
123
124 /**
125 * Position the trace at the specified location. The null location
126 * is used to indicate that the first trace event.
127 *
128 * @param location the trace specific location (null for 1st event)
129 * @return a context which can later be used to read the corresponding event
130 */
131 public ITmfContext seekLocation(ITmfLocation<?> location);
132
133 /**
134 * Position the trace at the event located at the specified ratio in the
135 * trace file.
136 *
137 * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
138 * voluntarily vague. Typically, it would refer to the event proportional
139 * rank or timestamp in the trace file.
140 *
141 * @param ratio the proportional 'rank' in the trace
142 * @return a context which can later be used to read the corresponding event
143 */
144 public ITmfContext seekLocation(double ratio);
145
146 /**
147 * Position the trace at the first event with the specified timestamp. If
148 * there is no event with the requested timestamp, a context pointing to
149 * the chronologically next event is returned.
150 *
151 * @param timestamp the timestamp of desired event
152 * @return a context which can later be used to read the corresponding event
153 */
154 public ITmfContext seekEvent(ITmfTimestamp timestamp);
155
156 /**
157 * Position the trace at the Nth event in the trace.
158 *
159 * @param rank the event rank
160 * @return a context which can later be used to read the corresponding event
161 */
162 public ITmfContext seekEvent(long rank);
163
164 // ------------------------------------------------------------------------
165 // Read operations
166 // ------------------------------------------------------------------------
167
168 /**
169 * Return the event pointed by the supplied context (or null if no event
170 * left) and updates the context to point the next event.
171 *
172 * @param context the read context
173 * @return the next event in the stream
174 */
175 public ITmfEvent getNextEvent(ITmfContext context);
176
177 /**
178 * Return the event pointed by the supplied context (or null if no event
179 * left) and *does not* update the context.
180 *
181 * @param context the read context
182 * @return the next event in the stream
183 */
184 public ITmfEvent parseEvent(ITmfContext context);
185
186
187 // ------------------------------------------------------------------------
188 // Location operations
189 // ------------------------------------------------------------------------
190
191 /**
192 * @return the current trace location
193 */
194 public ITmfLocation<?> getCurrentLocation();
195
196 /**
197 * Returns the ratio (proportion) corresponding to the specified location.
198 *
199 * @param location a trace specific location
200 * @return a floating-point number between 0.0 (beginning) and 1.0 (end)
201 */
202 public double getLocationRatio(ITmfLocation<?> location);
203
204 /**
205 * Returns the rank of the first event with the requested timestamp.
206 * If none, returns the index of the subsequent event (if any).
207 *
208 * @param timestamp the requested event timestamp
209 * @return the corresponding event rank
210 */
211 public long getRank(ITmfTimestamp timestamp);
212
213 // ------------------------------------------------------------------------
214 // Cloneable
215 // ------------------------------------------------------------------------
216
217 /**
218 * @return a clone of the trace
219 */
220 public ITmfTrace<T> clone() throws CloneNotSupportedException;
221
222 }
This page took 0.036591 seconds and 6 git commands to generate.