Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2009, 2015 Ericsson |
0283f7ff | 3 | * |
8c8bf09f ASL |
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 | |
0283f7ff | 8 | * |
8c8bf09f ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
fd3f1eff | 11 | * Alexandre Montplaisir - Merge with ITmfDataRequest |
8c8bf09f ASL |
12 | *******************************************************************************/ |
13 | ||
2bdf0193 | 14 | package org.eclipse.tracecompass.tmf.core.request; |
8c8bf09f | 15 | |
41f3b36b | 16 | import org.eclipse.jdt.annotation.NonNull; |
2bdf0193 | 17 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
8a580390 | 18 | import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter; |
2bdf0193 | 19 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
8c8bf09f ASL |
20 | |
21 | /** | |
8fd82db5 | 22 | * The TMF event request |
0283f7ff | 23 | * |
8fd82db5 | 24 | * @author Francois Chouinard |
8c8bf09f | 25 | */ |
fd3f1eff AM |
26 | public interface ITmfEventRequest { |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Constants | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
8a580390 BH |
32 | /** |
33 | * The request count for all the events | |
8a580390 | 34 | */ |
2740e05c AM |
35 | static final int ALL_DATA = Integer.MAX_VALUE; |
36 | ||
8a580390 BH |
37 | /** |
38 | * The request execution type/priority | |
8a580390 | 39 | */ |
fd3f1eff AM |
40 | enum ExecutionType { |
41 | /** | |
42 | * Backgroung, long-running, lower priority request | |
43 | */ | |
44 | BACKGROUND, | |
45 | /** | |
46 | * Foreground, short-running, high priority request | |
47 | */ | |
48 | FOREGROUND | |
49 | } | |
50 | ||
51 | // ------------------------------------------------------------------------ | |
52 | // Accessors | |
53 | // ------------------------------------------------------------------------ | |
54 | ||
55 | /** | |
56 | * @return request data type (T) | |
57 | */ | |
58 | Class<? extends ITmfEvent> getDataType(); | |
59 | ||
60 | /** | |
61 | * @return request ID | |
62 | */ | |
63 | int getRequestId(); | |
64 | ||
65 | /** | |
66 | * @return request ID | |
67 | */ | |
68 | ExecutionType getExecType(); | |
69 | ||
70 | /** | |
71 | * @return the index of the first event requested | |
72 | */ | |
73 | long getIndex(); | |
74 | ||
75 | /** | |
76 | * @return the number of requested events | |
77 | */ | |
78 | int getNbRequested(); | |
79 | ||
80 | /** | |
81 | * @return the number of events read so far | |
82 | */ | |
83 | int getNbRead(); | |
8c8bf09f ASL |
84 | |
85 | /** | |
86 | * @return the requested time range | |
87 | */ | |
57a2a5ca | 88 | TmfTimeRange getRange(); |
8c8bf09f | 89 | |
6badfac0 | 90 | /** |
8a580390 BH |
91 | * @return the event provider filter to verify if an event is provided by |
92 | * the relevant event provider. | |
6badfac0 | 93 | */ |
8a580390 | 94 | ITmfFilter getProviderFilter(); |
6badfac0 BH |
95 | |
96 | /** | |
8a580390 BH |
97 | * Sets a provider filter to verify if an event is provided by the relevant |
98 | * event provider. | |
6badfac0 | 99 | * |
8a580390 BH |
100 | * @param filter |
101 | * event provider filter to set | |
6badfac0 | 102 | */ |
8a580390 | 103 | void setProviderFilter(ITmfFilter filter); |
6badfac0 | 104 | |
fd3f1eff AM |
105 | // ------------------------------------------------------------------------ |
106 | // Request state predicates | |
107 | // ------------------------------------------------------------------------ | |
108 | ||
109 | /** | |
110 | * @return true if the request is still active | |
111 | */ | |
112 | boolean isRunning(); | |
113 | ||
114 | /** | |
115 | * @return true if the request is completed | |
116 | */ | |
117 | boolean isCompleted(); | |
118 | ||
119 | /** | |
120 | * @return true if the request has failed | |
121 | */ | |
122 | boolean isFailed(); | |
123 | ||
124 | /** | |
125 | * @return true if the request was cancelled | |
126 | */ | |
127 | boolean isCancelled(); | |
128 | ||
129 | // ------------------------------------------------------------------------ | |
130 | // Data handling | |
131 | // ------------------------------------------------------------------------ | |
132 | ||
133 | /** | |
134 | * Process the piece of data | |
135 | * | |
136 | * @param event | |
137 | * The trace event to process | |
138 | */ | |
41f3b36b | 139 | void handleData(@NonNull ITmfEvent event); |
fd3f1eff AM |
140 | |
141 | // ------------------------------------------------------------------------ | |
142 | // Request notifications | |
143 | // ------------------------------------------------------------------------ | |
144 | ||
145 | /** | |
146 | * Request processing start notification | |
147 | */ | |
148 | void handleStarted(); | |
149 | ||
150 | /** | |
151 | * Request processing completion notification | |
152 | */ | |
153 | void handleCompleted(); | |
154 | ||
155 | /** | |
156 | * Request successful completion notification | |
157 | */ | |
158 | void handleSuccess(); | |
159 | ||
160 | /** | |
161 | * Request failure notification | |
162 | */ | |
163 | void handleFailure(); | |
164 | ||
165 | /** | |
166 | * Request cancellation notification | |
167 | */ | |
168 | void handleCancel(); | |
169 | ||
170 | /** | |
171 | * To suspend the client thread until the request completes (or is | |
172 | * cancelled). | |
173 | * | |
174 | * @throws InterruptedException | |
175 | * thrown if the request was cancelled | |
176 | */ | |
177 | void waitForCompletion() throws InterruptedException; | |
178 | ||
179 | // ------------------------------------------------------------------------ | |
180 | // Request state modifiers | |
181 | // ------------------------------------------------------------------------ | |
182 | ||
183 | /** | |
184 | * Put the request in the running state | |
185 | */ | |
186 | void start(); | |
187 | ||
188 | /** | |
189 | * Put the request in the completed state | |
190 | */ | |
191 | void done(); | |
192 | ||
193 | /** | |
194 | * Put the request in the failed completed state | |
195 | */ | |
196 | void fail(); | |
197 | ||
198 | /** | |
199 | * Put the request in the cancelled completed state | |
200 | */ | |
201 | void cancel(); | |
202 | ||
203 | // ------------------------------------------------------------------------ | |
204 | // Others | |
205 | // ------------------------------------------------------------------------ | |
206 | ||
a79913eb | 207 | /** |
fd3f1eff AM |
208 | * This method is called by the event provider to set the index |
209 | * corresponding to the time range start time | |
210 | * | |
211 | * @param index | |
212 | * The start time index | |
a79913eb | 213 | */ |
57a2a5ca | 214 | void setStartIndex(int index); |
a79913eb | 215 | |
8c8bf09f | 216 | } |