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