Internalize some classes and fix a pile of warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / request / TmfEventRequest.java
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
13 package org.eclipse.linuxtools.tmf.core.request;
14
15 import org.eclipse.linuxtools.internal.tmf.core.Tracer;
16 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
17 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
18
19 /**
20 * An extension of TmfDataRequest for timestamped events.
21 *
22 * @version 1.0
23 * @author Francois Chouinard
24 */
25 public abstract class TmfEventRequest<T extends ITmfEvent> extends TmfDataRequest<T> implements ITmfEventRequest<T> {
26
27 // ------------------------------------------------------------------------
28 // Attributes
29 // ------------------------------------------------------------------------
30
31 private final TmfTimeRange fRange; // The requested events time range
32
33 // ------------------------------------------------------------------------
34 // Constructors
35 // ------------------------------------------------------------------------
36
37 /**
38 * Request all the events of a given type (high priority)
39 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
40 *
41 * @param dataType the requested data type
42 */
43 public TmfEventRequest(Class<T> dataType) {
44 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
45 }
46
47 /**
48 * Request all the events of a given type (given priority)
49 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
50 *
51 * @param dataType the requested data type
52 * @param priority the requested execution priority
53 */
54 public TmfEventRequest(Class<T> dataType, ExecutionType priority) {
55 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
56 }
57
58 /**
59 * Request all the events of a given type for the given time range (high priority)
60 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
61 *
62 * @param dataType the requested data type
63 * @param range the time range of the requested events
64 */
65 public TmfEventRequest(Class<T> dataType, TmfTimeRange range) {
66 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
67 }
68
69 /**
70 * Request all the events of a given type for the given time range (given priority)
71 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
72 *
73 * @param dataType the requested data type
74 * @param range the time range of the requested events
75 * @param priority the requested execution priority
76 */
77 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, ExecutionType priority) {
78 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
79 }
80
81 /**
82 * Request 'n' events of a given type from the given time range (high priority)
83 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
84 *
85 * @param dataType the requested data type
86 * @param range the time range of the requested events
87 * @param nbRequested the number of events requested
88 */
89 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested) {
90 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
91 }
92
93 /**
94 * Request 'n' events of a given type for the given time range (given priority)
95 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
96 *
97 * @param dataType the requested data type
98 * @param range the time range of the requested events
99 * @param nbRequested the number of events requested
100 * @param priority the requested execution priority
101 */
102 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) {
103 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, priority);
104 }
105
106 /**
107 * Request 'n' events of a given type for the given time range (high priority).
108 * Events are returned in blocks of the given size.
109 *
110 * @param dataType the requested data type
111 * @param range the time range of the requested events
112 * @param nbRequested the number of events requested
113 * @param blockSize the number of events per block
114 */
115 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize) {
116 this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
117 }
118
119 /**
120 * Request 'n' events of a given type for the given time range (high priority).
121 * Events are returned in blocks of the given size.
122 *
123 * @param dataType the requested data type
124 * @param range the time range of the requested events
125 * @param index the index of the first event to retrieve
126 * @param nbRequested the number of events requested
127 * @param blockSize the number of events per block
128 */
129 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize) {
130 this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
131 }
132
133 /**
134 * Request 'n' events of a given type for the given time range (given priority).
135 * Events are returned in blocks of the given size.
136 *
137 * @param dataType the requested data type
138 * @param range the time range of the requested events
139 * @param nbRequested the number of events requested
140 * @param blockSize the number of events per block
141 * @param priority the requested execution priority
142 */
143 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) {
144 this(dataType, range, 0, nbRequested, blockSize, priority);
145 }
146
147 /**
148 * Request 'n' events of a given type for the given time range (given priority).
149 * Events are returned in blocks of the given size.
150 *
151 * @param dataType the requested data type
152 * @param range the time range of the requested events
153 * @param index the index of the first event to retrieve
154 * @param nbRequested the number of events requested
155 * @param blockSize the number of events per block
156 * @param priority the requested execution priority
157 */
158 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize, ExecutionType priority) {
159 super(dataType, index, nbRequested, blockSize, priority);
160 fRange = range;
161
162 if (Tracer.isRequestTraced()) {
163 String type = getClass().getName();
164 type = type.substring(type.lastIndexOf('.') + 1);
165 @SuppressWarnings("nls")
166 String message = "CREATED "
167 + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
168 + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
169 + " Range=" + getRange()
170 + " DataType=" + getDataType().getSimpleName();
171 Tracer.traceRequest(this, message);
172 }
173 }
174
175 // ------------------------------------------------------------------------
176 // Accessors
177 // ------------------------------------------------------------------------
178
179 /**
180 * @return the requested time range
181 */
182 @Override
183 public TmfTimeRange getRange() {
184 return fRange;
185 }
186
187 // ------------------------------------------------------------------------
188 // Setters
189 // ------------------------------------------------------------------------
190
191 /**
192 * this method is called by the event provider to set the index corresponding
193 * to the time range start time once it is known
194 *
195 * @param index the start index
196 */
197 @Override
198 public void setStartIndex(int index) {
199 setIndex(index);
200 }
201
202 // ------------------------------------------------------------------------
203 // Object
204 // ------------------------------------------------------------------------
205
206 @Override
207 // All requests have a unique id
208 public int hashCode() {
209 return getRequestId();
210 }
211
212 @Override
213 public boolean equals(Object other) {
214 if (other instanceof TmfEventRequest<?>) {
215 TmfEventRequest<?> request = (TmfEventRequest<?>) other;
216 return super.equals(other) && request.fRange.equals(fRange);
217 }
218 return false;
219 }
220
221 @Override
222 @SuppressWarnings("nls")
223 public String toString() {
224 return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
225 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
226 }
227
228 }
This page took 0.04339 seconds and 6 git commands to generate.