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
.component
;
15 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
16 import org
.eclipse
.linuxtools
.tmf
.event
.TmfSyntheticEventStub
;
17 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
18 import org
.eclipse
.linuxtools
.tmf
.request
.TmfDataRequest
;
19 import org
.eclipse
.linuxtools
.tmf
.request
.TmfEventRequest
;
20 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfContext
;
21 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
24 * <b><u>TmfSyntheticEventProviderStub</u></b>
26 * TODO: Implement me. Please.
28 public class TmfSyntheticEventProviderStub
extends TmfEventProvider
<TmfSyntheticEventStub
> {
30 public static final int BLOCK_SIZE
= 100;
31 public static final int NB_EVENTS
= 1000;
33 public TmfSyntheticEventProviderStub() {
34 super(TmfSyntheticEventStub
.class);
37 @SuppressWarnings("unchecked")
39 public ITmfContext
armRequest(final TmfDataRequest
<TmfSyntheticEventStub
> request
) {
41 // Get the TmfSyntheticEventStub provider
42 ITmfDataProvider
<TmfEvent
>[] eventProviders
= (ITmfDataProvider
<TmfEvent
>[]) TmfProviderManager
.getProviders(TmfEvent
.class, TmfEventProviderStub
.class);
43 ITmfDataProvider
<TmfEvent
> provider
= eventProviders
[0];
45 // make sure we have the right type of request
46 if (!(request
instanceof TmfEventRequest
<?
>)) {
51 TmfEventRequest
<TmfSyntheticEventStub
> eventRequest
= (TmfEventRequest
<TmfSyntheticEventStub
>) request
;
52 TmfTimeRange range
= eventRequest
.getRange();
53 final TmfEventRequest
<TmfEvent
> subRequest
=
54 new TmfEventRequest
<TmfEvent
>(TmfEvent
.class, range
, NB_EVENTS
, BLOCK_SIZE
) {
56 public void handleData() {
57 TmfEvent
[] events
= getData();
58 if (events
.length
> 0) {
59 for (TmfEvent e
: events
) {
60 handleIncomingData(e
);
67 provider
.sendRequest(subRequest
); // , false);
69 // Return a dummy context
70 return new TmfContext();
73 // Queue 2 synthetic events per base event
74 private void handleIncomingData(TmfEvent e
) {
75 queueResult(new TmfSyntheticEventStub(e
));
76 queueResult(new TmfSyntheticEventStub(e
));