Search in sources :

Example 1 with ComponentPrototypeBinding

use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.

the class GroupPrototypeHolderItemProvider method getImage.

/**
 * This returns GroupPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    PrototypeHolder holder = (PrototypeHolder) object;
    PrototypeBinding pb = holder.getPrototypeBinding();
    if (pb != null) {
        FeatureType type = FeatureType.ABSTRACT_FEATURE;
        if (pb instanceof ComponentPrototypeBinding) {
            type = AadlBaUtils.getCompPrototypeType((ComponentPrototypeBinding) pb);
        } else if (pb instanceof FeatureGroupPrototypeBinding) {
            type = FeatureType.FEATURE_GROUP_PROTOTYPE;
        } else if (pb instanceof FeaturePrototypeBinding) {
            type = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) pb);
        }
        switch(type) {
            case FEATURE_GROUP_PROTOTYPE:
                {
                    imgFile += "FeatureGroup";
                    break;
                }
            case THREAD_GROUP_PROTOTYPE:
                {
                    imgFile += "ThreadGroup";
                    break;
                }
            case REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case SUBPROGRAM_GROUP_PROTOTYPE:
                {
                    imgFile += "Subprogram";
                    break;
                }
            default:
                imgFile = "full/obj16/IfStatement";
        }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeatureType(org.osate.ba.aadlba.FeatureType) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 2 with ComponentPrototypeBinding

use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.

the class AadlBaTypeChecker method subprogramTypeCheck.

// Gets subprogram type binded to the given subprogram call action.
// On error, reports error and returns null.
private Classifier subprogramTypeCheck(CommAction comAct) {
    Element el = null;
    if (comAct.getReference() != null) {
        el = comAct.getReference().getOsateRef();
    } else {
        el = comAct.getQualifiedName().getOsateRef();
    }
    Classifier result = null;
    String errorMsg = null;
    if (el instanceof ComponentPrototype) {
        ComponentPrototype cp = (ComponentPrototype) el;
        if (cp instanceof SubprogramPrototype) {
            ComponentClassifier cc = cp.getConstrainingClassifier();
            if (cc != null && cc instanceof SubprogramType) {
                result = cc;
            } else {
                errorMsg = " is not a defined subprogram prototype";
                result = null;
            }
        } else {
            errorMsg = " is not an subprogram prototype";
            result = null;
        }
    } else if (// Always after ComponentPrototype
    el instanceof CalledSubprogram) {
        // case.
        result = getSubprogramType((CalledSubprogram) el);
    } else if (el instanceof ComponentPrototypeBinding) {
        ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) el;
        // Takes the last binding.
        ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
        if (cpa.getSubcomponentType() instanceof SubprogramType) {
            result = (SubprogramType) cpa.getSubcomponentType();
        } else {
            errorMsg = " is not an subprogram prototype";
            result = null;
        }
    } else // Error case : the binded object is not an subprogram.
    {
        errorMsg = "is not subprogram";
        result = null;
    }
    // Error reporting.
    if (result == null && errorMsg != null) {
        String subprogramName = unparseReference(comAct.getReference());
        reportError(comAct, '\'' + subprogramName + '\'' + errorMsg);
    }
    return result;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) Element(org.osate.aadl2.Element) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) SubprogramType(org.osate.aadl2.SubprogramType) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) CalledSubprogram(org.osate.aadl2.CalledSubprogram) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 3 with ComponentPrototypeBinding

use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.

the class AadlBaUtils method getDataClassifier.

/**
 * Returns the DataClassifier object associated to the given List of PrototypeBinging objects.
 *
 * @param prototypeBindings the list of PrototypeBinging object
 * @param dp the DataPrototype searched for in prototypeBindings
 * @return the DataClassifier object (null if not found)
 */
private static DataClassifier getDataClassifier(List<PrototypeBinding> prototypeBindings, DataPrototype dp) {
    for (PrototypeBinding pb : prototypeBindings) {
        if (pb instanceof ComponentPrototypeBinding && pb.getFormal().equals(dp)) {
            ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) pb;
            ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
            if (cpa.getSubcomponentType() instanceof DataClassifier) {
                return (DataClassifier) cpa.getSubcomponentType();
            }
        }
    }
    return null;
}
Also used : ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) DataClassifier(org.osate.aadl2.DataClassifier) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding)

Example 4 with ComponentPrototypeBinding

use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.

the class AadlBaUtils method prototypeBindingResolver.

