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