970d3b5cb1f1f327926d83da428021409f441e00
[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.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
18 import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
19 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
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.
25 *
26 * @author alexmont
27 *
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.
34 *
35 * @return The history's registered start time
36 */
37 public long getStartTime();
38
39 /**
40 * Return the current end time of the history.
41 *
42 * @return
43 */
44 public long getCurrentEndTime();
45
46 /**
47 * Return the current total amount of attributes in the system.
48 *
49 * @return
50 */
51 public int getNbAttributes();
52
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.
60 *
61 * This version will NOT create any new attributes. If an invalid attribute
62 * is requested, an exception will be thrown.
63 *
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.
78 *
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.
82 *
83 * This version will NOT create any new attributes. If an invalid attribute
84 * is requested, an exception will be thrown.
85 *
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
92 */
93 public int getQuarkRelative(int startingNodeQuark, String... subPath)
94 throws AttributeNotFoundException;
95
96 /**
97 * Return the sub-attributes of the target attribute, as a List of quarks.
98 *
99 * @param quark
100 * The attribute of which you want to sub-attributes. You can use
101 * "-1" here to specify the root node.
102 * @param recursive
103 * True if you want all recursive sub-attributes, false if you
104 * only want the first level.
105 * @return A List of integers, matching the quarks of the sub-attributes.
106 * @throws AttributeNotFoundException
107 * If the quark was not existing or invalid.
108 */
109 public List<Integer> getSubAttributes(int quark, boolean recursive)
110 throws AttributeNotFoundException;
111
112 /**
113 * Batch quark-retrieving method. This method allows you to specify a path
114 * pattern which includes a wildcard "*" somewhere. It will check all the
115 * existing attributes in the attribute tree and return those who match the
116 * pattern.
117 *
118 * For example, passing ("Threads", "*", "Exec_mode") will return the list
119 * of quarks for attributes "Threads/1000/Exec_mode",
120 * "Threads/1500/Exec_mode", and so on, depending on what exists at this
121 * time in the attribute tree.
122 *
123 * If no wildcard is specified, the behavior is the same as
124 * getQuarkAbsolute() (except it will return a List with one entry). This
125 * method will never create new attributes.
126 *
127 * Only one wildcard "*" is supported at this time.
128 *
129 * @param pattern
130 * The array of strings representing the pattern to look for. It
131 * should ideally contain one entry that is only a "*".
132 * @return A List of attribute quarks, representing attributes that matched
133 * the pattern. If no attribute matched, the list will be empty (but
134 * not null).
135 */
136 public List<Integer> getQuarks(String... pattern);
137
138 /**
139 * Return the name assigned to this quark. This returns only the "basename",
140 * not the complete path to this attribute.
141 *
142 * @param attributeQuark
143 * The quark for which we want the name
144 * @return The name of the quark
145 */
146 public String getAttributeName(int attributeQuark);
147
148 /**
149 * This returns the slash-separated path of an attribute by providing its
150 * quark
151 *
152 * @param attributeQuark
153 * The quark of the attribute we want
154 * @return One single string separated with '/', like a filesystem path
155 */
156 public String getFullAttributePath(int attributeQuark);
157
158 /**
159 * @name Query methods
160 */
161
162 /**
163 * Returns the current state value we have (in the Transient State) for the
164 * given attribute.
165 *
166 * This is useful even for a StateHistorySystem, as we are guaranteed it
167 * will only do a memory access and not go look on disk (and we don't even
168 * have to provide a timestamp!)
169 *
170 * @param attributeQuark
171 * For which attribute we want the current state
172 * @return The State value that's "current" for this attribute
173 * @throws AttributeNotFoundException
174 * If the requested attribute is invalid
175 */
176 public ITmfStateValue queryOngoingState(int attributeQuark)
177 throws AttributeNotFoundException;
178
179 /**
180 * Load the complete state information at time 't' into the returned List.
181 * You can then get the intervals for single attributes by using
182 * List.get(n), where 'n' is the quark of the attribute.
183 *
184 * On average if you need around 10 or more queries for the same timestamps,
185 * use this method. If you need less than 10 (for example, running many
186 * queries for the same attributes but at different timestamps), you might
187 * be better using the querySingleState() methods instead.
188 *
189 * @param t
190 * We will recreate the state information to what it was at time
191 * t.
192 * @throws TimeRangeException
193 * If the 't' parameter is outside of the range of the state
194 * history.
195 */
196 public List<ITmfStateInterval> loadStateAtTime(long t)
197 throws TimeRangeException;
198
199 /**
200 * Singular query method. This one does not update the whole stateInfo
201 * vector, like loadStateAtTimes() does. It only searches for one specific
202 * entry in the state history.
203 *
204 * It should be used when you only want very few entries, instead of the
205 * whole state (or many entries, but all at different timestamps). If you do
206 * request many entries all at the same time, you should use the
207 * conventional loadStateAtTime() + List.get() method.
208 *
209 * @param t
210 * The timestamp at which we want the state
211 * @param attributeQuark
212 * Which attribute we want to get the state of
213 * @return The StateInterval representing the state
214 * @throws TimeRangeException
215 * If 't' is invalid
216 * @throws AttributeNotFoundException
217 * If the requested quark does not exist in the model
218 */
219 public ITmfStateInterval querySingleState(long t, int attributeQuark)
220 throws AttributeNotFoundException, TimeRangeException;
221
222 /**
223 * Return a list of state intervals, containing the "history" of a given
224 * attribute between timestamps t1 and t2. The list will be ordered by
225 * ascending time.
226 *
227 * Note that contrary to loadStateAtTime(), the returned list here is in the
228 * "direction" of time (and not in the direction of attributes, as is the
229 * case with loadStateAtTime()).
230 *
231 * @param attributeQuark
232 * Which attribute this query is interested in
233 * @param t1
234 * Start time of the range query
235 * @param t2
236 * Target end time of the query. If t2 is greater than the end of
237 * the trace, we will return what we have up to the end of the
238 * history.
239 * @return The List of state intervals that happened between t1 and t2
240 * @throws TimeRangeException
241 * If t1 is invalid, or if t2 <= t1
242 * @throws AttributeNotFoundException
243 * If the requested quark does not exist in the model.
244 */
245 public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
246 long t1, long t2) throws TimeRangeException,
247 AttributeNotFoundException;
248
249 /**
250 * Return the state history of a given attribute, but with at most one
251 * update per "resolution". This can be useful for populating views (where
252 * it's useless to have more than one query per pixel, for example).
253 *
254 * @param attributeQuark
255 * Which attribute this query is interested in
256 * @param t1
257 * Start time of the range query
258 * @param t2
259 * Target end time of the query. If t2 is greater than the end of
260 * the trace, we will return what we have up to the end of the
261 * history.
262 * @param resolution
263 * The "step" of this query
264 * @return The List of states that happened between t1 and t2
265 * @throws TimeRangeException
266 * If t1 is invalid, or if t2 <= t1
267 * @throws AttributeNotFoundException
268 * If the attribute doesn't exist
269 */
270 public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
271 long t1, long t2, long resolution) throws TimeRangeException,
272 AttributeNotFoundException;
273 }
This page took 0.036643 seconds and 4 git commands to generate.