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 | ||
13 | package org.eclipse.linuxtools.tmf.component; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.event.TmfEvent; | |
16 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; | |
951d134a | 17 | import org.eclipse.linuxtools.tmf.request.TmfCoalescedEventRequest; |
fc6ccf6f FC |
18 | import org.eclipse.linuxtools.tmf.request.TmfDataRequest; |
19 | import org.eclipse.linuxtools.tmf.request.TmfEventRequest; | |
8c8bf09f ASL |
20 | |
21 | /** | |
22 | * <b><u>TmfEventProvider</u></b> | |
23 | * <p> | |
24 | * Implement me. Please. | |
25 | */ | |
26 | public abstract class TmfEventProvider<T extends TmfEvent> extends TmfDataProvider<T> { | |
27 | ||
fc6ccf6f FC |
28 | public TmfEventProvider(Class<T> type) { |
29 | super("TmfEventProvider", type); | |
8c8bf09f ASL |
30 | } |
31 | ||
fc6ccf6f FC |
32 | public TmfEventProvider(Class<T> type, int queueSize) { |
33 | super("TmfEventProvider", type, queueSize); | |
8c8bf09f | 34 | } |
fc6ccf6f | 35 | |
8c8bf09f | 36 | @Override |
fc6ccf6f | 37 | public boolean isCompleted(TmfDataRequest<T> request, T data, int nbRead) { |
8c8bf09f | 38 | boolean dataRequestCompleted = super.isCompleted(request, data, nbRead); |
fc6ccf6f FC |
39 | if (!dataRequestCompleted && request instanceof TmfEventRequest<?> && data != null) { |
40 | TmfTimestamp endTime = ((TmfEventRequest<?>) request).getRange().getEndTime(); | |
8c8bf09f ASL |
41 | return data.getTimestamp().compareTo(endTime, false) > 0; |
42 | } | |
43 | return dataRequestCompleted; | |
44 | } | |
45 | ||
951d134a FC |
46 | @Override |
47 | protected synchronized void newCoalescedDataRequest(TmfDataRequest<T> request) { | |
48 | if (request instanceof TmfEventRequest<?>) { | |
49 | TmfEventRequest<T> eventRequest = (TmfEventRequest<T>) request; | |
50 | TmfCoalescedEventRequest<T> coalescedRequest = | |
51 | new TmfCoalescedEventRequest<T>(fType, eventRequest.getRange(), eventRequest.getNbRequested(), eventRequest.getBlockize()); | |
52 | coalescedRequest.addRequest(eventRequest); | |
53 | fPendingCoalescedRequests.add(coalescedRequest); | |
54 | } | |
55 | } | |
56 | ||
8c8bf09f | 57 | } |