Exemplo n.º 1
0
  public final void getPropertyValueInternal(
      final Property property, final PropertyAcc pas, final boolean fromInstanceSlaveCall)
      throws InvalidModelException {
    /*
     * First see if the property is defined locally in the instance. Such
     * local property associations arise from component property
     * associations in the declarative spec, from explicit programmatic
     * setting of the property, or as cached results from earlier property
     * lookups.
     */
    if (pas.addLocal(this)) {
      return;
    }

    /*
     * If we don't find the property locally we defer to the declarative
     * specifications.
     */
    getPropertyValueFromDeclarativeModel(property, pas);

    /*
     * If we still don't have a value, and the property is "inherit", get it
     * from the enclosing component instance. Don't short-circuit this step
     * because the property caching during instantiation doesn't catch
     * contained property values that may be attached to an ancestor
     * instance and that might be inherited by this instance.
     */
    if (property.isInherit()) {
      final NamedElement ph = (NamedElement) eContainer();
      if (ph != null) {
        ph.getPropertyValueInternal(property, pas, false);
      }
    }
  }
Exemplo n.º 2
0
 /**
  * Get the property value from the declarative model elements associated with the instance object.
  * This implementation works for everything but ConnectionInstances; this method is overridden in
  * ConnectionInstance to handle the problem of dealing with all the connections that make up the
  * semantic connection.
  *
  * @param property The property to lookup
  * @param pva The property value accumulator to use to build the property value
  * @throws InvalidModelException Thrown if the property value cannot be retrieved because the
  *     model is incomplete or otherwise invalid.
  */
 protected void getPropertyValueFromDeclarativeModel(
     final Property property, final PropertyAcc pas) throws InvalidModelException {
   // apv.pushCurrentComponent(getContainingComponentInstanceOrSelf());
   try {
     final List<? extends NamedElement> compDecls = getInstantiatedObjects();
     // Here we assume compDecls is empty or has only one element
     if (!compDecls.isEmpty()) {
       final NamedElement compDecl = compDecls.get(0);
       if (compDecl == null) return;
       compDecl.getPropertyValueInternal(property, pas, true);
     }
   } finally {
     // apv.popCurrentComponent();
   }
 }
 public void setStreamMissRate(final NamedElement ph, final double rate) {
   final RealLiteral newPropertyValue = Aadl2Factory.eINSTANCE.createRealLiteral();
   newPropertyValue.setValue(rate);
   ph.setPropertyValue(
       GetProperties.lookupPropertyDefinition(ph, SEI._NAME, SEI.STREAM_MISS_RATE),
       newPropertyValue);
 }
Exemplo n.º 4
0
 /**
  * Check that ph is not null and returns the property value by calling
  * ph.getSimplePropertyValue(pd)
  *
  * @param ph The property holder from which to retrieve the property value.
  * @param pd The property to retrieve.
  * @return The retrieved property value.
  * @throws InvalidModelException Thrown if the property value cannot be retrieved because the
  *     model is incomplete or otherwise invalid.
  * @throws PropertyNotPresentException Thrown if the property is undefined for ph.
  * @throws PropertyIsModalException Thrown if ph is modal and declarative.
  * @throws IllegalStateException Thrown if the lookup encounters a cycle of property reference
  *     dependencies.
  * @throws IllegalArgumentException Thrown if ph or pd is null.
  * @throws PropertyDoesNotApplyToHolderException Thrown if pd does not apply to ph.
  * @throws PropertyIsListException Thrown if the property is not scalar.
  */
 public static PropertyExpression getSimplePropertyValue(final NamedElement ph, final Property pd)
     throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException,
         IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException,
         PropertyIsListException {
   if (ph == null) {
     throw new IllegalArgumentException("NamedElement ph cannot be null.");
   }
   PropertyExpression res = ph.getSimplePropertyValue(pd);
   if (res instanceof NamedValue) {
     AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
     if (nv instanceof Property) {
       res = ph.getSimplePropertyValue((Property) nv);
     } else if (nv instanceof PropertyConstant) {
       res = ((PropertyConstant) nv).getConstantValue();
     }
   }
   return res;
 }
 private void error(NamedElement el, String s) {
   super.error(el, s);
   if (previousNE == null || previousNE != el) {
     if (previousNE != null) action.logInfo("");
     action.logInfo(el.getName() + "," + s);
   } else {
     action.logInfo("," + s);
   }
   previousNE = el;
 }
Exemplo n.º 6
0
 public static Classifier getClassifierReference(final NamedElement ph, final Property pd) {
   if (ph == null) {
     return null;
   }
   try {
     final PropertyExpression pv = ph.getSimplePropertyValue(pd);
     final Classifier ref = ((ClassifierValueImpl) pv).getClassifier();
     return ref;
   } catch (PropertyLookupException e) {
     return null;
   }
 }
Exemplo n.º 7
0
  /**
   * get a property association from the properties section of the containing classifier if the
   * context. This method has been designed to work with end points of connections, i.e., consisting
   * of a target and a context. The context must be a NamedElement in its containing classifier,
   * i.e., a feature, feature group, subcomponent. The property holder is assumed to be contained in
   * the context object, e.g., a feature in afeature group or a data subcomponent in a port, or
   * feature in a subcomponent. The association must match the property definition. if the context
   * is null then the containing classifier of the target is used and the path must be one or no
   * path. The applies to clause of the property association must be of size 2 if the context is set
   * and point to the context and then the property holder. The property value of the property
   * association is assumed not to be modal.
   *
   * @param context NamedElement whose containing classifier's properties section is searched for
   *     the desired property
   * @param target NamedElement the model element to which the property is applied to via the
   *     applies to clause
   * @param pd Property the property definition
   * @return
   */
  public static PropertyExpression getContainedSimplePropertyValue(
      final NamedElement context, final NamedElement target, final Property pd) {
    if (context == null) return target.getNonModalPropertyValue(pd);
    Classifier cl = AadlUtil.getContainingClassifier(context);
    EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : props) {
      if (propertyAssociation.getProperty().equals(pd)) {
        // we found a property with the corect type
        // now we need to check whether the applies to points to the holder
        EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
        for (ContainedNamedElement containedNamedElement : appliestos) {
          EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
          if (cpes.size() == 2) {
            NamedElement pathcxt = cpes.get(0).getNamedElement();
            NamedElement pathelement = cpes.get(1).getNamedElement();
            if (context.equals(pathcxt) && target.equals(pathelement)) {
              EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
              if (!vallist.isEmpty()) {
                ModalPropertyValue elem = vallist.get(0);
                PropertyExpression res = elem.getOwnedValue();
                if (res instanceof NamedValue) {
                  AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
                  if (nv instanceof Property) {
                    res = target.getNonModalPropertyValue((Property) nv);
                  } else if (nv instanceof PropertyConstant) {
                    res = ((PropertyConstant) nv).getConstantValue();
                  }
                }

                return res;
              }
            }
          }
        }
      }
    }
    return null;
  }