1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.request
;
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
;
20 * An extension of TmfDataRequest for timestamped events.
22 * @param <T> The request event type
25 * @author Francois Chouinard
27 public abstract class TmfEventRequest
<T
extends ITmfEvent
> extends TmfDataRequest
<T
> implements ITmfEventRequest
<T
> {
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 private final TmfTimeRange fRange
; // The requested events time range
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 * Request all the events of a given type (high priority)
41 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
43 * @param dataType the requested data type
45 public TmfEventRequest(Class
<T
> dataType
) {
46 this(dataType
, TmfTimeRange
.ETERNITY
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
50 * Request all the events of a given type (given priority)
51 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
53 * @param dataType the requested data type
54 * @param priority the requested execution priority
56 public TmfEventRequest(Class
<T
> dataType
, ExecutionType priority
) {
57 this(dataType
, TmfTimeRange
.ETERNITY
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, priority
);
61 * Request all the events of a given type for the given time range (high priority)
62 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
64 * @param dataType the requested data type
65 * @param range the time range of the requested events
67 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
) {
68 this(dataType
, range
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
72 * Request all the events of a given type for the given time range (given priority)
73 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
75 * @param dataType the requested data type
76 * @param range the time range of the requested events
77 * @param priority the requested execution priority
79 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, ExecutionType priority
) {
80 this(dataType
, range
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, priority
);
84 * Request 'n' events of a given type from the given time range (high priority)
85 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
87 * @param dataType the requested data type
88 * @param range the time range of the requested events
89 * @param nbRequested the number of events requested
91 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
) {
92 this(dataType
, range
, 0, nbRequested
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
96 * Request 'n' events of a given type for the given time range (given priority)
97 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
99 * @param dataType the requested data type
100 * @param range the time range of the requested events
101 * @param nbRequested the number of events requested
102 * @param priority the requested execution priority
104 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, ExecutionType priority
) {
105 this(dataType
, range
, 0, nbRequested
, DEFAULT_BLOCK_SIZE
, priority
);
109 * Request 'n' events of a given type for the given time range (high priority).
110 * Events are returned in blocks of the given size.
112 * @param dataType the requested data type
113 * @param range the time range of the requested events
114 * @param nbRequested the number of events requested
115 * @param blockSize the number of events per block
117 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
) {
118 this(dataType
, range
, 0, nbRequested
, blockSize
, ExecutionType
.FOREGROUND
);
122 * Request 'n' events of a given type for the given time range (high priority).
123 * Events are returned in blocks of the given size.
125 * @param dataType the requested data type
126 * @param range the time range of the requested events
127 * @param index the index of the first event to retrieve
128 * @param nbRequested the number of events requested
129 * @param blockSize the number of events per block
131 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, long index
, int nbRequested
, int blockSize
) {
132 this(dataType
, range
, index
, nbRequested
, blockSize
, ExecutionType
.FOREGROUND
);
136 * Request 'n' events of a given type for the given time range (given priority).
137 * Events are returned in blocks of the given size.
139 * @param dataType the requested data type
140 * @param range the time range of the requested events
141 * @param nbRequested the number of events requested
142 * @param blockSize the number of events per block
143 * @param priority the requested execution priority
145 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
, ExecutionType priority
) {
146 this(dataType
, range
, 0, nbRequested
, blockSize
, priority
);
150 * Request 'n' events of a given type for the given time range (given priority).
151 * Events are returned in blocks of the given size.
153 * @param dataType the requested data type
154 * @param range the time range of the requested events
155 * @param index the index of the first event to retrieve
156 * @param nbRequested the number of events requested
157 * @param blockSize the number of events per block
158 * @param priority the requested execution priority
160 public TmfEventRequest(Class
<T
> dataType
, TmfTimeRange range
, long index
, int nbRequested
, int blockSize
, ExecutionType priority
) {
161 super(dataType
, index
, nbRequested
, blockSize
, priority
);
164 if (Tracer
.isRequestTraced()) {
165 String type
= getClass().getName();
166 type
= type
.substring(type
.lastIndexOf('.') + 1);
167 @SuppressWarnings("nls")
168 String message
= "CREATED "
169 + (getExecType() == ITmfDataRequest
.ExecutionType
.BACKGROUND ?
"(BG)" : "(FG)")
170 + " Type=" + type
+ " Index=" + getIndex() + " NbReq=" + getNbRequested()
171 + " Range=" + getRange()
172 + " DataType=" + getDataType().getSimpleName();
173 Tracer
.traceRequest(this, message
);
177 // ------------------------------------------------------------------------
179 // ------------------------------------------------------------------------
182 * @return the requested time range
185 public TmfTimeRange
getRange() {
189 // ------------------------------------------------------------------------
191 // ------------------------------------------------------------------------
194 * this method is called by the event provider to set the index corresponding
195 * to the time range start time once it is known
197 * @param index the start index
200 public void setStartIndex(int index
) {
204 // ------------------------------------------------------------------------
206 // ------------------------------------------------------------------------
209 // All requests have a unique id
210 public int hashCode() {
211 return getRequestId();
215 public boolean equals(Object other
) {
216 if (other
instanceof TmfEventRequest
<?
>) {
217 TmfEventRequest
<?
> request
= (TmfEventRequest
<?
>) other
;
218 return super.equals(other
) && request
.fRange
.equals(fRange
);
224 @SuppressWarnings("nls")
225 public String
toString() {
226 return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
227 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
This page took 0.03642 seconds and 6 git commands to generate.