next up previous top
Next: User Defined Properties
Up: Property
Previous: TriggerDef

Variant

Description

The Variant property is used to further specify a component definition or instantiation. It provides the system designer with the means for specifying to the UniCon compiler which variant in a primitive implementation of a component to use during system construction.

Primitive implementations are composed of a list of variants. A variant is an alternative implementation. If a component has only one variant, the choice of alternative to use during system construction is obvious. If a component has more than one variant, the UniCon compiler must choose one of them. In this case, if the system designer does not specify a Variant property in either the component definition or its instantation, the UniCon compiler chooses the first variant in the list as the alternative implementation to use during system construction. If the system designer does specify a Variant property, the UniCon compiler uses the variant named in the value of that property as the alternative implementation.

The value of the Variant property must name a variant in the component definition that is being defined or instantiated. The Variant property is not permitted to further specify a component with a composite implementation in UniCon.

Property Lists

The Variant property can legally be specified in the property list in the following UniCon language elements:

Value Syntax

The syntax of the value part of the Variant property consists of a single <identifier> or "string", enclosed in parentheses. The case of the letters can be upper, lower, or mixed.

Required Rule

Optional

The default value for the Variant property is the name of the first variant in the list of variants in the primitive implementation of the component. If the component only has one variant, the name of that variant is the default.

Merge Rule

REPLACE

Subsequent specifications of the Variant property in a single property list replace earlier specifications (i.e., the last specification is the one that the UniCon compiler uses).

Semantic Checks

The following are the semantic checks performed on the value of the Variant property:

  1. The <identifier> or "string" value must name a variant in the component definition or instantiation in which the Variant property is specified.

  2. The component definition or instantiation in which the Variant property is specified must have a primitive implementation.

Example

The following are examples of specifications of Variant properties. The first is embedded in the definition of a Computation component:

  COMPONENT My_Sort_Library
    INTERFACE IS
      TYPE Computation
      LIBRARY
      VARIANT (sort_library)
      PLAYER bubble IS RoutineDef
        SIGNATURE ("int *"; "int *")
      END bubble
      PLAYER quick IS RoutineDef
        SIGNATURE ("int *"; "int *")
      END quick
      PLAYER merge IS RoutineDef
        SIGNATURE ("int *"; "int *")
      END merge
    END INTERFACE
    IMPLEMENTATION IS
      VARIANT sort_library IN "libs.a"
        IMPLTYPE (ObjectLibrary)
      END sort_library
      VARIANT debug_sort_library IN "libsdb.a"
        IMPLTYPE (ObjectLibrary)
      END debug_sort_library
    END IMPLEMENTATION
  END My_Sort_Library
This next example is embedded in an instantiation of the above component. The Variant property in the instantiation overrides the one in the definition:

  USES sortlib INTERFACE My_Sort_Library
    VARIANT (debug_sort_library)
  END sortlib

next up previous top
Next: User Defined Properties
Up: Property
Previous: TriggerDef

Comments? Mail the current maintainer of this page.

Author: Gregory Zelesnik

Last Modified: May 12, 1996