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

COVERAGE SUMMARY FOR SOURCE FILE [ComponentCostPerInstanceImpl.java]

nameclass, %method, %block, %line, %
ComponentCostPerInstanceImpl.java0%   (0/1)0%   (0/12)0%   (0/167)0%   (0/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComponentCostPerInstanceImpl0%   (0/1)0%   (0/12)0%   (0/167)0%   (0/44)
ComponentCostPerInstanceImpl (): void 0%   (0/1)0%   (0/3)0%   (0/2)
basicGetAllocation (): Allocation 0%   (0/1)0%   (0/3)0%   (0/1)
eGet (int, boolean, boolean): Object 0%   (0/1)0%   (0/16)0%   (0/4)
eIsSet (int): boolean 0%   (0/1)0%   (0/13)0%   (0/3)
eSet (int, Object): void 0%   (0/1)0%   (0/12)0%   (0/5)
eStaticClass (): EClass 0%   (0/1)0%   (0/2)0%   (0/1)
eUnset (int): void 0%   (0/1)0%   (0/10)0%   (0/5)
getAllocation (): Allocation 0%   (0/1)0%   (0/38)0%   (0/7)
getInitialCost (): double 0%   (0/1)0%   (0/7)0%   (0/1)
getNumberOfInstances (): int 0%   (0/1)0%   (0/35)0%   (0/9)
getOperatingCost (): double 0%   (0/1)0%   (0/7)0%   (0/1)
setAllocation (Allocation): void 0%   (0/1)0%   (0/21)0%   (0/5)

1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package de.uka.ipd.sdq.pcm.cost.impl;
8 
9import java.util.List;
10 
11import de.uka.ipd.sdq.pcm.allocation.Allocation;
12import de.uka.ipd.sdq.pcm.allocation.AllocationContext;
13 
14import de.uka.ipd.sdq.pcm.cost.ComponentCostPerInstance;
15import de.uka.ipd.sdq.pcm.cost.costPackage;
16 
17import org.eclipse.emf.common.notify.Notification;
18 
19import org.eclipse.emf.ecore.EClass;
20import org.eclipse.emf.ecore.InternalEObject;
21 
22import org.eclipse.emf.ecore.impl.ENotificationImpl;
23 
24/**
25 * <!-- begin-user-doc -->
26 * An implementation of the model object '<em><b>Component Cost Per Instance</b></em>'.
27 * <!-- end-user-doc -->
28 * <p>
29 * The following features are implemented:
30 * <ul>
31 *   <li>{@link de.uka.ipd.sdq.pcm.cost.impl.ComponentCostPerInstanceImpl#getAllocation <em>Allocation</em>}</li>
32 * </ul>
33 * </p>
34 *
35 * @generated
36 */
37public class ComponentCostPerInstanceImpl extends ComponentCostImpl implements ComponentCostPerInstance {
38        /**
39         * The cached value of the '{@link #getAllocation() <em>Allocation</em>}' reference.
40         * <!-- begin-user-doc -->
41         * <!-- end-user-doc -->
42         * @see #getAllocation()
43         * @generated
44         * @ordered
45         */
46        protected Allocation allocation;
47 
48        /**
49         * <!-- begin-user-doc -->
50         * <!-- end-user-doc -->
51         * @generated
52         */
53        protected ComponentCostPerInstanceImpl() {
54                super();
55        }
56 
57        /**
58         * <!-- begin-user-doc -->
59         * <!-- end-user-doc -->
60         * @generated
61         */
62        @Override
63        protected EClass eStaticClass() {
64                return costPackage.Literals.COMPONENT_COST_PER_INSTANCE;
65        }
66 
67        /**
68         * <!-- begin-user-doc -->
69         * <!-- end-user-doc -->
70         * @generated
71         */
72        public Allocation getAllocation() {
73                if (allocation != null && allocation.eIsProxy()) {
74                        InternalEObject oldAllocation = (InternalEObject)allocation;
75                        allocation = (Allocation)eResolveProxy(oldAllocation);
76                        if (allocation != oldAllocation) {
77                                if (eNotificationRequired())
78                                        eNotify(new ENotificationImpl(this, Notification.RESOLVE, costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION, oldAllocation, allocation));
79                        }
80                }
81                return allocation;
82        }
83 
84        /**
85         * <!-- begin-user-doc -->
86         * <!-- end-user-doc -->
87         * @generated
88         */
89        public Allocation basicGetAllocation() {
90                return allocation;
91        }
92 
93        /**
94         * <!-- begin-user-doc -->
95         * <!-- end-user-doc -->
96         * @generated
97         */
98        public void setAllocation(Allocation newAllocation) {
99                Allocation oldAllocation = allocation;
100                allocation = newAllocation;
101                if (eNotificationRequired())
102                        eNotify(new ENotificationImpl(this, Notification.SET, costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION, oldAllocation, allocation));
103        }
104 
105        /**
106         * <!-- begin-user-doc -->
107         * <!-- end-user-doc -->
108         * @generated
109         */
110        @Override
111        public Object eGet(int featureID, boolean resolve, boolean coreType) {
112                switch (featureID) {
113                        case costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION:
114                                if (resolve) return getAllocation();
115                                return basicGetAllocation();
116                }
117                return super.eGet(featureID, resolve, coreType);
118        }
119 
120        /**
121         * <!-- begin-user-doc -->
122         * <!-- end-user-doc -->
123         * @generated
124         */
125        @Override
126        public void eSet(int featureID, Object newValue) {
127                switch (featureID) {
128                        case costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION:
129                                setAllocation((Allocation)newValue);
130                                return;
131                }
132                super.eSet(featureID, newValue);
133        }
134 
135        /**
136         * <!-- begin-user-doc -->
137         * <!-- end-user-doc -->
138         * @generated
139         */
140        @Override
141        public void eUnset(int featureID) {
142                switch (featureID) {
143                        case costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION:
144                                setAllocation((Allocation)null);
145                                return;
146                }
147                super.eUnset(featureID);
148        }
149 
150        /**
151         * <!-- begin-user-doc -->
152         * <!-- end-user-doc -->
153         * @generated
154         */
155        @Override
156        public boolean eIsSet(int featureID) {
157                switch (featureID) {
158                        case costPackage.COMPONENT_COST_PER_INSTANCE__ALLOCATION:
159                                return allocation != null;
160                }
161                return super.eIsSet(featureID);
162        }
163        
164        /**
165         * <!-- begin-user-doc -->
166         * <!-- end-user-doc -->
167         * @generated not
168         */
169        @Override
170        public double getOperatingCost() {
171                // the operating costs are the componentOperatingCost times the number of instances of the component.
172                return getNumberOfInstances() * this.getComponentOperatingCost();
173        }
174 
175        /**
176         * <!-- begin-user-doc -->
177         * <!-- end-user-doc -->
178         * @generated not
179         */
180        @Override
181        public double getInitialCost() {
182                // the initial costs are the componentOperatingCost times the number of instances of the component.
183                return getNumberOfInstances() * this.getComponentInitialCost();
184        }
185        
186        private int getNumberOfInstances(){
187                int numberOfInstances = 0;
188                if (this.getAllocation() != null){
189                        List<AllocationContext> allocationContexts = this.getAllocation().getAllocationContexts_Allocation();
190                        for (AllocationContext allocationContext : allocationContexts) {
191                                if (allocationContext.getAssemblyContext_AllocationContext().getEncapsulatedComponent__AssemblyContext().getId()
192                                                .equals(this.getRepositoryComponent().getId())){
193                                        numberOfInstances ++;
194                                }
195                        }
196                } else {
197                        numberOfInstances = 1;
198                }
199                return numberOfInstances;
200        }
201 
202} //ComponentCostPerInstanceImpl

[all classes][de.uka.ipd.sdq.pcm.cost.impl]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov