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