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 [UsageModelVisitor.java]

nameclass, %method, %block, %line, %
UsageModelVisitor.java0%   (0/1)0%   (0/10)0%   (0/171)0%   (0/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UsageModelVisitor0%   (0/1)0%   (0/10)0%   (0/171)0%   (0/46)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
UsageModelVisitor (PCMInstance): void 0%   (0/1)0%   (0/18)0%   (0/7)
caseBranch (Branch): Object 0%   (0/1)0%   (0/29)0%   (0/6)
caseDelay (Delay): Object 0%   (0/1)0%   (0/10)0%   (0/3)
caseEntryLevelSystemCall (EntryLevelSystemCall): Object 0%   (0/1)0%   (0/60)0%   (0/12)
caseLoop (Loop): Object 0%   (0/1)0%   (0/15)0%   (0/4)
caseScenarioBehaviour (ScenarioBehaviour): Object 0%   (0/1)0%   (0/11)0%   (0/3)
caseStart (Start): Object 0%   (0/1)0%   (0/10)0%   (0/3)
caseStop (Stop): Object 0%   (0/1)0%   (0/5)0%   (0/2)
getStartAction (ScenarioBehaviour): Start 0%   (0/1)0%   (0/8)0%   (0/3)

1package de.uka.ipd.sdq.pcmsolver.visitors;
2 
3import java.util.List;
4 
5import org.apache.log4j.Logger;
6import org.eclipse.emf.common.util.EList;
7 
8import de.uka.ipd.sdq.context.computed_allocation.ComputedAllocationFactory;
9import de.uka.ipd.sdq.context.computed_usage.ComputedUsageFactory;
10import de.uka.ipd.sdq.pcm.parameter.ParameterFactory;
11import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
12import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification;
13import de.uka.ipd.sdq.pcm.usagemodel.Branch;
14import de.uka.ipd.sdq.pcm.usagemodel.BranchTransition;
15import de.uka.ipd.sdq.pcm.usagemodel.Delay;
16import de.uka.ipd.sdq.pcm.usagemodel.EntryLevelSystemCall;
17import de.uka.ipd.sdq.pcm.usagemodel.Loop;
18import de.uka.ipd.sdq.pcm.usagemodel.ScenarioBehaviour;
19import de.uka.ipd.sdq.pcm.usagemodel.Start;
20import de.uka.ipd.sdq.pcm.usagemodel.Stop;
21import de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelSwitch;
22import de.uka.ipd.sdq.pcmsolver.models.PCMInstance;
23import de.uka.ipd.sdq.pcmsolver.transformations.ContextWrapper;
24 
25/**
26 * Visitor that builds the computed usage and computed allocation contexts by calling 
27 * {@link SeffVisitor} for each {@link EntryLevelSystemCall}.
28 * @author Koziolek, Martens
29 * 
30 */
31public class UsageModelVisitor extends UsagemodelSwitch {
32 
33        protected static Logger logger = Logger.getLogger(UsageModelVisitor.class
34                        .getName());
35 
36        protected PCMInstance pcmInstance;
37        private ComputedUsageFactory compUsageFactory;
38        private ComputedAllocationFactory compAllocationFactory;
39        private ParameterFactory parameterFactory;
40                        
41        protected ContextWrapper myContextWrapper = null;
42        
43        /**
44         * Solves dependencies for this {@link PCMInstance} and adds the results to the 
45         * {@link PCMInstance}'s computed contexts (such as {@link PCMInstance#getComputedUsage()}). 
46         * @param inst
47         *            an instance of the Palladio Component Metamodel
48         */
49        public UsageModelVisitor(PCMInstance inst) {
50                pcmInstance = inst;
51                compUsageFactory = ComputedUsageFactory.eINSTANCE;
52                compAllocationFactory = ComputedAllocationFactory.eINSTANCE;
53                parameterFactory = ParameterFactory.eINSTANCE;
54        }
55 
56        /*
57         * (non-Javadoc)
58         * 
59         * @see de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelSwitch#caseScenarioBehaviour(de.uka.ipd.sdq.pcm.usagemodel.ScenarioBehaviour)
60         */
61        @Override
62        public Object caseScenarioBehaviour(ScenarioBehaviour object) {
63                logger.debug("VisitScenarioBehaviour");
64                doSwitch(getStartAction(object));
65                return object;
66        }
67 
68        /* (non-Javadoc)
69         * @see de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelSwitch#caseStart(de.uka.ipd.sdq.pcm.usagemodel.Start)
70         */
71        @Override
72        public Object caseStart(Start object) {
73                logger.debug("VisitStart");
74                doSwitch(object.getSuccessor());
75                return object;
76        }
77 
78        /* (non-Javadoc)
79         * @see de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelSwitch#caseStop(de.uka.ipd.sdq.pcm.usagemodel.Stop)
80         */
81        @Override
82        public Object caseStop(Stop object) {
83                logger.debug("VisitStop");
84                return object;
85        }
86 
87        
88        
89        @Override
90        public Object caseBranch(Branch object) {
91                logger.debug("VisitBranch");
92                EList<BranchTransition> btList = object.getBranchTransitions_Branch();
93                for(BranchTransition bt : btList){
94                        doSwitch(bt.getBranchedBehaviour_BranchTransition());
95                }
96                doSwitch(object.getSuccessor());
97                return object;
98        }
99 
100        /* (non-Javadoc)
101         * @see de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelSwitch#caseEntryLevelSystemCall(de.uka.ipd.sdq.pcm.usagemodel.EntryLevelSystemCall)
102         */
103        @Override
104        public Object caseEntryLevelSystemCall(EntryLevelSystemCall elsc) {
105                logger.debug("VisitEntryLevelSystemCall");
106                logger.debug("Called System Method "
107                                + elsc.getOperationSignature__EntryLevelSystemCall().getEntityName());
108 
109                // Get List of ContextWrappers, one for each called component instance
110                List<ContextWrapper> contextWrapperList;
111                if (myContextWrapper == null)
112                        contextWrapperList = ContextWrapper.getContextWrapperFor(elsc, pcmInstance);
113                else
114                        contextWrapperList = myContextWrapper.getContextWrapperFor(elsc);
115 
116                for (ContextWrapper contextWrapper : contextWrapperList) {
117                        ServiceEffectSpecification seff = contextWrapper.getNextSEFF(elsc);
118                        SeffVisitor visitor = new SeffVisitor(contextWrapper);
119                        //try {
120                                visitor.doSwitch((ResourceDemandingSEFF) seff);
121                        /*} catch (Exception e) {
122                                logger.error("Error while visiting RDSEFF");
123                                e.printStackTrace();
124                        }*/
125                }
126                
127                //XXX: The internal myContextWrapper is not affected by the handling of the
128                // EntryLevelSystem call because the copies of it handle it. This was different 
129                // before allowing replication, when only one ContextWrapper instance was used. 
130                doSwitch(elsc.getSuccessor());
131                return elsc;
132        }
133 
134        
135        
136        @Override
137        public Object caseDelay(Delay object) {
138                logger.debug("VisitDelay");
139                doSwitch(object.getSuccessor());
140                return object;
141        }
142 
143        @Override
144        public Object caseLoop(Loop object) {
145                logger.debug("VisitLoop");
146                doSwitch(object.getBodyBehaviour_Loop());
147                doSwitch(object.getSuccessor());
148                return object;
149        }
150 
151        /**
152         * @param object
153         * @return
154         */
155        private Start getStartAction(ScenarioBehaviour object) {
156                Start startAction = (Start) EMFQueryHelper.getObjectByType(object
157                                .getActions_ScenarioBehaviour(), Start.class);
158                return startAction;
159        }
160 
161}

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