Commit | Line | Data |
---|---|---|
8a6ff07f | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2015 École Polytechnique de Montréal |
8a6ff07f GB |
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 | * Geneviève Bastien - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.tests.stubs.analysis; |
8a6ff07f | 14 | |
d0c7e4ba AM |
15 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; |
16 | ||
baa96b1d | 17 | import org.eclipse.jdt.annotation.NonNullByDefault; |
31d786ef | 18 | import org.eclipse.jdt.annotation.Nullable; |
2bdf0193 AM |
19 | import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; |
20 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
8a6ff07f GB |
21 | |
22 | /** | |
23 | * Test State System module | |
24 | * | |
25 | * @author Geneviève Bastien | |
26 | */ | |
baa96b1d | 27 | @NonNullByDefault |
8a6ff07f GB |
28 | public class TestStateSystemModule extends TmfStateSystemAnalysisModule { |
29 | ||
31d786ef GB |
30 | private @Nullable TestStateSystemProvider fProvider = null; |
31 | private boolean fThrottleEvents = false; | |
32 | ||
8a6ff07f | 33 | @Override |
baa96b1d | 34 | protected ITmfStateProvider createStateProvider() { |
31d786ef GB |
35 | |
36 | TestStateSystemProvider provider = new TestStateSystemProvider(checkNotNull(getTrace())); | |
37 | fProvider = provider; | |
38 | boolean throttle = fThrottleEvents; | |
39 | provider.setThrottling(throttle); | |
40 | return provider; | |
8a6ff07f GB |
41 | } |
42 | ||
43 | @Override | |
44 | protected StateSystemBackendType getBackendType() { | |
45 | return StateSystemBackendType.INMEM; | |
46 | } | |
47 | ||
a01f6266 GB |
48 | /** |
49 | * Get the name of the backend | |
50 | * | |
51 | * @return The name of the backend used | |
52 | */ | |
53 | public String getBackendName() { | |
54 | return StateSystemBackendType.INMEM.name(); | |
55 | } | |
56 | ||
31d786ef GB |
57 | /** |
58 | * Set whether events are processed one at a time | |
59 | * | |
60 | * @param throttleEvent A value of <code>true</code> will have the events processed one a time instead of adding them all to the queue. To process the next event, one must call the {@link #signalNextEvent()} method. A value of <code>false</code> will return to default behavior. | |
61 | */ | |
62 | public void setPerEventSignalling(boolean throttleEvent) { | |
63 | fThrottleEvents = throttleEvent; | |
64 | TestStateSystemProvider provider = fProvider; | |
65 | if (provider != null) { | |
66 | provider.setThrottling(throttleEvent); | |
67 | } | |
68 | } | |
69 | ||
70 | /** | |
71 | * Signal for the next event to be processed. This makes sense only if | |
72 | * {@link #setPerEventSignalling(boolean)} method has been set to true | |
73 | */ | |
74 | public void signalNextEvent() { | |
75 | TestStateSystemProvider provider = fProvider; | |
76 | if (provider != null) { | |
77 | provider.signalNextEvent(); | |
78 | } | |
79 | } | |
80 | ||
8a6ff07f | 81 | } |