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