1 /*******************************************************************************
2 * Copyright (c) 2009, 2011, 2012 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.trace
;
16 import java
.io
.FileNotFoundException
;
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
;
26 * <b><u>ITmfTrace</u></b>
28 * The basic event trace structure in TMF.
30 public interface ITmfTrace
<T
extends ITmfEvent
> extends ITmfComponent
, Cloneable
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 * Initialize a newly instantiated "empty" trace object. This is used to
38 * parameterize an ITmfTrace instantiated with its parameterless constructor.
40 * @param name the trace name
41 * @param path the trace path
42 * @param type the trace event type
43 * @throws FileNotFoundException
45 public void initTrace(String name
, String path
, Class
<T
> type
) throws FileNotFoundException
;
48 * Validate that the trace is of the correct type.
50 * @param project the eclipse project
51 * @param path the trace path
53 * @return true if trace is valid
55 public boolean validate(IProject project
, String path
);
58 * Set the resource used for persistent properties on this trace
60 * @param resource the properties resource
62 public void setResource(IResource resource
);
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
69 * @return the trace path
71 public String
getPath();
74 * @return the properties resource or null if none is set
76 public IResource
getResource();
79 * @return the number of events in the trace
81 public long getNbEvents();
84 * @return the trace time range
86 public TmfTimeRange
getTimeRange();
89 * @return the timestamp of the first trace event
91 public ITmfTimestamp
getStartTime();
94 * @return the timestamp of the last trace event
96 public ITmfTimestamp
getEndTime();
99 * @return the streaming interval in ms (0 if not streaming)
101 public long getStreamingInterval();
104 * @return the trace index page size
106 public int getIndexPageSize();
108 // ------------------------------------------------------------------------
110 // ------------------------------------------------------------------------
113 * Start the trace indexing, optionally wait for the index to be fully
114 * built before returning.
116 * @param waitForCompletion true for synchronous indexing
118 public void indexTrace(boolean waitForCompletion
);
120 // ------------------------------------------------------------------------
122 // ------------------------------------------------------------------------
125 * Position the trace at the specified location. The null location
126 * is used to indicate that the first trace event.
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
131 public ITmfContext
seekLocation(ITmfLocation
<?
> location
);
134 * Position the trace at the event located at the specified ratio in the
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.
141 * @param ratio the proportional 'rank' in the trace
142 * @return a context which can later be used to read the corresponding event
144 public ITmfContext
seekLocation(double ratio
);
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.
151 * @param timestamp the timestamp of desired event
152 * @return a context which can later be used to read the corresponding event
154 public ITmfContext
seekEvent(ITmfTimestamp timestamp
);
157 * Position the trace at the Nth event in the trace.
159 * @param rank the event rank
160 * @return a context which can later be used to read the corresponding event
162 public ITmfContext
seekEvent(long rank
);
164 // ------------------------------------------------------------------------
166 // ------------------------------------------------------------------------
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.
172 * @param context the read context
173 * @return the next event in the stream
175 public ITmfEvent
getNextEvent(ITmfContext context
);
178 * Return the event pointed by the supplied context (or null if no event
179 * left) and *does not* update the context.
181 * @param context the read context
182 * @return the next event in the stream
184 public ITmfEvent
parseEvent(ITmfContext context
);
187 // ------------------------------------------------------------------------
188 // Location operations
189 // ------------------------------------------------------------------------
192 * @return the current trace location
194 public ITmfLocation
<?
> getCurrentLocation();
197 * Returns the ratio (proportion) corresponding to the specified location.
199 * @param location a trace specific location
200 * @return a floating-point number between 0.0 (beginning) and 1.0 (end)
202 public double getLocationRatio(ITmfLocation
<?
> location
);
205 * Returns the rank of the first event with the requested timestamp.
206 * If none, returns the index of the subsequent event (if any).
208 * @param timestamp the requested event timestamp
209 * @return the corresponding event rank
211 public long getRank(ITmfTimestamp timestamp
);
213 // ------------------------------------------------------------------------
215 // ------------------------------------------------------------------------
218 * @return a clone of the trace
220 public ITmfTrace
<T
> clone() throws CloneNotSupportedException
;