/**
 * Resolves the given prototype binding by returning the binded classifier
 * It returns {@code null} if the given prototype binding is not defined.
 *
 * @param pb the given prototype binding
 * @return the binded classifier or {@code null}
 */
public static Classifier prototypeBindingResolver(PrototypeBinding pb) {
    Classifier result = null;
    if (pb instanceof ComponentPrototypeBinding) {
        ComponentPrototypeBinding cpb;
        cpb = (ComponentPrototypeBinding) pb;
        // Takes the last binding.
        ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
        result = (Classifier) cpa.getSubcomponentType();
    } else if (pb instanceof FeaturePrototypeBinding) {
        FeaturePrototypeBinding fpb;
        fpb = (FeaturePrototypeBinding) pb;
        FeaturePrototypeActual fpa = fpb.getActual();
        if (fpa instanceof AccessSpecification) {
            result = ((AccessSpecification) fpa).getClassifier();
        } else if (fpa instanceof PortSpecification) {
            result = ((PortSpecification) fpa).getClassifier();
        } else {
            // Reports error.
            String errorMsg = "prototypeBindingResolver : " + fpa.getClass().getSimpleName() + " is not supported yet.";
            System.err.println(errorMsg);
            throw new UnsupportedOperationException(errorMsg);
        }
    } else if (pb instanceof FeatureGroupPrototypeBinding) {
        FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) pb;
        result = (FeatureGroupType) fgpb.getActual().getFeatureType();
    } else {
        // Reports error.
        String errorMsg = "prototypeBindingResolver : " + pb.getClass().getSimpleName() + " is not supported yet.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
    return result;
}
Also used : PortSpecification(org.osate.aadl2.PortSpecification) FeaturePrototypeActual(org.osate.aadl2.FeaturePrototypeActual) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) AccessSpecification(org.osate.aadl2.AccessSpecification) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) AadlString(org.osate.aadl2.AadlString) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding)

Example 5 with ComponentPrototypeBinding

use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.

the class Aadl2Utils method getBindedFeature.

private static Feature getBindedFeature(List<PrototypeBinding> bindings, Feature f) {
    FeatureClassifier cl = f.getFeatureClassifier();
    if ((!(cl instanceof DataPrototype)) || bindings == null || bindings.isEmpty()) {
        return f;
    }
    if ((f instanceof EventPort) || (f instanceof AbstractFeature)) {
        return f;
    }
    DataPrototype proto = (DataPrototype) cl;
    for (PrototypeBinding b : bindings) {
        if (!(b instanceof ComponentPrototypeBinding)) {
            continue;
        }
        ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) b;
        Prototype p = b.getFormal();
        if (p.getName().equals(proto.getName())) {
            List<ComponentPrototypeActual> actuals = cpb.getActuals();
            if (actuals != null && !actuals.isEmpty()) {
                ComponentPrototypeActual actual = actuals.get(0);
                SubcomponentType st = actual.getSubcomponentType();
                if (!(st instanceof DataClassifier)) {
                    continue;
                }
                DataClassifier dc = (DataClassifier) st;
                return setFeatureClassifier(f, dc);
            }
        }
    }
    return f;
}
Also used : FeatureClassifier(org.osate.aadl2.FeatureClassifier) DataPrototype(org.osate.aadl2.DataPrototype) Prototype(org.osate.aadl2.Prototype) EventPort(org.osate.aadl2.EventPort) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) SubcomponentType(org.osate.aadl2.SubcomponentType) AbstractFeature(org.osate.aadl2.AbstractFeature) DataPrototype(org.osate.aadl2.DataPrototype) DataClassifier(org.osate.aadl2.DataClassifier) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding)

Aggregations

ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)12 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)9 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)8 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)8 PrototypeBinding (org.osate.aadl2.PrototypeBinding)6 AccessSpecification (org.osate.aadl2.AccessSpecification)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 ComponentPrototype (org.osate.aadl2.ComponentPrototype)5 DataClassifier (org.osate.aadl2.DataClassifier)5 PortSpecification (org.osate.aadl2.PortSpecification)5 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)4 FeaturePrototypeReference (org.osate.aadl2.FeaturePrototypeReference)4 AadlString (org.osate.aadl2.AadlString)3 AbstractFeature (org.osate.aadl2.AbstractFeature)3 DataPrototype (org.osate.aadl2.DataPrototype)3 EventPort (org.osate.aadl2.EventPort)3 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)3 FeaturePrototype (org.osate.aadl2.FeaturePrototype)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2