Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 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 | * 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; |
6c13869b | 16 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; |
8c8bf09f ASL |
17 | |
18 | /** | |
19 | * <b><u>TmfEventRequest</u></b> | |
20 | * <p> | |
21 | * Implement me. Please. | |
22 | */ | |
72f1e62a | 23 | public abstract class TmfEventRequest<T extends ITmfEvent> extends TmfDataRequest<T> implements ITmfEventRequest<T> { |
8c8bf09f ASL |
24 | |
25 | // ------------------------------------------------------------------------ | |
26 | // Attributes | |
27 | // ------------------------------------------------------------------------ | |
28 | ||
29 | private final TmfTimeRange fRange; // The requested events time range | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constructors | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | /** | |
0d9a6d76 FC |
36 | * Request all the events of a given type (high priority) |
37 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
38 | * | |
39 | * @param dataType the requested data type | |
8c8bf09f | 40 | */ |
951d134a | 41 | public TmfEventRequest(Class<T> dataType) { |
a4115405 | 42 | this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
43 | } |
44 | ||
0d9a6d76 FC |
45 | /** |
46 | * Request all the events of a given type (given priority) | |
47 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
48 | * | |
49 | * @param dataType the requested data type | |
50 | * @param priority the requested execution priority | |
51 | */ | |
52 | public TmfEventRequest(Class<T> dataType, ExecutionType priority) { | |
53 | this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority); | |
8c8bf09f ASL |
54 | } |
55 | ||
56 | /** | |
0d9a6d76 FC |
57 | * Request all the events of a given type for the given time range (high priority) |
58 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
59 | * | |
60 | * @param dataType the requested data type | |
61 | * @param range the time range of the requested events | |
8c8bf09f | 62 | */ |
951d134a | 63 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range) { |
a79913eb | 64 | this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
65 | } |
66 | ||
0d9a6d76 FC |
67 | /** |
68 | * Request all the events of a given type for the given time range (given priority) | |
69 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
70 | * | |
71 | * @param dataType the requested data type | |
72 | * @param range the time range of the requested events | |
73 | * @param priority the requested execution priority | |
74 | */ | |
75 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, ExecutionType priority) { | |
76 | this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority); | |
8c8bf09f ASL |
77 | } |
78 | ||
79 | /** | |
0d9a6d76 FC |
80 | * Request 'n' events of a given type from the given time range (high priority) |
81 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
82 | * | |
83 | * @param dataType the requested data type | |
84 | * @param range the time range of the requested events | |
85 | * @param nbRequested the number of events requested | |
8c8bf09f | 86 | */ |
951d134a | 87 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested) { |
a79913eb | 88 | this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
89 | } |
90 | ||
0d9a6d76 FC |
91 | /** |
92 | * Request 'n' events of a given type for the given time range (given priority) | |
93 | * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE). | |
94 | * | |
95 | * @param dataType the requested data type | |
96 | * @param range the time range of the requested events | |
97 | * @param nbRequested the number of events requested | |
98 | * @param priority the requested execution priority | |
99 | */ | |
100 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) { | |
101 | this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, priority); | |
8c8bf09f ASL |
102 | } |
103 | ||
104 | /** | |
0d9a6d76 FC |
105 | * Request 'n' events of a given type for the given time range (high priority). |
106 | * Events are returned in blocks of the given size. | |
107 | * | |
108 | * @param dataType the requested data type | |
109 | * @param range the time range of the requested events | |
110 | * @param nbRequested the number of events requested | |
111 | * @param blockSize the number of events per block | |
8c8bf09f | 112 | */ |
951d134a | 113 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize) { |
a79913eb | 114 | this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND); |
550d787e FC |
115 | } |
116 | ||
7e6347b0 FC |
117 | /** |
118 | * Request 'n' events of a given type for the given time range (high priority). | |
119 | * Events are returned in blocks of the given size. | |
120 | * | |
121 | * @param dataType the requested data type | |
122 | * @param range the time range of the requested events | |
123 | * @param index the index of the first event to retrieve | |
124 | * @param nbRequested the number of events requested | |
125 | * @param blockSize the number of events per block | |
126 | */ | |
127 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int index, int nbRequested, int blockSize) { | |
128 | this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND); | |
129 | } | |
130 | ||
0d9a6d76 FC |
131 | /** |
132 | * Request 'n' events of a given type for the given time range (given priority). | |
133 | * Events are returned in blocks of the given size. | |
134 | * | |
135 | * @param dataType the requested data type | |
136 | * @param range the time range of the requested events | |
137 | * @param nbRequested the number of events requested | |
138 | * @param blockSize the number of events per block | |
139 | * @param priority the requested execution priority | |
140 | */ | |
141 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) { | |
142 | this(dataType, range, 0, nbRequested, blockSize, priority); | |
a79913eb FC |
143 | } |
144 | ||
0d9a6d76 FC |
145 | /** |
146 | * Request 'n' events of a given type for the given time range (given priority). | |
147 | * Events are returned in blocks of the given size. | |
148 | * | |
149 | * @param dataType the requested data type | |
150 | * @param range the time range of the requested events | |
151 | * @param index the index of the first event to retrieve | |
152 | * @param nbRequested the number of events requested | |
153 | * @param blockSize the number of events per block | |
154 | * @param priority the requested execution priority | |
155 | */ | |
156 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int index, int nbRequested, int blockSize, ExecutionType priority) { | |
157 | super(dataType, index, nbRequested, blockSize, priority); | |
8c8bf09f ASL |
158 | fRange = range; |
159 | } | |
160 | ||
161 | // ------------------------------------------------------------------------ | |
162 | // Accessors | |
163 | // ------------------------------------------------------------------------ | |
164 | ||
165 | /** | |
166 | * @return the requested time range | |
167 | */ | |
d4011df2 FC |
168 | @Override |
169 | public TmfTimeRange getRange() { | |
8c8bf09f ASL |
170 | return fRange; |
171 | } | |
172 | ||
a79913eb FC |
173 | // ------------------------------------------------------------------------ |
174 | // Setters | |
175 | // ------------------------------------------------------------------------ | |
176 | ||
177 | /** | |
178 | * this method is called by the event provider to set the index corresponding | |
179 | * to the time range start time once it is known | |
0d9a6d76 FC |
180 | * |
181 | * @param index the start index | |
a79913eb FC |
182 | */ |
183 | @Override | |
184 | public void setStartIndex(int index) { | |
185 | setIndex(index); | |
186 | } | |
187 | ||
2fb2eb37 FC |
188 | // ------------------------------------------------------------------------ |
189 | // Object | |
190 | // ------------------------------------------------------------------------ | |
191 | ||
192 | @Override | |
193 | // All requests have a unique id | |
194 | public int hashCode() { | |
195 | return getRequestId(); | |
196 | } | |
197 | ||
198 | @Override | |
199 | public boolean equals(Object other) { | |
200 | if (other instanceof TmfEventRequest<?>) { | |
201 | TmfEventRequest<?> request = (TmfEventRequest<?>) other; | |
202 | return super.equals(other) && request.fRange.equals(fRange); | |
203 | } | |
204 | return false; | |
205 | } | |
206 | ||
207 | @Override | |
3b38ea61 | 208 | @SuppressWarnings("nls") |
2fb2eb37 FC |
209 | public String toString() { |
210 | return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName() | |
a79913eb | 211 | + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]"; |
2fb2eb37 FC |
212 | } |
213 | ||
8c8bf09f | 214 | } |