use of org.osate.aadl2.PrototypeBinding in project osate2 by osate.
the class AadlBaUtils method getFeatureType.
/**
* Analyze the given AADL Osate element and return its enumeration type.
*
* It's an improved version of Osate2 org.osate.parser.AadlSemanticCheckSwitch#getFeatureType
*
* @param el the given AADL Osate element
* @return the given AADL Osate element's type
* @exception UnsupportedOperationException for the unsupported types
*/
/*
* <copyright>
* Copyright 2009 by Carnegie Mellon University, all rights reserved.
*
* Use of the Open Source AADL Tool Environment (OSATE) is subject to the terms of the license set forth
* at http://www.eclipse.org/legal/cpl-v10.html.
*
* NO WARRANTY
*
* ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER PROPERTY OR RIGHTS GRANTED OR PROVIDED BY
* CARNEGIE MELLON UNIVERSITY PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN "AS-IS" BASIS.
* CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING,
* BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, INFORMATIONAL CONTENT,
* NONINFRINGEMENT, OR ERROR-FREE OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR
* CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE,
* REGARDLESS OF WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. LICENSEE AGREES THAT IT WILL NOT
* MAKE ANY WARRANTY ON BEHALF OF CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON CONCERNING THE
* APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE DELIVERABLES UNDER THIS LICENSE.
*
* Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie Mellon University, its trustees, officers,
* employees, and agents from all claims or demands made against them (and any related losses, expenses, or
* attorney's fees) arising out of, or relating to Licensee's and/or its sub licensees' negligent use or willful
* misuse of or negligent conduct or willful misconduct regarding the Software, facilities, or other rights or
* assistance granted by Carnegie Mellon University under this License, including, but not limited to, any claims of
* product liability, personal injury, death, damage to property, or violation of any laws or regulations.
*
* Carnegie Mellon University Software Engineering Institute authored documents are sponsored by the U.S. Department
* of Defense under Contract F19628-00-C-0003. Carnegie Mellon University retains copyrights in all material produced
* under this contract. The U.S. Government retains a non-exclusive, royalty-free license to publish or reproduce these
* documents, or allow others to do so, for U.S. Government purposes only pursuant to the copyright license
* under the contract clause at 252.227.7013.
* </copyright>
*/
public static org.osate.ba.aadlba.FeatureType getFeatureType(Element el) {
if (el instanceof DataPort) {
switch(((DataPort) el).getDirection()) {
case IN:
return FeatureType.IN_DATA_PORT;
case OUT:
return FeatureType.OUT_DATA_PORT;
case IN_OUT:
return FeatureType.IN_OUT_DATA_PORT;
}
} else if (el instanceof EventPort) {
switch(((EventPort) el).getDirection()) {
case IN:
return FeatureType.IN_EVENT_PORT;
case OUT:
return FeatureType.OUT_EVENT_PORT;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_PORT;
}
} else if (el instanceof EventDataPort) {
switch(((EventDataPort) el).getDirection()) {
case IN:
return FeatureType.IN_EVENT_DATA_PORT;
case OUT:
return FeatureType.OUT_EVENT_DATA_PORT;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_DATA_PORT;
}
} else if (el instanceof FeatureGroup) {
return FeatureType.FEATURE_GROUP;
} else if (el instanceof DataAccess) {
switch(((DataAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_DATA_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_DATA_ACCESS;
}
} else if (el instanceof SubprogramAccess) {
switch(((SubprogramAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_ACCESS;
}
} else if (el instanceof SubprogramGroupAccess) {
switch(((SubprogramGroupAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
}
} else if (el instanceof BusAccess) {
switch(((BusAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_BUS_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_BUS_ACCESS;
}
} else if (el instanceof AbstractFeature) {
return FeatureType.ABSTRACT_FEATURE;
} else if (el instanceof Parameter) {
switch(((Parameter) el).getDirection()) {
case IN:
return FeatureType.IN_PARAMETER;
case OUT:
return FeatureType.OUT_PARAMETER;
case IN_OUT:
return FeatureType.IN_OUT_PARAMETER;
}
} else if (el instanceof Prototype) {
if (el instanceof ComponentPrototype) {
switch(el.eClass().getClassifierID()) {
case Aadl2Package.SUBPROGRAM_PROTOTYPE:
return FeatureType.SUBPROGRAM_PROTOTYPE;
case Aadl2Package.SUBPROGRAM_GROUP_PROTOTYPE:
return FeatureType.SUBPROGRAM_GROUP_PROTOTYPE;
case Aadl2Package.THREAD_PROTOTYPE:
return FeatureType.THREAD_PROTOTYPE;
case Aadl2Package.THREAD_GROUP_PROTOTYPE:
return FeatureType.THREAD_GROUP_PROTOTYPE;
default:
return FeatureType.COMPONENT_PROTOTYPE;
}
} else if (el instanceof FeaturePrototype) {
return getFeaturePrototypeType((FeaturePrototype) el);
} else if (el instanceof FeatureGroupPrototype) {
return FeatureType.FEATURE_GROUP_PROTOTYPE;
}
} else if (el instanceof PrototypeBinding) {
if (el instanceof ComponentPrototypeBinding) {
return FeatureType.COMPONENT_PROTOTYPE_BINDING;
} else if (el instanceof FeatureGroupPrototypeBinding) {
return FeatureType.FEATURE_GROUP_PROTOTYPE_BINDING;
} else // FeaturePrototypeBinding case.
{
return FeatureType.FEATURE_PROTOTYPE_BINDING;
}
} else if (el instanceof org.osate.aadl2.PropertyConstant) {
return FeatureType.PROPERTY_CONSTANT;
} else if (el instanceof org.osate.aadl2.Property) {
return FeatureType.PROPERTY_VALUE;
} else if (el instanceof ClassifierValue) {
return FeatureType.CLASSIFIER_VALUE;
} else if (el instanceof SubprogramGroup) {
return FeatureType.SUBPROGRAM_GROUP;
} else if (el instanceof SubprogramGroupAccess) {
switch(((SubprogramGroupAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
}
} else if (el instanceof ThreadGroup) {
return FeatureType.THREAD_GROUP;
} else if (el instanceof SystemSubcomponent) {
return FeatureType.SYSTEM_SUBCOMPONENT;
} else if (el instanceof SubprogramSubcomponent) {
return FeatureType.SUBPROGRAM_SUBCOMPONENT;
} else if (el instanceof SubprogramClassifier) {
return FeatureType.SUBPROGRAM_CLASSIFIER;
} else if (el instanceof DataSubcomponent) {
return FeatureType.DATA_SUBCOMPONENT;
} else if (el instanceof DataClassifier) {
return FeatureType.DATA_CLASSIFIER;
} else if (el instanceof ProcessorClassifier) {
return FeatureType.PROCESSOR_CLASSIFIER;
} else if (el instanceof ProcessClassifier) {
return FeatureType.PROCESS_CLASSIFIER;
}
String errorMsg = "getFeatureType : " + el.getClass().getSimpleName() + " is not supported yet at line " + Aadl2Utils.getLocationReference(el).getLine() + ".";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
use of org.osate.aadl2.PrototypeBinding in project osate2 by osate.
the class Aadl2Visitors method findPrototypeBindingInComponent.
/**
* Returns the first occurrence of a PrototypeBinding object within the given
* component or component implementation and its ancestors which concerns
* a prototype which name equals to the given one or {@code null}
* if there isn't matching PrototypeBinding object found.
* @param c the given component or component implementation
* @param prototypeName the prototype name
* @return the first occurrence of a PrototypeBinding object or {@code null}
*/
public static PrototypeBinding findPrototypeBindingInComponent(Classifier c, String prototypeName) {
if (c == null) {
return null;
}
PrototypeBinding result = null;
for (PrototypeBinding pb : c.getOwnedPrototypeBindings()) {
if (pb.getFormal() != null && prototypeName.equalsIgnoreCase(pb.getFormal().getName())) {
return pb;
}
}
// Recursive call for component implementation.
if (result == null && c instanceof ComponentImplementation) {
ComponentImplementation ci = (ComponentImplementation) c;
result = findPrototypeBindingInComponent(ci.getType(), prototypeName);
}
// Recursive call for parent component.
if (result == null && c.getExtended() != null) {
result = findPrototypeBindingInComponent(c.getExtended(), prototypeName);
}
return result;
}
use of org.osate.aadl2.PrototypeBinding in project osate2 by osate.
the class AadlBaNameResolver method classifierFeaturePropertyReferenceResolver.
private boolean classifierFeaturePropertyReferenceResolver(DeclarativePropertyReference ref) {
Reference component = ref.getReference();
if (refResolver(component)) {
PropertyAssociation pa = null;
Classifier type = null;
Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
Element el = (component.getOsateRef() != null) ? component.getOsateRef() : component.getBaRef();
if (el instanceof PrototypeBinding) {
PrototypeBinding pb = (PrototypeBinding) el;
type = AadlBaUtils.getClassifier(pb, pb.getContainingClassifier());
} else if (el instanceof ClassifierFeature) {
ClassifierFeature cf = (ClassifierFeature) el;
// Fetch the own property association of the classifier feature.
pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), cf);
if (pa == null) {
type = AadlBaUtils.getClassifier(cf, cf.getContainingClassifier());
}
} else if (el instanceof BehaviorVariable) {
BehaviorVariable bv = (BehaviorVariable) el;
DeclarativeBehaviorElement de = (DeclarativeBehaviorElement) bv.getDataClassifier();
if (de.getOsateRef() instanceof Classifier) {
type = (Classifier) de.getOsateRef();
}
} else // Cannot resolve or unimplemented cases.
{
String msg = "the type of \'" + ((NamedElement) el).getName() + "\' cannot be resolved";
_errManager.error(el, msg);
}
// search within its type.
if (pa == null && type != null) {
pa = PropertyUtils.findPropertyAssociation(propertyNameId.getId(), type);
}
if (pa != null) {
ref.getPropertyNames().get(0).setOsateRef(pa);
propertyNameId.setOsateRef(pa);
return propertyNameResolver(ref.getPropertyNames());
} else {
reportNameError(propertyNameId, propertyNameId.getId());
return false;
}
} else {
// refResolver has already reported the error.
return false;
}
}
use of org.osate.aadl2.PrototypeBinding in project osate2 by osate.
the class PortPrototypeHolderImpl method setPrototypeBinding.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setPrototypeBinding(PrototypeBinding newPrototypeBinding) {
PrototypeBinding oldPrototypeBinding = prototypeBinding;
prototypeBinding = newPrototypeBinding;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AadlBaPackage.PORT_PROTOTYPE_HOLDER__PROTOTYPE_BINDING, oldPrototypeBinding, prototypeBinding));
}
use of org.osate.aadl2.PrototypeBinding in project osate2 by osate.
the class SubcomponentImpl method createOwnedPrototypeBinding.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public PrototypeBinding createOwnedPrototypeBinding(EClass eClass) {
PrototypeBinding newOwnedPrototypeBinding = (PrototypeBinding) create(eClass);
getOwnedPrototypeBindings().add(newOwnedPrototypeBinding);
return newOwnedPrototypeBinding;
}
Aggregations