| 1 | /** |
| 2 | * Copyright 2008, sdq.ipd.uka.de, U KA |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.simucomframework.simucomstatus.impl; |
| 7 | |
| 8 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimuComStatus; |
| 9 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage; |
| 10 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimulatedProcesses; |
| 11 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimulatedResources; |
| 12 | |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.common.notify.NotificationChain; |
| 15 | |
| 16 | import org.eclipse.emf.ecore.EClass; |
| 17 | import org.eclipse.emf.ecore.InternalEObject; |
| 18 | |
| 19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
| 21 | |
| 22 | /** |
| 23 | * <!-- begin-user-doc --> |
| 24 | * An implementation of the model object '<em><b>Simu Com Status</b></em>'. |
| 25 | * <!-- end-user-doc --> |
| 26 | * <p> |
| 27 | * The following features are implemented: |
| 28 | * <ul> |
| 29 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.SimuComStatusImpl#getProcessStatus <em>Process Status</em>}</li> |
| 30 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.SimuComStatusImpl#getResourceStatus <em>Resource Status</em>}</li> |
| 31 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.SimuComStatusImpl#getCurrentSimulationTime <em>Current Simulation Time</em>}</li> |
| 32 | * </ul> |
| 33 | * </p> |
| 34 | * |
| 35 | * @generated |
| 36 | */ |
| 37 | public class SimuComStatusImpl extends EObjectImpl implements SimuComStatus { |
| 38 | /** |
| 39 | * The cached value of the '{@link #getProcessStatus() <em>Process Status</em>}' containment reference. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @see #getProcessStatus() |
| 43 | * @generated |
| 44 | * @ordered |
| 45 | */ |
| 46 | protected SimulatedProcesses processStatus; |
| 47 | |
| 48 | /** |
| 49 | * The cached value of the '{@link #getResourceStatus() <em>Resource Status</em>}' containment reference. |
| 50 | * <!-- begin-user-doc --> |
| 51 | * <!-- end-user-doc --> |
| 52 | * @see #getResourceStatus() |
| 53 | * @generated |
| 54 | * @ordered |
| 55 | */ |
| 56 | protected SimulatedResources resourceStatus; |
| 57 | |
| 58 | /** |
| 59 | * The default value of the '{@link #getCurrentSimulationTime() <em>Current Simulation Time</em>}' attribute. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @see #getCurrentSimulationTime() |
| 63 | * @generated |
| 64 | * @ordered |
| 65 | */ |
| 66 | protected static final double CURRENT_SIMULATION_TIME_EDEFAULT = 0.0; |
| 67 | |
| 68 | /** |
| 69 | * The cached value of the '{@link #getCurrentSimulationTime() <em>Current Simulation Time</em>}' attribute. |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @see #getCurrentSimulationTime() |
| 73 | * @generated |
| 74 | * @ordered |
| 75 | */ |
| 76 | protected double currentSimulationTime = CURRENT_SIMULATION_TIME_EDEFAULT; |
| 77 | |
| 78 | /** |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | protected SimuComStatusImpl() { |
| 84 | super(); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * <!-- begin-user-doc --> |
| 89 | * <!-- end-user-doc --> |
| 90 | * @generated |
| 91 | */ |
| 92 | @Override |
| 93 | protected EClass eStaticClass() { |
| 94 | return SimucomstatusPackage.Literals.SIMU_COM_STATUS; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | public SimulatedProcesses getProcessStatus() { |
| 103 | return processStatus; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * <!-- begin-user-doc --> |
| 108 | * <!-- end-user-doc --> |
| 109 | * @generated |
| 110 | */ |
| 111 | public NotificationChain basicSetProcessStatus(SimulatedProcesses newProcessStatus, NotificationChain msgs) { |
| 112 | SimulatedProcesses oldProcessStatus = processStatus; |
| 113 | processStatus = newProcessStatus; |
| 114 | if (eNotificationRequired()) { |
| 115 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS, oldProcessStatus, newProcessStatus); |
| 116 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 117 | } |
| 118 | return msgs; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | public void setProcessStatus(SimulatedProcesses newProcessStatus) { |
| 127 | if (newProcessStatus != processStatus) { |
| 128 | NotificationChain msgs = null; |
| 129 | if (processStatus != null) |
| 130 | msgs = ((InternalEObject)processStatus).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS, null, msgs); |
| 131 | if (newProcessStatus != null) |
| 132 | msgs = ((InternalEObject)newProcessStatus).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS, null, msgs); |
| 133 | msgs = basicSetProcessStatus(newProcessStatus, msgs); |
| 134 | if (msgs != null) msgs.dispatch(); |
| 135 | } |
| 136 | else if (eNotificationRequired()) |
| 137 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS, newProcessStatus, newProcessStatus)); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @generated |
| 144 | */ |
| 145 | public SimulatedResources getResourceStatus() { |
| 146 | return resourceStatus; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * <!-- begin-user-doc --> |
| 151 | * <!-- end-user-doc --> |
| 152 | * @generated |
| 153 | */ |
| 154 | public NotificationChain basicSetResourceStatus(SimulatedResources newResourceStatus, NotificationChain msgs) { |
| 155 | SimulatedResources oldResourceStatus = resourceStatus; |
| 156 | resourceStatus = newResourceStatus; |
| 157 | if (eNotificationRequired()) { |
| 158 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS, oldResourceStatus, newResourceStatus); |
| 159 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 160 | } |
| 161 | return msgs; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * <!-- begin-user-doc --> |
| 166 | * <!-- end-user-doc --> |
| 167 | * @generated |
| 168 | */ |
| 169 | public void setResourceStatus(SimulatedResources newResourceStatus) { |
| 170 | if (newResourceStatus != resourceStatus) { |
| 171 | NotificationChain msgs = null; |
| 172 | if (resourceStatus != null) |
| 173 | msgs = ((InternalEObject)resourceStatus).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS, null, msgs); |
| 174 | if (newResourceStatus != null) |
| 175 | msgs = ((InternalEObject)newResourceStatus).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS, null, msgs); |
| 176 | msgs = basicSetResourceStatus(newResourceStatus, msgs); |
| 177 | if (msgs != null) msgs.dispatch(); |
| 178 | } |
| 179 | else if (eNotificationRequired()) |
| 180 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS, newResourceStatus, newResourceStatus)); |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * <!-- begin-user-doc --> |
| 185 | * <!-- end-user-doc --> |
| 186 | * @generated |
| 187 | */ |
| 188 | public double getCurrentSimulationTime() { |
| 189 | return currentSimulationTime; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * <!-- begin-user-doc --> |
| 194 | * <!-- end-user-doc --> |
| 195 | * @generated |
| 196 | */ |
| 197 | public void setCurrentSimulationTime(double newCurrentSimulationTime) { |
| 198 | double oldCurrentSimulationTime = currentSimulationTime; |
| 199 | currentSimulationTime = newCurrentSimulationTime; |
| 200 | if (eNotificationRequired()) |
| 201 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.SIMU_COM_STATUS__CURRENT_SIMULATION_TIME, oldCurrentSimulationTime, currentSimulationTime)); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * <!-- begin-user-doc --> |
| 206 | * <!-- end-user-doc --> |
| 207 | * @generated |
| 208 | */ |
| 209 | @Override |
| 210 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 211 | switch (featureID) { |
| 212 | case SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS: |
| 213 | return basicSetProcessStatus(null, msgs); |
| 214 | case SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS: |
| 215 | return basicSetResourceStatus(null, msgs); |
| 216 | } |
| 217 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * <!-- begin-user-doc --> |
| 222 | * <!-- end-user-doc --> |
| 223 | * @generated |
| 224 | */ |
| 225 | @Override |
| 226 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 227 | switch (featureID) { |
| 228 | case SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS: |
| 229 | return getProcessStatus(); |
| 230 | case SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS: |
| 231 | return getResourceStatus(); |
| 232 | case SimucomstatusPackage.SIMU_COM_STATUS__CURRENT_SIMULATION_TIME: |
| 233 | return new Double(getCurrentSimulationTime()); |
| 234 | } |
| 235 | return super.eGet(featureID, resolve, coreType); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * <!-- begin-user-doc --> |
| 240 | * <!-- end-user-doc --> |
| 241 | * @generated |
| 242 | */ |
| 243 | @Override |
| 244 | public void eSet(int featureID, Object newValue) { |
| 245 | switch (featureID) { |
| 246 | case SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS: |
| 247 | setProcessStatus((SimulatedProcesses)newValue); |
| 248 | return; |
| 249 | case SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS: |
| 250 | setResourceStatus((SimulatedResources)newValue); |
| 251 | return; |
| 252 | case SimucomstatusPackage.SIMU_COM_STATUS__CURRENT_SIMULATION_TIME: |
| 253 | setCurrentSimulationTime(((Double)newValue).doubleValue()); |
| 254 | return; |
| 255 | } |
| 256 | super.eSet(featureID, newValue); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * <!-- begin-user-doc --> |
| 261 | * <!-- end-user-doc --> |
| 262 | * @generated |
| 263 | */ |
| 264 | @Override |
| 265 | public void eUnset(int featureID) { |
| 266 | switch (featureID) { |
| 267 | case SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS: |
| 268 | setProcessStatus((SimulatedProcesses)null); |
| 269 | return; |
| 270 | case SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS: |
| 271 | setResourceStatus((SimulatedResources)null); |
| 272 | return; |
| 273 | case SimucomstatusPackage.SIMU_COM_STATUS__CURRENT_SIMULATION_TIME: |
| 274 | setCurrentSimulationTime(CURRENT_SIMULATION_TIME_EDEFAULT); |
| 275 | return; |
| 276 | } |
| 277 | super.eUnset(featureID); |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * <!-- begin-user-doc --> |
| 282 | * <!-- end-user-doc --> |
| 283 | * @generated |
| 284 | */ |
| 285 | @Override |
| 286 | public boolean eIsSet(int featureID) { |
| 287 | switch (featureID) { |
| 288 | case SimucomstatusPackage.SIMU_COM_STATUS__PROCESS_STATUS: |
| 289 | return processStatus != null; |
| 290 | case SimucomstatusPackage.SIMU_COM_STATUS__RESOURCE_STATUS: |
| 291 | return resourceStatus != null; |
| 292 | case SimucomstatusPackage.SIMU_COM_STATUS__CURRENT_SIMULATION_TIME: |
| 293 | return currentSimulationTime != CURRENT_SIMULATION_TIME_EDEFAULT; |
| 294 | } |
| 295 | return super.eIsSet(featureID); |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * <!-- begin-user-doc --> |
| 300 | * <!-- end-user-doc --> |
| 301 | * @generated |
| 302 | */ |
| 303 | @Override |
| 304 | public String toString() { |
| 305 | if (eIsProxy()) return super.toString(); |
| 306 | |
| 307 | StringBuffer result = new StringBuffer(super.toString()); |
| 308 | result.append(" (currentSimulationTime: "); |
| 309 | result.append(currentSimulationTime); |
| 310 | result.append(')'); |
| 311 | return result.toString(); |
| 312 | } |
| 313 | |
| 314 | } //SimuComStatusImpl |