EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.simucomframework.variables.stoexvisitor]

COVERAGE SUMMARY FOR SOURCE FILE [PCMProbfunctionEvaluationVisitor.java]

nameclass, %method, %block, %line, %
PCMProbfunctionEvaluationVisitor.java0%   (0/1)0%   (0/5)0%   (0/78)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PCMProbfunctionEvaluationVisitor0%   (0/1)0%   (0/5)0%   (0/78)0%   (0/21)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
PCMProbfunctionEvaluationVisitor (StoExCacheEntry): void 0%   (0/1)0%   (0/6)0%   (0/3)
caseProbabilityDensityFunction (ProbabilityDensityFunction): Object 0%   (0/1)0%   (0/20)0%   (0/4)
caseProbabilityMassFunction (ProbabilityMassFunction): Object 0%   (0/1)0%   (0/20)0%   (0/4)
drawSample (IProbabilityFunction): Object 0%   (0/1)0%   (0/27)0%   (0/7)

1package de.uka.ipd.sdq.simucomframework.variables.stoexvisitor;
2 
3import java.util.Iterator;
4 
5import org.apache.log4j.Logger;
6import org.eclipse.emf.ecore.EObject;
7 
8import de.uka.ipd.sdq.probfunction.ProbabilityDensityFunction;
9import de.uka.ipd.sdq.probfunction.ProbabilityMassFunction;
10import de.uka.ipd.sdq.probfunction.math.IProbabilityDensityFunction;
11import de.uka.ipd.sdq.probfunction.math.IProbabilityFunction;
12import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction;
13import de.uka.ipd.sdq.probfunction.util.ProbfunctionSwitch;
14import de.uka.ipd.sdq.simucomframework.variables.cache.StoExCache;
15import de.uka.ipd.sdq.simucomframework.variables.cache.StoExCacheEntry;
16 
17/**
18 * Visitor to visit probfunctions and evaluate them to return a sample
19 * @author Steffen Becker
20 *
21 */
22public class PCMProbfunctionEvaluationVisitor extends ProbfunctionSwitch<Object> {
23        private static Logger logger = 
24                Logger.getLogger(PCMProbfunctionEvaluationVisitor.class.getName());
25 
26        private StoExCacheEntry stoexCacheEntry;
27 
28        public PCMProbfunctionEvaluationVisitor(StoExCacheEntry stoexCacheEntry) {
29                this.stoexCacheEntry = stoexCacheEntry;
30        }
31        
32        @Override
33        public Object caseProbabilityDensityFunction(ProbabilityDensityFunction object) {
34                IProbabilityFunction pdf = stoexCacheEntry.getProbFunction(object);
35                Object result = drawSample(pdf);
36                logger.debug("Draw Sample returned "+result);
37                return result;
38        }
39 
40        @Override
41        public Object caseProbabilityMassFunction(ProbabilityMassFunction object) {
42                IProbabilityFunction pdf = stoexCacheEntry.getProbFunction(object);
43                Object result = drawSample(pdf);
44                logger.debug("Draw Sample returned "+result);
45                return result;
46        }
47        
48        private Object drawSample(IProbabilityFunction f) {
49                if (f == null)
50                        throw new RuntimeException("Probability function in drawSample() must be != null");
51                if (f instanceof IProbabilityMassFunction)
52                        return ((IProbabilityMassFunction)f).drawSample();
53                if (f instanceof IProbabilityDensityFunction)
54                        return ((IProbabilityDensityFunction)f).drawSample();
55                throw new RuntimeException("Should never be here. Unknown Probfunction found!");
56        }
57}

[all classes][de.uka.ipd.sdq.simucomframework.variables.stoexvisitor]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov