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