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