1 | package de.uka.ipd.sdq.simucomframework; |
2 | |
3 | import de.uka.ipd.sdq.probespec.framework.IBlackboardListener; |
4 | import de.uka.ipd.sdq.probespec.framework.ISampleBlackboard; |
5 | import de.uka.ipd.sdq.probespec.framework.ProbeSetAndRequestContext; |
6 | import de.uka.ipd.sdq.probespec.framework.ProbeSetSample; |
7 | import de.uka.ipd.sdq.probespec.framework.RequestContext; |
8 | import de.uka.ipd.sdq.simulation.abstractsimengine.ISimulationControl; |
9 | |
10 | /** |
11 | * Decorates an {@link ISampleBlackboard} in order to discard measurements that |
12 | * arrives after the simulation has been stopped already. |
13 | * |
14 | * @author pmerkle |
15 | * |
16 | */ |
17 | public class DiscardInvalidMeasurementsBlackboardDecorator implements |
18 | ISampleBlackboard { |
19 | |
20 | private ISampleBlackboard decorated; |
21 | private ISimulationControl simControl; |
22 | |
23 | public DiscardInvalidMeasurementsBlackboardDecorator( |
24 | ISampleBlackboard decorated, ISimulationControl simControl) { |
25 | this.decorated = decorated; |
26 | this.simControl = simControl; |
27 | } |
28 | |
29 | public void addBlackboardListener(IBlackboardListener l, Integer... topics) { |
30 | decorated.addBlackboardListener(l, topics); |
31 | } |
32 | |
33 | public void addSample(ProbeSetSample pss) { |
34 | if (simControl.isRunning()) { |
35 | decorated.addSample(pss); |
36 | } |
37 | } |
38 | |
39 | public void addSampleAfterSimulationEnd(ProbeSetSample pss) { |
40 | decorated.addSample(pss); |
41 | } |
42 | |
43 | public void deleteSample(ProbeSetAndRequestContext pss) { |
44 | decorated.deleteSample(pss); |
45 | } |
46 | |
47 | public void deleteSamplesInRequestContext(RequestContext requestContext) { |
48 | decorated.deleteSamplesInRequestContext(requestContext); |
49 | } |
50 | |
51 | public ProbeSetSample getSample(ProbeSetAndRequestContext probeSetSampleID) { |
52 | return decorated.getSample(probeSetSampleID); |
53 | } |
54 | |
55 | public int size() { |
56 | return decorated.size(); |
57 | } |
58 | |
59 | } |