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

COVERAGE SUMMARY FOR SOURCE FILE [Calculator.java]

nameclass, %method, %block, %line, %
Calculator.java0%   (0/1)0%   (0/6)0%   (0/52)0%   (0/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Calculator0%   (0/1)0%   (0/6)0%   (0/52)0%   (0/16)
Calculator (ProbeSpecContext): void 0%   (0/1)0%   (0/15)0%   (0/5)
addCalculatorListener (ICalculatorListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
fireCalculated (Vector): void 0%   (0/1)0%   (0/16)0%   (0/3)
getMeasurementMetrics (): Vector 0%   (0/1)0%   (0/3)0%   (0/1)
getProbeSpecContext (): ProbeSpecContext 0%   (0/1)0%   (0/3)0%   (0/1)
sampleArrived (ProbeSetSample): BlackboardVote 0%   (0/1)0%   (0/9)0%   (0/4)

1package de.uka.ipd.sdq.probespec.framework.calculator;
2 
3import java.util.Vector;
4import java.util.concurrent.CopyOnWriteArrayList;
5 
6import javax.measure.Measure;
7import javax.measure.quantity.Quantity;
8 
9import de.uka.ipd.sdq.pipesandfilters.framework.MeasurementMetric;
10import de.uka.ipd.sdq.probespec.framework.BlackboardVote;
11import de.uka.ipd.sdq.probespec.framework.IBlackboardListener;
12import de.uka.ipd.sdq.probespec.framework.ISampleBlackboard;
13import de.uka.ipd.sdq.probespec.framework.ProbeSetSample;
14import de.uka.ipd.sdq.probespec.framework.ProbeSpecContext;
15import de.uka.ipd.sdq.probespec.framework.exceptions.CalculatorException;
16 
17/**
18 * This class is the abstract super class for all Calculator implementations.
19 * All specific Calculators have to inherit from this class.
20 * <p>
21 * Calculators observe the {@link ISampleBlackboard} for probe set samples
22 * (Observer Pattern). As soon as a new probe set sample is published at the
23 * blackboard, the {@link #execute(ProbeSetSample)} method is invoked. The
24 * calculator have to decide, whether the probe set sample is of interest for
25 * the calculation.
26 * 
27 * @author Faber
28 * 
29 */
30public abstract class Calculator implements IBlackboardListener {
31 
32    private ProbeSpecContext probeSpecContext;
33        private Vector<MeasurementMetric> measurementMetrics;
34 
35        // copy on write enables listeners to unregister during event processing.
36        private CopyOnWriteArrayList<ICalculatorListener> listeners;
37 
38        protected Calculator(ProbeSpecContext ctx) {
39            this.probeSpecContext = ctx;
40                this.measurementMetrics = getConcreteMeasurementMetrics();
41                this.listeners = new CopyOnWriteArrayList<ICalculatorListener>();
42        }
43 
44        /**
45         * This method is called to return meta data about the result tuples of the
46         * calculator. E.g. it is used initialize the pipe and filter chain.
47         * 
48         * @return
49         */
50        public Vector<MeasurementMetric> getMeasurementMetrics() {
51                return measurementMetrics;
52        }
53 
54//        /**
55//         * The update method is called by the SampleBlackboard (observable entity)
56//         * containing all ProbeSetSamples. The method casts the two objects and then
57//         * calls the execute method of the specific calculator
58//         * 
59//         * TODO If a logging framework is added to this project, handle the
60//         * exception below correctly.
61//         * 
62//         * @param o
63//         *            The observable object (SampleBlackboard)
64//         * @param arg
65//         *            The ProbeSetSample object written on the SampleBlackboard
66//         */
67//        @Override
68//        public void update(Observable o, Object arg) {
69//                if (o instanceof SampleBlackboard && arg instanceof ProbeSetSample) {
70//                        ProbeSetSample pss = (ProbeSetSample) arg;
71//                        try {
72//                                execute(pss);
73//                        } catch (CalculatorException e) {
74//                                e.printStackTrace();
75//                        }
76//
77//                }
78//        }
79 
80        @Override
81        public BlackboardVote sampleArrived(ProbeSetSample pss) {
82                try {
83                        return execute(pss);
84                } catch (CalculatorException e) {
85                        e.printStackTrace();
86                }
87//                return decideBlackboardVote();
88                return BlackboardVote.DISCARD;
89        }
90        
91    protected ProbeSpecContext getProbeSpecContext() {
92        return probeSpecContext;
93    }
94        
95//        public abstract BlackboardVote decideBlackboardVote();
96 
97        abstract protected BlackboardVote execute(ProbeSetSample pss)
98                        throws CalculatorException;
99 
100        abstract protected Vector<MeasurementMetric> getConcreteMeasurementMetrics();
101 
102        public void addCalculatorListener(ICalculatorListener l) {
103                listeners.add(l);
104        }
105 
106        protected void fireCalculated(
107                        Vector<Measure<?, ? extends Quantity>> resultTuple) {
108                for (ICalculatorListener l : listeners) {
109                        l.calculated(resultTuple);
110                }
111        }
112 
113}

[all classes][de.uka.ipd.sdq.probespec.framework.calculator]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov