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