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
.ITmfDataRequest
;
19 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfEventRequest
;
20 import org
.eclipse
.linuxtools
.tmf
.request
.TmfEventRequest
;
21 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfContext
;
22 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
25 * <b><u>TmfSyntheticEventProviderStub</u></b>
27 * TODO: Implement me. Please.
29 public class TmfSyntheticEventProviderStub
extends TmfEventProvider
<TmfSyntheticEventStub
> {
31 public static final int BLOCK_SIZE
= 100;
32 public static final int NB_EVENTS
= 1000;
34 public TmfSyntheticEventProviderStub() {
35 super("TmfSyntheticEventProviderStub", TmfSyntheticEventStub
.class);
38 @SuppressWarnings("unchecked")
40 public ITmfContext
armRequest(final ITmfDataRequest
<TmfSyntheticEventStub
> request
) {
42 // Get the TmfSyntheticEventStub provider
43 ITmfDataProvider
<TmfEvent
>[] eventProviders
= (ITmfDataProvider
<TmfEvent
>[]) TmfProviderManager
.getProviders(TmfEvent
.class, TmfEventProviderStub
.class);
44 ITmfDataProvider
<TmfEvent
> provider
= eventProviders
[0];
46 // make sure we have the right type of request
47 if (!(request
instanceof ITmfEventRequest
<?
>)) {
52 TmfEventRequest
<TmfSyntheticEventStub
> eventRequest
= (TmfEventRequest
<TmfSyntheticEventStub
>) request
;
53 TmfTimeRange range
= eventRequest
.getRange();
54 final TmfEventRequest
<TmfEvent
> subRequest
=
55 new TmfEventRequest
<TmfEvent
>(TmfEvent
.class, range
, NB_EVENTS
, BLOCK_SIZE
) {
57 public void handleData() {
58 TmfEvent
[] events
= getData();
59 if (events
.length
> 0) {
60 for (TmfEvent e
: events
) {
61 handleIncomingData(e
);
68 provider
.sendRequest(subRequest
); // , false);
70 // Return a dummy context
71 return new TmfContext();
74 // Queue 2 synthetic events per base event
75 private void handleIncomingData(TmfEvent e
) {
76 queueResult(new TmfSyntheticEventStub(e
));
77 queueResult(new TmfSyntheticEventStub(e
));