Search in sources :

Example 1 with FeaturePrototypeBinding

use of org.osate.aadl2.FeaturePrototypeBinding 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 FeaturePrototypeBinding

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

the class DataAccessPrototypeHolderItemProvider method getImage.

/**
 * This returns DataAccessPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    AccessType type = null;
    PrototypeHolder holder = (PrototypeHolder) object;
    FeaturePrototypeBinding fpb = (FeaturePrototypeBinding) holder.getPrototypeBinding();
    if (fpb != null) {
        type = ((AccessSpecification) fpb.getActual()).getKind();
    } else {
        type = AccessType.REQUIRES;
    }
    switch(type) {
        case PROVIDES:
            {
                imgFile += "ProvidesDataAccess";
                break;
            }
        default:
        case REQUIRES:
            {
                imgFile += "RequiresDataAccess";
                break;
            }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) AccessType(org.osate.aadl2.AccessType) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 3 with FeaturePrototypeBinding

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

the class AadlBaUtils method getFeatPrototypeType.

/**
 * Translates the given FeaturePrototypeBinding object into a FeatureType
 * enumeration.
 *
 * @param fpb the given FeaturePrototypeBinding
 * @return the translation in FeatureType object
 * @exception UnsupportedOperationException for the unsupported types
 */
public static FeatureType getFeatPrototypeType(FeaturePrototypeBinding fpb) {
    FeaturePrototypeActual fpa = fpb.getActual();
    if (fpa instanceof AccessSpecification) {
        AccessSpecification as = (AccessSpecification) fpa;
        boolean isRequired = as.getKind() == AccessType.REQUIRES;
        switch(as.getCategory()) {
            case BUS:
                {
                    return (isRequired) ? FeatureType.REQUIRES_BUS_ACCESS_PROTOTYPE : FeatureType.PROVIDES_BUS_ACCESS_PROTOTYPE;
                }
            case DATA:
                {
                    return (isRequired) ? FeatureType.REQUIRES_DATA_ACCESS_PROTOTYPE : FeatureType.PROVIDES_DATA_ACCESS_PROTOTYPE;
                }
            case SUBPROGRAM:
                {
                    return (isRequired) ? FeatureType.REQUIRES_SUBPROGRAM_ACCESS_PROTOTYPE : FeatureType.PROVIDES_SUBPROGRAM_ACCESS_PROTOTYPE;
                }
            case SUBPROGRAM_GROUP:
                {
                    return (isRequired) ? FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE : FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE;
                }
        }
    } else if (fpa instanceof PortSpecification) {
        PortSpecification ps = (PortSpecification) fpa;
        if (ps.getCategory() == PortCategory.DATA) {
            switch(ps.getDirection()) {
                case IN:
                    return FeatureType.IN_DATA_PORT_PROTOTYPE;
                case OUT:
                    return FeatureType.OUT_DATA_PORT_PROTOTYPE;
                case IN_OUT:
                    return FeatureType.IN_OUT_DATA_PORT_PROTOTYPE;
            }
        } else if (ps.getCategory() == PortCategory.EVENT) {
            switch(ps.getDirection()) {
                case IN:
                    return FeatureType.IN_EVENT_PORT_PROTOTYPE;
                case OUT:
                    return FeatureType.OUT_EVENT_PORT_PROTOTYPE;
                case IN_OUT:
                    return FeatureType.IN_OUT_EVENT_PORT_PROTOTYPE;
            }
        } else {
            switch(ps.getDirection()) {
                case IN:
                    return FeatureType.IN_EVENT_DATA_PORT_PROTOTYPE;
                case OUT:
                    return FeatureType.OUT_EVENT_DATA_PORT_PROTOTYPE;
                case IN_OUT:
                    return FeatureType.IN_OUT_EVENT_DATA_PORT_PROTOTYPE;
            }
        }
    } else if (fpa instanceof FeatureGroupPrototypeActual) {
        return FeatureType.FEATURE_GROUP_PROTOTYPE;
    } else {
        // Reports error.
        String errorMsg = "getFeatPrototypeType : " + fpa.getClass().getSimpleName() + " is not supported yet.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
    return FeatureType.NONE;
}
Also used : PortSpecification(org.osate.aadl2.PortSpecification) FeaturePrototypeActual(org.osate.aadl2.FeaturePrototypeActual) AccessSpecification(org.osate.aadl2.AccessSpecification) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) AadlString(org.osate.aadl2.AadlString)

Example 4 with FeaturePrototypeBinding

use of org.osate.aadl2.FeaturePrototypeBinding 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 FeaturePrototypeBinding

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

the class ResolvePrototypeUtil method resolveFeaturePrototype.

/**
 * Find the binding for a given feature prototype. Recursively resolves references.
 *
 * @param proto the prototype to resolve
 * @param context the context in which the prototype is used, e.g., a ComponentType, FeatureGroupType
 * @return the actual feature this prototype resolves to.
 */
public static FeaturePrototypeBinding resolveFeaturePrototype(Prototype proto, Element context) {
    final FeaturePrototypeBinding fpb = (FeaturePrototypeBinding) resolvePrototype(proto, context);
    if (fpb == null) {
        // cannot resolve
        return null;
    }
    final FeaturePrototypeActual actual = fpb.getActual();
    if (actual instanceof FeaturePrototypeReference) {
        // If context is FeatureGroupPrototypeActual, use containing classifier as the context for the reference
        if (context instanceof FeatureGroupPrototypeActual) {
            context = context.getContainingClassifier();
        }
        return resolveFeaturePrototype(((FeaturePrototypeReference) actual).getPrototype(), context);
    }
    return fpb;
}
Also used : FeaturePrototypeActual(org.osate.aadl2.FeaturePrototypeActual) FeaturePrototypeReference(org.osate.aadl2.FeaturePrototypeReference) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding)

Aggregations

FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)12 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)7 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)7 AccessSpecification (org.osate.aadl2.AccessSpecification)6 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)6 FeaturePrototypeActual (org.osate.aadl2.FeaturePrototypeActual)6 FeaturePrototypeReference (org.osate.aadl2.FeaturePrototypeReference)6 PortSpecification (org.osate.aadl2.PortSpecification)6 AadlString (org.osate.aadl2.AadlString)4 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)4 PrototypeBinding (org.osate.aadl2.PrototypeBinding)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 EObject (org.eclipse.emf.ecore.EObject)2 AbstractFeature (org.osate.aadl2.AbstractFeature)2 AccessType (org.osate.aadl2.AccessType)2 BusAccess (org.osate.aadl2.BusAccess)2 ComponentClassifier (org.osate.aadl2.ComponentClassifier)2 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)2 FeaturePrototype (org.osate.aadl2.FeaturePrototype)2