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