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));
}
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));
}
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;
}
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;
}
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;
}
Aggregations