Previous UML Classes Table of Contents UML Packages Next


17.5.10 Package

Templates


*Generalizations

   

    TemplateableElement (from Templates) on page 649

   

    Package (from Kernel ) on page 109

   Description

   Package specializes TemplateableElement and PackageableElement specializes ParameterableElement to specify that a package can be used as a template and a PackageableElement as a template parameter.

   Attributes

   No additional attributes

   Associations

   No additional associations

   Constraints

   No additional constraints

   Semantics

   A Package supports the ability to be defined as a template and PackageableElement s may, therefore, be parametered in a package template. A package template parameter may refer to any element owned or used by the package template, or templates nested within it, and so on recursively. That is, there are no special rules concerning how the parameters of a package template are defined.

   A package may be defined to be bound to one or more template packages. The semantics for these bindings is as described in the general case, with the exception that we need to spell out the rules for merging the results of multiple bindings. In that case, the effect is the same as taking the intermediate results and merging them into the eventual result using package merge. This is illustrated by the example below.

   Notation

   See TemplateableElement for a description of the general notation that is defined to support these added capabilities.

   Examples

   The example below shows a package template (named ResourceAllocation) with three formal template parameters. All three formal template parameters (named Resource, ResourceKind, and System) are unconstrained class template parameters. There is also a bound package (named CarRental) that substitutes Car for Resource, CarSpec for ResourceKind, and CarRentalSystem for System.


   Resource,

   <<bind>> <Resource -> Car, ResourceKind -> CarSpec, System -> CarRentalSystem>

   CarRental

   Figure 17.26 -Template Package and Bound Package