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
.TmfCoreTracer
;
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.
23 * @author Francois Chouinard
25 public abstract class TmfEventRequest
extends TmfDataRequest
implements ITmfEventRequest
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 private final TmfTimeRange fRange
; // The requested events time range
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
38 * Request all the events of a given type (high priority)
39 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
41 * @param dataType the requested data type
43 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
) {
44 this(dataType
, TmfTimeRange
.ETERNITY
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
48 * Request all the events of a given type (given priority)
49 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
51 * @param dataType the requested data type
52 * @param priority the requested execution priority
54 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, ExecutionType priority
) {
55 this(dataType
, TmfTimeRange
.ETERNITY
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, priority
);
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).
62 * @param dataType the requested data type
63 * @param range the time range of the requested events
65 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
) {
66 this(dataType
, range
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
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).
73 * @param dataType the requested data type
74 * @param range the time range of the requested events
75 * @param priority the requested execution priority
77 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, ExecutionType priority
) {
78 this(dataType
, range
, 0, ALL_DATA
, DEFAULT_BLOCK_SIZE
, priority
);
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).
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
89 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
) {
90 this(dataType
, range
, 0, nbRequested
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
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).
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
102 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
, ExecutionType priority
) {
103 this(dataType
, range
, 0, nbRequested
, DEFAULT_BLOCK_SIZE
, priority
);
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.
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
115 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
) {
116 this(dataType
, range
, 0, nbRequested
, blockSize
, ExecutionType
.FOREGROUND
);
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.
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
129 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, long index
, int nbRequested
, int blockSize
) {
130 this(dataType
, range
, index
, nbRequested
, blockSize
, ExecutionType
.FOREGROUND
);
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.
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
143 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
, ExecutionType priority
) {
144 this(dataType
, range
, 0, nbRequested
, blockSize
, priority
);
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.
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
158 public TmfEventRequest(Class
<?
extends ITmfEvent
> dataType
, TmfTimeRange range
, long index
, int nbRequested
, int blockSize
, ExecutionType priority
) {
159 super(dataType
, index
, nbRequested
, blockSize
, priority
);
162 if (TmfCoreTracer
.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 TmfCoreTracer
.traceRequest(this, message
);
175 // ------------------------------------------------------------------------
177 // ------------------------------------------------------------------------
180 * @return the requested time range
183 public TmfTimeRange
getRange() {
187 // ------------------------------------------------------------------------
189 // ------------------------------------------------------------------------
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
195 * @param index the start index
198 public void setStartIndex(int index
) {
202 // ------------------------------------------------------------------------
204 // ------------------------------------------------------------------------
207 // All requests have a unique id
208 public int hashCode() {
209 return getRequestId();
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
);
222 @SuppressWarnings("nls")
223 public String
toString() {
224 return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
225 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
This page took 0.035205 seconds and 5 git commands to generate.