Previous Table of Contents Next


5.4.1 DataTypes Classes


   5.4.1.1 Enumeration

   The Enumeration class is intended as a starting point from which enumerated data types can be created. An enumerated data type is a collection of identifiers often used as the permitted states that some other attribute or property of the enumerated type may take.

   The isOrdered attribute of an Enumeration instance is used to determine if the ordered constraint on the EnumerationLiterals association is relevant for the enumeration. The particular ordering of EnumerationLiteral instances is obtained from the ordered constraint on the association even if the value attributes of the EnumerationLiteral instances contain non-null values that might be used to determine ordering. This is done to provide more flexible ordering semantics.

   An instance of Enumeration is also required to create a range data type. Refer to the EnumerationLiteral class for details.

   Superclasses

   DataType

   Contained Elements

   EnumerationLiteral

   Attributes

   isOrdered

If True, the ordered constraint on the EnumerationLiterals association is relevant. Otherwise, the ordering of EnumerationLiteral instances is considered unspecified.

type:

multiplicity:

Boolean
exactly one

   References

   literal

Identifies the EnumerationLiteral instances relevant for a particular Enumeration instance. If the Enumeration’s isOrdered attribute is True, the ordering constraint on this reference end can be used to determine a logical ordering for the EnumerationLiteral instances. Otherwise, ordering is ignored.

class:

defined by:

multiplicity:

inverse:

EnumerationLiteral
EnumerationLiterals::literal
one or more; ordered
EnumerationLiteral::enumeration

   5.4.1.2 EnumerationLiteral

   EnumerationLiteral instances describe the enumeration identifiers, and possibly the values, associated with an enumerated data type. Enumeration identifiers are contained in the name attribute derived from the EnumerationLiteral instance’s ModelElement superclass.

   EnumerationLiteral instances may also be used to define expression-based values such as ranges. To do so, simply state the membership expression in the instance’s value. For example, a range literal can be created by setting the value attribute to “m..n,? where m represents the lower bound of the range, and n, the upper bound. In this way, ranges and other more complicated expressions can be intermixed with simple enumeration literals. For example, an enumeration might contain the literals “1,? “2,? “4..7,? and “> 10.?

   Consequently, a simple range data type can be created with an Enumeration instance that owns a single EnumerationLiteral instance. For example, a data type for positive integers could be created as shown in Figure 5-6. A model attribute of this data type might then be declared as “posInt : PositiveInteger.?

   PositiveInteger : Enumeration


   PosIntRange :EnumerationLiteral


   Value = ">= 0"

   Figure 5-6 Using Enumeration and EnumerationLiteral instances to create range data types Superclasses

   ModelElement

   Attributes

   value

The value associated with an enumeration identifier can be stored here. The attribute is optional because enumeration literals are not required to have a specific, displayable value. This is indicated by either an empty value attribute or a value attribute value whose expression body attribute is a zero-length string.

type:

multiplicity:

Expression
zero or more

   References

   enumeration

Identifies the Enumeration instance for which this enumeration literal is relevant.

class:

defined by:

multiplicity:

inverse:

Enumeration
EnumerationLiterals::enumeration
exactly one
Enumeration::literal

   5.4.1.3 QueryExpression

   QueryExpression instances contain query statements in language-dependent form.

   Superclasses

   ProcedureExpression

   5.4.1.4 TypeAlias

   The TypeAlias class is intended to provide a renaming capability for Classifier instances. This class is required to support situations in which creation of an alias for a class effectively creates a new class. For example, CORBA IDL type aliases have different typeCodes than their base types and are therefore treated as distinct types.

   Superclasses

   DataType

   References

   type

Identifies the Classifier instance for which this TypeAlias instance acts as an alias.

class:

defined by:

multiplicity:

Classifier
ClassifierAlias::type
exactly one

   Constraints

   A TypeAlias instance cannot alias itself. [C-4-1]

   5.4.1.5 Union

   The Union class represents programming language unions and similarly structured data types. Because of the diversity of union semantics found across software systems, the Union and UnionMember classes are likely candidates for specialization to better capture union semantics in specific language extension packages.

   A discriminated Union has a collection of UnionMembers that determine the sets of contents that the Union may contain. Such Unions have an attribute called the discriminator that identifies the memberCase value of the UnionMember that the Union currently contains. The discriminator is found via the UnionDiscriminator association to StructuralFeature. The discriminator may be embedded within UnionMembers or may be located outside the discriminator. If it is located within UnionMembers, the discriminator should occur in every UnionMember at the same location (often, the first).

   Undiscriminated unions (for example, a C language union) are also supported, but have an empty discriminator reference, and the memberCase attribute of the UnionMembers it contains is ignored.

   Undiscriminated Unions are often used to represent alternate views of a single physical storage area. A fine degree of control over this aspect of Unions may be obtained by creating a class that derives from both UnionMember and FixedOffsetField (in the CWM Record package) and setting the offset attribute instances of that class accordingly.

   Superclasses

   Classifier

   Contained Elements

   UnionMember

   References

   discriminator

Identifies the StructuralFeature instance that serves as the discriminator for the Union.

class:

defined by:

multiplicity:

StructuralFeature
UnionDiscriminator::discriminator
zero or more

   Constraints

   A Union can have at most one default UnionMember instance. [C-4-2]

   5.4.1.6 UnionMember

   UnionMembers are described as features of a Union and each represents one of the members of a Union. Note, however, that multiple case values can map to a single UnionMember. If isDefault is true, the union member is the default member. UnionMember instances are allowed to have a memberCase and be the default case.

   UnionMember instances often represent structured storage areas. A particular UnionMember may be associated with a Classifier that describes its internal structure via the StructuralFeatureType association (defined in the ObjectModel::Core package). For example, the Record::Group class, itself a Classifier, can be used as the type of a UnionMember in a manner completely analogous to how it is used to describe the type of a structured field (see the instance diagrams in the Record metamodel chapter for details).

   Superclasses

   Attribute

   Attributes

   memberCase isDefault

Contains the value of the Union’s discriminator for this UnionMember.

type:

multiplicity:

Expression
exactly one

Indicates if this UnionMember is the default member of the Union (implying that when unstated, the Union’s discriminator would assume this instance’s memberCase value).

type:

multiplicity:

Boolean
exactly one