
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.
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.
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).
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

Author:
Last Modified: May 12, 1996