1 | package de.uka.ipd.sdq.pcmsolver.handler; |
2 | |
3 | import org.apache.log4j.Logger; |
4 | |
5 | import de.uka.ipd.sdq.context.computed_usage.BranchProbability; |
6 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsageFactory; |
7 | import de.uka.ipd.sdq.pcm.seff.AbstractBranchTransition; |
8 | import de.uka.ipd.sdq.pcm.seff.ResourceDemandingBehaviour; |
9 | import de.uka.ipd.sdq.pcmsolver.visitors.SeffVisitor; |
10 | |
11 | public abstract class AbstractBranchTransitionHandler { |
12 | |
13 | private static Logger logger = Logger.getLogger(AbstractBranchTransitionHandler.class.getName()); |
14 | |
15 | protected ComputedUsageFactory usageFactory = ComputedUsageFactory.eINSTANCE; |
16 | |
17 | |
18 | protected SeffVisitor visitor; |
19 | |
20 | /** |
21 | * @param context |
22 | * @param _visitor |
23 | * @param nextHandler |
24 | */ |
25 | public AbstractBranchTransitionHandler(SeffVisitor seffVisitor) { |
26 | visitor = seffVisitor; |
27 | } |
28 | |
29 | /** |
30 | * @param bt |
31 | */ |
32 | protected void visitChildBehaviour(AbstractBranchTransition bt) { |
33 | ResourceDemandingBehaviour rdb = bt |
34 | .getBranchBehaviour_BranchTransition(); |
35 | if (rdb != null){ |
36 | visitor.doSwitch(rdb); |
37 | } |
38 | } |
39 | |
40 | /** |
41 | * @param bt |
42 | * @param solvedBranchProb |
43 | */ |
44 | protected void storeToUsageContext(AbstractBranchTransition bt, double solvedBranchProb) { |
45 | BranchProbability prob = usageFactory.createBranchProbability(); |
46 | prob.setBranchtransition_BranchProbability(bt); |
47 | prob.setProbability(solvedBranchProb); |
48 | |
49 | visitor.getContextWrapper().getCompUsgCtx().getBranchProbabilities_ComputedUsageContext().add(prob); |
50 | } |
51 | } |