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
.tmf
.core
.event
.TmfEvent
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
20 * <b><u>TmfCoalescedEventRequest</u></b>
22 * TODO: Implement me. Please.
24 public class TmfCoalescedEventRequest
<T
extends TmfEvent
> extends TmfCoalescedDataRequest
<T
> implements ITmfEventRequest
<T
> {
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 private TmfTimeRange fRange
; // The requested events time range
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
39 public TmfCoalescedEventRequest(Class
<T
> dataType
) {
40 this(dataType
, TmfTimeRange
.Eternity
, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
43 public TmfCoalescedEventRequest(Class
<T
> dataType
, ExecutionType execType
) {
44 this(dataType
, TmfTimeRange
.Eternity
, ALL_DATA
, DEFAULT_BLOCK_SIZE
, execType
);
50 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
) {
51 this(dataType
, range
, ALL_DATA
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
54 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, ExecutionType execType
) {
55 this(dataType
, range
, ALL_DATA
, DEFAULT_BLOCK_SIZE
, execType
);
62 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
) {
63 this(dataType
, range
, nbRequested
, DEFAULT_BLOCK_SIZE
, ExecutionType
.FOREGROUND
);
66 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, ExecutionType execType
) {
67 this(dataType
, range
, nbRequested
, DEFAULT_BLOCK_SIZE
, execType
);
73 * @param blockSize Size of the largest blocks expected
75 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
) {
76 super(dataType
, 0, nbRequested
, blockSize
, ExecutionType
.FOREGROUND
);
80 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int nbRequested
, int blockSize
, ExecutionType execType
) {
81 super(dataType
, 0, nbRequested
, blockSize
, execType
);
85 public TmfCoalescedEventRequest(Class
<T
> dataType
, TmfTimeRange range
, int index
, int nbRequested
, int blockSize
, ExecutionType execType
) {
86 super(dataType
, index
, nbRequested
, blockSize
, execType
);
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 public boolean isCompatible(ITmfDataRequest
<T
> request
) {
96 if (request
instanceof ITmfEventRequest
<?
>) {
97 boolean ok
= getNbRequested() == request
.getNbRequested();
98 ok
&= getIndex() == request
.getIndex();
99 ok
&= getExecType() == request
.getExecType();
100 //ok &= getDataType() == request.getDataType();
102 TmfTimestamp startTime
= ((ITmfEventRequest
<T
>) request
).getRange().getStartTime();
103 TmfTimestamp endTime
= ((ITmfEventRequest
<T
>) request
).getRange().getEndTime();
104 if (!fRange
.contains(startTime
))
105 fRange
= new TmfTimeRange(startTime
, fRange
.getEndTime());
106 if (!fRange
.contains(endTime
))
107 fRange
= new TmfTimeRange(fRange
.getStartTime(), endTime
);
114 // ------------------------------------------------------------------------
116 // ------------------------------------------------------------------------
119 public void handleData(T data
) {
120 super.handleData(data
);
121 for (ITmfDataRequest
<T
> request
: fRequests
) {
123 request
.handleData(null);
125 if (request
instanceof TmfEventRequest
<?
>) {
126 TmfEventRequest
<T
> req
= (TmfEventRequest
<T
>) request
;
127 if (!req
.isCompleted()) {
128 TmfTimestamp ts
= data
.getTimestamp();
129 if (req
.getRange().contains(ts
)) {
130 if (req
.getDataType().isInstance(data
)) {
131 req
.handleData(data
);
137 TmfDataRequest
<T
> req
= (TmfDataRequest
<T
>) request
;
138 if (!req
.isCompleted()) {
139 if (req
.getDataType().isInstance(data
)) {
140 req
.handleData(data
);
148 // ------------------------------------------------------------------------
150 // ------------------------------------------------------------------------
153 public TmfTimeRange
getRange() {
158 public void setStartIndex(int index
) {
162 // ------------------------------------------------------------------------
164 // ------------------------------------------------------------------------
167 // All requests have a unique id
168 public int hashCode() {
169 return super.hashCode();
173 public boolean equals(Object other
) {
174 if (other
instanceof TmfCoalescedEventRequest
<?
>) {
175 TmfCoalescedEventRequest
<?
> request
= (TmfCoalescedEventRequest
<?
>) other
;
176 return (request
.getDataType() == getDataType()) &&
177 (request
.getIndex() == getIndex()) &&
178 (request
.getNbRequested() == getNbRequested()) &&
179 (request
.getRange().equals(getRange()));
181 if (other
instanceof TmfCoalescedDataRequest
<?
>) {
182 return super.equals(other
);
188 @SuppressWarnings("nls")
189 public String
toString() {
190 return "[TmfCoalescedEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
191 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
This page took 0.038272 seconds and 5 git commands to generate.