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

COVERAGE SUMMARY FOR SOURCE FILE [ExpressionParameterSolverVisitor.java]

nameclass, %method, %block, %line, %
ExpressionParameterSolverVisitor.java0%   (0/1)0%   (0/4)0%   (0/173)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExpressionParameterSolverVisitor0%   (0/1)0%   (0/4)0%   (0/173)0%   (0/35)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
ExpressionParameterSolverVisitor (HashMap, ContextWrapper): void 0%   (0/1)0%   (0/7)0%   (0/3)
caseVariable (Variable): Object 0%   (0/1)0%   (0/125)0%   (0/23)
getFullParameterName (AbstractNamedReference): String 0%   (0/1)0%   (0/36)0%   (0/6)

1package de.uka.ipd.sdq.pcmsolver.visitors;
2 
3 
4import java.util.HashMap;
5 
6import org.apache.log4j.Logger;
7import org.eclipse.emf.common.util.BasicEList;
8import org.eclipse.emf.common.util.EList;
9 
10import de.uka.ipd.sdq.context.computed_usage.ExternalCallOutput;
11import de.uka.ipd.sdq.context.computed_usage.Input;
12import de.uka.ipd.sdq.pcm.parameter.CharacterisedVariable;
13import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation;
14import de.uka.ipd.sdq.pcm.parameter.VariableUsage;
15import de.uka.ipd.sdq.pcmsolver.transformations.ContextWrapper;
16import de.uka.ipd.sdq.stoex.AbstractNamedReference;
17import de.uka.ipd.sdq.stoex.Expression;
18import de.uka.ipd.sdq.stoex.NamespaceReference;
19import de.uka.ipd.sdq.stoex.Variable;
20import de.uka.ipd.sdq.stoex.analyser.visitors.ExpressionSolveVisitor;
21import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum;
22 
23public class ExpressionParameterSolverVisitor extends ExpressionSolveVisitor {
24 
25        private static Logger logger = Logger
26        .getLogger(ExpressionParameterSolverVisitor.class.getName());
27 
28        //private Context context;
29        private ContextWrapper contextWrapper;
30        
31        public ExpressionParameterSolverVisitor(HashMap<Expression, TypeEnum> typeAnn, ContextWrapper ctxWrp){
32                super(typeAnn);
33                this.contextWrapper = ctxWrp;
34        }
35 
36        /* (non-Javadoc)
37         * @see de.uka.ipd.sdq.stoex.analyser.visitors.ExpressionSolveVisitor#caseVariable(de.uka.ipd.sdq.stoex.Variable)
38         *
39         * Solves a parametric dependency. For a given variable, it tries to 
40         * determine it's actual specification (e.g. probability distribution or
41         * constant) by looking it up in the usage context.
42         */
43        @Override
44        public Object caseVariable(Variable var){
45                AbstractNamedReference anr = var.getId_Variable();
46                CharacterisedVariable chVar = (CharacterisedVariable)var;
47                
48                //Contains both input parameters specified in the interface and component parameters. 
49                EList<VariableUsage> vuList = new BasicEList<VariableUsage>();
50                Input input = contextWrapper.getCompUsgCtx().getInput_ComputedUsageContext();
51                if (input !=null){
52                        vuList.addAll(input.getParameterChacterisations_Input());
53                }
54                
55                EList<ExternalCallOutput> ecoList = contextWrapper.getCompUsgCtx().getExternalCallOutput_ComputedUsageContext();
56                for (ExternalCallOutput eco : ecoList){
57                        // TODO: recognise scopes
58                        EList<VariableUsage> vuList2 = eco.getParameterCharacterisations_ExternalCallOutput();
59                        vuList.addAll(vuList2); 
60                }
61                
62                String soughtParameterName = getFullParameterName(anr);
63                for (VariableUsage vu : vuList){ 
64                        AbstractNamedReference ref = vu.getNamedReference__VariableUsage();
65                        String currentParameterName = getFullParameterName(ref);
66 
67                        if (currentParameterName.equals(soughtParameterName)){
68                                EList<VariableCharacterisation> varCharList = vu.getVariableCharacterisation_VariableUsage();
69 
70                                for (VariableCharacterisation vc : varCharList){ // iterate over a parameter's characterisations
71                                        if (vc.getType() == chVar.getCharacterisationType()){
72                                                String specification = vc.getSpecification_VariableCharacterisation().getSpecification();
73                                                Expression expr = ExpressionHelper.parseToExpression(specification);
74                                                return expr;
75                                        }
76                                }
77                                throw new RuntimeException("Variable Characterisation missing in Usage Context ("+soughtParameterName+")!");
78                        }
79                }
80                throw new RuntimeException("Variable Characterisation missing in Usage Context ("+soughtParameterName+")!");
81        }
82 
83        /**
84         * @param currentParameterName
85         * @param ref
86         * @return
87         */
88        private String getFullParameterName(AbstractNamedReference ref) {
89                String name = ""; 
90                while (ref instanceof NamespaceReference){
91                        NamespaceReference nsRef = (NamespaceReference)ref;
92                        name += nsRef.getReferenceName() + ".";
93                        ref = nsRef.getInnerReference_NamespaceReference();
94                }
95                return name += ref.getReferenceName();
96        }
97}

[all classes][de.uka.ipd.sdq.pcmsolver.visitors]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov