Previous UML Classes Table of Contents UML Packages Next


17.5.1 ParameterableElement

Templates


   A parameterable element is an element that can be exposed as a formal template parameter for a template, or specified as an actual parameter in a binding of a template.

*Generalizations

   

    Element (from Kernel ) on page 63

   Description

   A ParameterableElement can be referenced by a TemplateParameter when defining a formal template parameter for a template. A ParameterableElement can be referenced by a TemplateParameterSubstitution when used as an actual parameter in a binding of a template.

   ParameterableElement is an abstract metaclass.

   Attributes

   No additional attributes

   Associations

Issue 9110 - rename ‘owningParameter’ to ‘owningTemplateParameter’

   • owningTemplateParameter : TemplateParameter[0..1] The formal template parameter that owns this element. Subsets Element::owner and ParameterableElement::templateParameter.

   • templateParameter : TemplateParameter [0..1] The template parameter that exposes this element as a formal parameter.

   Constraints

   No additional constraints

   Additional Operations

   [1] The query isCompatibleWith() determines if this parameterable element is compatible with the specified parameterable element. By default parameterable element P is compatible with parameterable element Q if the kind of P is the same or a subtype as the kind of Q. Subclasses should override this operation to specify different compatibility constraints.

   ParameterableElement::isCompatibleWith(p : ParameterableElement) : Boolean;

   isCompatibleWith = p->oclIsKindOf(self.oclType)

   [2] The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter.

   ParameterableElement::isTemplateParameter() : Boolean;

   isTemplateParameter = templateParameter->notEmpty()

   Semantics

   A ParameterableElement may be part of the definition of a template parameter. The ParameterableElement is used to constrain the actual arguments that may be specified for this template parameter in a binding of the template.

   A ParameterableElement exposed as a template parameter can be used in the template as any other element of this kind defined in the namespace of the template. For example, a classifier template parameter can be used as the type of typed elements. In an element bound to the template, any use of the template parameter will be substituted by the use of the actual parameter.

   If a ParameterableElement is exposed as a template parameter, then the parameterable element is only meaningful within the template (it may not be used in other parts of the model).

   Semantic Variation Points

   The enforcement of template parameter constraints is a semantic variation point:

   

   If template parameter constraints apply, then within the template element a template parameter can only be used according to its constraint. For example, an operation template parameter can only be called with actual parameters matching the constraint in terms of the signature constraint of the operation template parameter. Applying constraints will imply that a bound element is well-formed if the template element is well-formed and if actual parameters comply with the formal parameter constraints.

   

   If template parameter constraints do not apply, then within the template element a template parameter can be used without being constrained. For example, an operation template parameter will have no signature in terms of parameters and it can be called with arbitrary actual parameters. Not applying constraints provides more flexibility, but some actual template parameters may not yield a well-formed bound element.

   Notation

   See TemplateParameter for a description of the notation for exposing a ParameterableElement as a formal parameter of a template.

   See TemplateBinding for a description of the notation for using a ParameterableElement as an actual parameter in a binding of a template.

   Within these notations, the parameterable element is typically shown as the name of the parametered element (if that element is a named element).

   Examples

   See TemplateParameter.