tmf: Add the Tmf- prefix to the state system interfaces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / statesystem / ITmfStateSystem.java
1 /*******************************************************************************
2 * Copyright (c) 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 * Alexandre Montplaisir - Initial API
11 ******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.core.statesystem;
14
15 import java.util.List;
16
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
19 import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
20 import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
21 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
22 import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
23
24 /**
25 * This is the read-only interface to the generic state system. It contains all
26 * the read-only quark-getting methods, as well as the history-querying ones.
27 *
28 * @author Alexandre Montplaisir
29 * @version 2.0
30 * @since 2.0
31 */
32 public interface ITmfStateSystem {
33
34 /**
35 * Return the start time of this history. It usually matches the start time
36 * of the original trace.
37 *
38 * @return The history's registered start time
39 */
40 public long getStartTime();
41
42 /**
43 * Return the current end time of the history.
44 *
45 * @return The current end time of this state history
46 */
47 public long getCurrentEndTime();
48
49 /**
50 * Return the current total amount of attributes in the system. This is also
51 * equal to the quark that will be assigned to the next attribute that's
52 * created.
53 *
54 * @return The current number of attributes in the system
55 */
56 public int getNbAttributes();
57
58 /**
59 * Check if a given quark is the last attribute that was added to the
60 * system.
61 *
62 * This is a common case, and it's a bit clearer than
63 * " x == getNbAttributes - 1"
64 *
65 * @param quark
66 * The quark to check for
67 * @return True if this is the last quark that was added to the system,
68 * false if not
69 * @since 2.0
70 */
71 public boolean isLastAttribute(int quark);
72
73 /**
74 * @name Read-only quark-getting methods
75 */
76
77 /**
78 * Basic quark-retrieving method. Pass an attribute in parameter as an array
79 * of strings, the matching quark will be returned.
80 *
81 * This version will NOT create any new attributes. If an invalid attribute
82 * is requested, an exception will be thrown.
83 *
84 * @param attribute
85 * Attribute given as its full path in the Attribute Tree
86 * @return The quark of the requested attribute, if it existed.
87 * @throws AttributeNotFoundException
88 * This exception is thrown if the requested attribute simply
89 * did not exist in the system.
90 */
91 public int getQuarkAbsolute(String... attribute)
92 throws AttributeNotFoundException;
93
94 /**
95 * "Relative path" quark-getting method. Instead of specifying a full path,
96 * if you know the path is relative to another attribute for which you
97 * already have the quark, use this for better performance.
98 *
99 * This is useful for cases where a lot of modifications or queries will
100 * originate from the same branch of the attribute tree : the common part of
101 * the path won't have to be re-hashed for every access.
102 *
103 * This version will NOT create any new attributes. If an invalid attribute
104 * is requested, an exception will be thrown.
105 *
106 * @param startingNodeQuark
107 * The quark of the attribute from which 'subPath' originates.
108 * @param subPath
109 * "Rest" of the path to get to the final attribute
110 * @return The matching quark, if it existed
111 * @throws AttributeNotFoundException
112 * If the quark is invalid
113 */
114 public int getQuarkRelative(int startingNodeQuark, String... subPath)
115 throws AttributeNotFoundException;
116
117 /**
118 * Return the sub-attributes of the target attribute, as a List of quarks.
119 *
120 * @param quark
121 * The attribute of which you want to sub-attributes. You can use
122 * "-1" here to specify the root node.
123 * @param recursive
124 * True if you want all recursive sub-attributes, false if you
125 * only want the first level.
126 * @return A List of integers, matching the quarks of the sub-attributes.
127 * @throws AttributeNotFoundException
128 * If the quark was not existing or invalid.
129 */
130 public List<Integer> getSubAttributes(int quark, boolean recursive)
131 throws AttributeNotFoundException;
132
133 /**
134 * Batch quark-retrieving method. This method allows you to specify a path
135 * pattern which includes a wildcard "*" somewhere. It will check all the
136 * existing attributes in the attribute tree and return those who match the
137 * pattern.
138 *
139 * For example, passing ("Threads", "*", "Exec_mode") will return the list
140 * of quarks for attributes "Threads/1000/Exec_mode",
141 * "Threads/1500/Exec_mode", and so on, depending on what exists at this
142 * time in the attribute tree.
143 *
144 * If no wildcard is specified, the behavior is the same as
145 * getQuarkAbsolute() (except it will return a List with one entry). This
146 * method will never create new attributes.
147 *
148 * Only one wildcard "*" is supported at this time.
149 *
150 * @param pattern
151 * The array of strings representing the pattern to look for. It
152 * should ideally contain one entry that is only a "*".
153 * @return A List of attribute quarks, representing attributes that matched
154 * the pattern. If no attribute matched, the list will be empty (but
155 * not null).
156 */
157 public List<Integer> getQuarks(String... pattern);
158
159 /**
160 * Return the name assigned to this quark. This returns only the "basename",
161 * not the complete path to this attribute.
162 *
163 * @param attributeQuark
164 * The quark for which we want the name
165 * @return The name of the quark
166 */
167 public String getAttributeName(int attributeQuark);
168
169 /**
170 * This returns the slash-separated path of an attribute by providing its
171 * quark
172 *
173 * @param attributeQuark
174 * The quark of the attribute we want
175 * @return One single string separated with '/', like a filesystem path
176 */
177 public String getFullAttributePath(int attributeQuark);
178
179 /**
180 * @name Query methods
181 */
182
183 /**
184 * Returns the current state value we have (in the Transient State) for the
185 * given attribute.
186 *
187 * This is useful even for a StateHistorySystem, as we are guaranteed it
188 * will only do a memory access and not go look on disk (and we don't even
189 * have to provide a timestamp!)
190 *
191 * @param attributeQuark
192 * For which attribute we want the current state
193 * @return The State value that's "current" for this attribute
194 * @throws AttributeNotFoundException
195 * If the requested attribute is invalid
196 */
197 public ITmfStateValue queryOngoingState(int attributeQuark)
198 throws AttributeNotFoundException;
199
200 /**
201 * Load the complete state information at time 't' into the returned List.
202 * You can then get the intervals for single attributes by using
203 * List.get(n), where 'n' is the quark of the attribute.
204 *
205 * On average if you need around 10 or more queries for the same timestamps,
206 * use this method. If you need less than 10 (for example, running many
207 * queries for the same attributes but at different timestamps), you might
208 * be better using the querySingleState() methods instead.
209 *
210 * @param t
211 * We will recreate the state information to what it was at time
212 * t.
213 * @return The List of intervals, where the offset = the quark
214 * @throws TimeRangeException
215 * If the 't' parameter is outside of the range of the state
216 * history.
217 */
218 public List<ITmfStateInterval> queryFullState(long t)
219 throws TimeRangeException;
220
221 /**
222 * Singular query method. This one does not update the whole stateInfo
223 * vector, like queryFullState() does. It only searches for one specific
224 * entry in the state history.
225 *
226 * It should be used when you only want very few entries, instead of the
227 * whole state (or many entries, but all at different timestamps). If you do
228 * request many entries all at the same time, you should use the
229 * conventional queryFullState() + List.get() method.
230 *
231 * @param t
232 * The timestamp at which we want the state
233 * @param attributeQuark
234 * Which attribute we want to get the state of
235 * @return The StateInterval representing the state
236 * @throws TimeRangeException
237 * If 't' is invalid
238 * @throws AttributeNotFoundException
239 * If the requested quark does not exist in the model
240 */
241 public ITmfStateInterval querySingleState(long t, int attributeQuark)
242 throws AttributeNotFoundException, TimeRangeException;
243
244 /**
245 * Convenience method to query attribute stacks (created with
246 * pushAttribute()/popAttribute()). This will return the interval that is
247 * currently at the top of the stack, or 'null' if that stack is currently
248 * empty. It works similarly to querySingleState().
249 *
250 * To retrieve the other values in a stack, you can query the sub-attributes
251 * manually.
252 *
253 * @param t
254 * The timestamp of the query
255 * @param stackAttributeQuark
256 * The top-level stack-attribute (that was the target of
257 * pushAttribute() at creation time)
258 * @return The interval that was at the top of the stack, or 'null' if the
259 * stack was empty.
260 * @throws StateValueTypeException
261 * If the target attribute is not a valid stack attribute (if it
262 * has a string value for example)
263 * @throws AttributeNotFoundException
264 * If the attribute was simply not found
265 * @throws TimeRangeException
266 * If the given timestamp is invalid
267 * @since 2.0
268 */
269 public ITmfStateInterval querySingleStackTop(long t, int stackAttributeQuark)
270 throws StateValueTypeException, AttributeNotFoundException,
271 TimeRangeException;
272
273 /**
274 * Return a list of state intervals, containing the "history" of a given
275 * attribute between timestamps t1 and t2. The list will be ordered by
276 * ascending time.
277 *
278 * Note that contrary to queryFullState(), the returned list here is in the
279 * "direction" of time (and not in the direction of attributes, as is the
280 * case with queryFullState()).
281 *
282 * @param attributeQuark
283 * Which attribute this query is interested in
284 * @param t1
285 * Start time of the range query
286 * @param t2
287 * Target end time of the query. If t2 is greater than the end of
288 * the trace, we will return what we have up to the end of the
289 * history.
290 * @return The List of state intervals that happened between t1 and t2
291 * @throws TimeRangeException
292 * If t1 is invalid, or if t2 <= t1
293 * @throws AttributeNotFoundException
294 * If the requested quark does not exist in the model.
295 */
296 public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
297 long t1, long t2) throws TimeRangeException,
298 AttributeNotFoundException;
299
300 /**
301 * Return the state history of a given attribute, but with at most one
302 * update per "resolution". This can be useful for populating views (where
303 * it's useless to have more than one query per pixel, for example). A
304 * progress monitor can be used to cancel the query before completion.
305 *
306 * @param attributeQuark
307 * Which attribute this query is interested in
308 * @param t1
309 * Start time of the range query
310 * @param t2
311 * Target end time of the query. If t2 is greater than the end of
312 * the trace, we will return what we have up to the end of the
313 * history.
314 * @param resolution
315 * The "step" of this query
316 * @param monitor
317 * A progress monitor. If the monitor is canceled during a query,
318 * we will return what has been found up to that point. You can
319 * use "null" if you do not want to use one.
320 * @return The List of states that happened between t1 and t2
321 * @throws TimeRangeException
322 * If t1 is invalid, if t2 <= t1, or if the resolution isn't
323 * greater than zero.
324 * @throws AttributeNotFoundException
325 * If the attribute doesn't exist
326 * @since 2.0
327 */
328 public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
329 long t1, long t2, long resolution, IProgressMonitor monitor)
330 throws TimeRangeException, AttributeNotFoundException;
331 }
This page took 0.038969 seconds and 6 git commands to generate.