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