/** */ package ftp.impl; import java.util.ArrayList; import java.util.List; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import ftp.FtpPackage; import ftp.Port; import ftp.SignalConstant; import ftp.SignalPort; import ftp.SignalValue; import ftp.SignalValues; import ftp.TypedPortValue; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Signal Constant</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link ftp.impl.SignalConstantImpl#getOutPort <em>Out Port</em>}</li> * <li>{@link ftp.impl.SignalConstantImpl#getValue <em>Value</em>}</li> * </ul> * * @generated */ public class SignalConstantImpl extends PrimitiveComponentImpl implements SignalConstant { /** * The cached value of the '{@link #getOutPort() <em>Out Port</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOutPort() * @generated * @ordered */ protected SignalPort outPort; /** * The default value of the '{@link #getValue() <em>Value</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getValue() * @generated * @ordered */ protected static final SignalValues VALUE_EDEFAULT = SignalValues.OFF; /** * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getValue() * @generated * @ordered */ protected SignalValues value = VALUE_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ protected SignalConstantImpl() { super(); setType("signalConstant"); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return FtpPackage.Literals.SIGNAL_CONSTANT; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public SignalPort getOutPort() { if (outPort == null) { SignalPort sp = new SignalPortImpl(); sp.setType("Out"); setOutPort(sp); } return outPort; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetOutPort(SignalPort newOutPort, NotificationChain msgs) { SignalPort oldOutPort = outPort; outPort = newOutPort; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FtpPackage.SIGNAL_CONSTANT__OUT_PORT, oldOutPort, newOutPort); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setOutPort(SignalPort newOutPort) { if (newOutPort != outPort) { NotificationChain msgs = null; if (outPort != null) msgs = ((InternalEObject)outPort).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FtpPackage.SIGNAL_CONSTANT__OUT_PORT, null, msgs); if (newOutPort != null) msgs = ((InternalEObject)newOutPort).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FtpPackage.SIGNAL_CONSTANT__OUT_PORT, null, msgs); msgs = basicSetOutPort(newOutPort, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FtpPackage.SIGNAL_CONSTANT__OUT_PORT, newOutPort, newOutPort)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public SignalValues getValue() { return value; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setValue(SignalValues newValue) { SignalValues oldValue = value; value = newValue == null ? VALUE_EDEFAULT : newValue; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FtpPackage.SIGNAL_CONSTANT__VALUE, oldValue, value)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case FtpPackage.SIGNAL_CONSTANT__OUT_PORT: return basicSetOutPort(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case FtpPackage.SIGNAL_CONSTANT__OUT_PORT: return getOutPort(); case FtpPackage.SIGNAL_CONSTANT__VALUE: return getValue(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case FtpPackage.SIGNAL_CONSTANT__OUT_PORT: setOutPort((SignalPort)newValue); return; case FtpPackage.SIGNAL_CONSTANT__VALUE: setValue((SignalValues)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case FtpPackage.SIGNAL_CONSTANT__OUT_PORT: setOutPort((SignalPort)null); return; case FtpPackage.SIGNAL_CONSTANT__VALUE: setValue(VALUE_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case FtpPackage.SIGNAL_CONSTANT__OUT_PORT: return outPort != null; case FtpPackage.SIGNAL_CONSTANT__VALUE: return value != VALUE_EDEFAULT; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); return result.toString(); } public List<Port> retrievePorts() { List<Port> ports = new ArrayList<Port>(); ports.add(getOutPort()); return ports; } public List<TypedPortValue> retrieveParams() { List<TypedPortValue> params = new ArrayList<TypedPortValue>(); SignalValue sv = new SignalValueImpl(); sv.setSignal(getValue()); params.add(sv); return params; } public List<Predicate> translateToLogic() { if (logic == null) { Predicate pred = new Predicate(); pred.functor = "signalConstant/2"; pred.stateArgs = 0; List<String> clauses = new ArrayList<String>(); clauses.add("(signalConstant(Sig,Const):-Sig=Const)"); pred.clauses = clauses; List<Predicate> preds = new ArrayList<Predicate>(); preds.add(pred); logic = preds; } return logic; } } //SignalConstantImpl