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; | |
2fb2eb37 FC |
17 | import org.eclipse.linuxtools.tmf.request.ITmfDataRequest; |
18 | import org.eclipse.linuxtools.tmf.request.ITmfEventRequest; | |
951d134a | 19 | import org.eclipse.linuxtools.tmf.request.TmfCoalescedEventRequest; |
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 | ||
ce785d7d FC |
28 | public TmfEventProvider(String name, Class<T> type) { |
29 | super(name, type); | |
8c8bf09f ASL |
30 | } |
31 | ||
ce785d7d FC |
32 | public TmfEventProvider(String name, Class<T> type, int queueSize) { |
33 | super(name, type, queueSize); | |
8c8bf09f | 34 | } |
377f1ad8 WB |
35 | |
36 | public TmfEventProvider(TmfEventProvider<T> oldProvider) { | |
37 | super(oldProvider); | |
38 | } | |
39 | ||
8c8bf09f | 40 | @Override |
2fb2eb37 | 41 | public boolean isCompleted(ITmfDataRequest<T> request, T data, int nbRead) { |
8c8bf09f | 42 | boolean dataRequestCompleted = super.isCompleted(request, data, nbRead); |
36548af3 | 43 | if (!dataRequestCompleted && request instanceof ITmfEventRequest<?> && !data.isNullRef()) { |
2fb2eb37 | 44 | TmfTimestamp endTime = ((ITmfEventRequest<?>) request).getRange().getEndTime(); |
8c8bf09f ASL |
45 | return data.getTimestamp().compareTo(endTime, false) > 0; |
46 | } | |
47 | return dataRequestCompleted; | |
48 | } | |
49 | ||
951d134a | 50 | @Override |
2fb2eb37 FC |
51 | protected synchronized void newCoalescedDataRequest(ITmfDataRequest<T> request) { |
52 | if (request instanceof ITmfEventRequest<?>) { | |
53 | ITmfEventRequest<T> eventRequest = (ITmfEventRequest<T>) request; | |
951d134a | 54 | TmfCoalescedEventRequest<T> coalescedRequest = |
cb866e08 | 55 | new TmfCoalescedEventRequest<T>(fType, eventRequest.getRange(), eventRequest.getNbRequested(), eventRequest.getBlockize(), eventRequest.getExecType()); |
951d134a FC |
56 | coalescedRequest.addRequest(eventRequest); |
57 | fPendingCoalescedRequests.add(coalescedRequest); | |
58 | } | |
54d55ced FC |
59 | else { |
60 | super.newCoalescedDataRequest(request); | |
61 | } | |
951d134a FC |
62 | } |
63 | ||
8c8bf09f | 64 | } |