use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class ConnectionImpl method getAllDstContextComponent.
/*
* (non-Javadoc)
*
* @see org.osate.aadl2.Connection#getAllDstContextComponent()
*/
public NamedElement getAllDstContextComponent() {
Connection conn = getRootConnection();
Context dcxt = conn.getAllDestinationContext();
if (dcxt instanceof FeatureGroup) {
return conn.getContainingComponentImpl();
}
return dcxt;
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class ConnectionImpl method getAllSrcContextComponent.
/*
* (non-Javadoc)
*
* @see org.osate.aadl2.Connection#getAllSrcContextComponent()
*/
public NamedElement getAllSrcContextComponent() {
Connection conn = getRootConnection();
Context scxt = conn.getAllSourceContext();
if (scxt instanceof FeatureGroup) {
return conn.getContainingComponentImpl();
}
return scxt;
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class FeatureGroupImpl method isInverseOf.
/**
* check for inverseof between two features.
* If they are feature groups then we check both the inverse of on the feature group and whether the feature group type is inverseof.
* @param f1
* @param f2
* @return boolean
*/
public boolean isInverseOf(FeatureGroup fg2) {
FeatureGroupType fgt1 = getAllFeatureGroupType();
FeatureGroupType fgt2 = fg2.getAllFeatureGroupType();
if (fgt1.isInverseOf(fgt2) && (isInverse() == fg2.isInverse())) {
return true;
}
if (fgt1 == fgt2 && (isInverse() != fg2.isInverse())) {
return true;
}
return false;
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class PropertyImpl method getPropertyValueFromDeclarativeModel.
protected void getPropertyValueFromDeclarativeModel(EvaluationContext ctx, PropertyAcc pas) throws InvalidModelException {
InstanceObject io = ctx.getInstanceObject();
List<? extends NamedElement> compDecls = io.getInstantiatedObjects();
if (compDecls == null) {
}
// Here we assume compDecls is empty or has only one element
if (!compDecls.isEmpty()) {
NamedElement compDecl = compDecls.get(0);
if (compDecl == null) {
return;
}
InstantiatedClassifier ic = ctx.getClassifierCache().get(io);
Classifier cl = (ic == null) ? null : ic.getClassifier();
if (compDecl instanceof Subcomponent) {
((SubcomponentImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof FeatureGroup) {
((FeatureGroupImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof Feature) {
((FeatureImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof PortConnection) {
((PortConnectionImpl) compDecl).getPropertyValue(this, pas);
} else {
compDecl.getPropertyValueInternal(this, pas, true);
}
}
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class InstanceUtil method getInstantiatedClassifier.
/**
* Get the component or feature group classifier that is instantiated by an
* instance object. Resolve prototypes if needed.
*
* @param iobj the instance object
* @param index the index of the instance object in an array
* @param classifierCache an optional cache of known instantiated
* classifiers, may be null
* @return the instantiated classifier together with bindings for anonymous
* classifiers
*/
public static InstantiatedClassifier getInstantiatedClassifier(InstanceObject iobj, int index, HashMap<InstanceObject, InstantiatedClassifier> classifierCache) {
InstantiatedClassifier ic = null;
if (classifierCache != null) {
final InstantiatedClassifier temp = classifierCache.get(iobj);
if (temp != null) {
return temp == InstantiatedClassifier.NULL ? null : temp;
}
}
if (iobj instanceof SystemInstance) {
ic = new InstantiatedClassifier(((SystemInstance) iobj).getComponentImplementation(), null);
}
if (ic == null) {
Classifier classifier = null;
EList<PrototypeBinding> prototypeBindings = null;
Prototype prototype = null;
if (iobj instanceof ComponentInstance) {
Subcomponent sub = ((ComponentInstance) iobj).getSubcomponent();
classifier = sub.getClassifier();
prototypeBindings = sub.getOwnedPrototypeBindings();
prototype = sub.getPrototype();
} else if (iobj instanceof FeatureInstance) {
FeatureType ft = ((FeatureGroup) ((FeatureInstance) iobj).getFeature()).getFeatureType();
classifier = (ft instanceof Classifier) ? (Classifier) ft : null;
prototype = (ft instanceof Prototype) ? (Prototype) ft : null;
} else {
return null;
}
if (classifier != null) {
ic = new InstantiatedClassifier(classifier, prototypeBindings);
}
// no classifier => try prototype
if (ic == null) {
if (prototype != null) {
// resolve prototype
if (prototype instanceof ComponentPrototype) {
ComponentPrototypeActual cpa = resolveComponentPrototype(prototype, iobj, classifierCache);
if (cpa != null) {
ic = new InstantiatedClassifier((ComponentClassifier) cpa.getSubcomponentType(), cpa.getBindings());
} else {
// ISSUE 986: If the constraining classifier is missing (null), then don't create an InstantiatedClassifier object
final ComponentClassifier cc = ((ComponentPrototype) prototype).getConstrainingClassifier();
if (cc != null) {
ic = new InstantiatedClassifier(cc, noBindings);
}
}
} else if (prototype instanceof FeatureGroupPrototype) {
FeatureGroupPrototypeActual fpa = resolveFeatureGroupPrototype(prototype, iobj, classifierCache);
if (fpa != null) {
ic = new InstantiatedClassifier((FeatureGroupType) fpa.getFeatureType(), fpa.getBindings());
} else {
ic = new InstantiatedClassifier(((FeatureGroupPrototype) prototype).getConstrainingFeatureGroupType(), noBindings);
}
}
}
}
}
if (classifierCache != null) {
classifierCache.put(iobj, ic == null ? InstantiatedClassifier.NULL : ic);
}
return ic;
}
Aggregations