Previous Table of Contents Next


8.6 Semantics of Attributes

   Attributes are one of two mechanisms provided by the MOF Model for defining relationships between values at the M1level. An Attribute of an M2-level Class defines a relation between each M1-level Instance of the Class, and values of some other type. The Attribute specification consists of the following properties:

   Many aspects of the M1-level computational semantics of Attributes depend on the mapping used. The following sub clauses describe those aspects of the semantics that are mapping independent.

8.6.1 Attribute name and type

   The “name? and “type? of an Attribute define the basic signature of a notional binary relationship between a Class instance and an attribute value or values. For example, an Attribute declaration of the form:

   class Class1 {

   attribute attr_1 AttrType;};

   defines a notional relation between an M1-level type corresponding to the Class1 and an M1-level type corresponding to the AttrType. The three main kinds of relation that can exist between a Class and an Attribute are illustrated below in Figure 8.1. The figure shows cases where an Attribute’s “multiplicity? bounds are “[1..1]? (single-valued), “[0..1]? (optional) and “[m..n]? (multi-valued) respectively. Each notional relation is distinguishable from others for that Class by the Attribute’s “name.?


   single-valued Attribute optional Attribute multi-valued Attribute

   Figure 8.1 - Notional Class — Attribute Relations

   An M2-level Attribute’s “type? can be either a Class or a DataType. In the former case, the Class — AttrType relation relates M1-level Instances corresponding to the two Classes. In the latter case, it relates M1-level Instances corresponding to the Class to M1-level Instances corresponding to the DataType.

   In the following sub clauses, it is often necessary to talk about the type of the M1-level Instances on the AttrType end of a Class — AttrType relation. To make the text more readable, we will use the phrase “the Attribute’s M1-level base type? for this type rather than referring to it as “the M1-level type corresponding to the M2-level Attribute’s “type.? As we shall see, the phrase “the Attribute’s M1-level type? is best used for another purpose.

8.6.2 Multiplicity

   The “multiplicity? property defines the cardinality, uniqueness, and orderedness of an Attribute as follows:

   • The “lower? and “upper? fields set the bounds on the number of elements (i.e., cardinality) allowed in an Attribute value; that is, the “(collection of) AttrType? in Figure 8.1 and Figure 8.2 on page 143. Discussion of multiplicity usually needs to deal with three cases:

   The “multiplicity? settings of an M2-level Attribute have considerable influence on the M1-level Attributes values. In particular, it determines whether the M1-level type of the Attribute is the M1-level base type, or a collection of that type. In addition, the “multiplicity? may also cause:

   The “multiplicity? may also have considerable impact on the APIs that a mapping provides for accessing and updating Attribute values.

   It should be noted that when an M2-level Attribute has “isOrdered? set to true, the corresponding Class — AttrType relation has an associated partial ordering when viewed from the Class role.

8.6.3 Scope

   The “scope? of an Attribute can be either “instance_level? or “classifier_level.? For an “instance_level? Attribute, independent relationships exist between instances of MyClass and instances of AttrType. For a “classifier_level? Attribute, a single instance of AttrType (or a collection of AttrType) is related to all instances of MyClass in the extent. This is illustrated in Figure 8.2.

   my_attr


   my_attr

   MyClass

   c

   1:AttrType

   1

   1

   MyClass

   c

   1:AttrType

   1

   0..1

   my_attr

   MyClass

   c

   AttrType

   1 m..n

   single-valued

   my_attr


   optional

   my_attr AttrType

   multi-valued

   MyClass


   m..n

   instance-level scoped attributes classifier-level scoped attributes

   Figure 8.2 - Instance-level versus Classifier-level scoping

   NOTE: For the classifier-level Attributes, the diagrams are intended to show that all MyClass instances are related to a single instance or collection of instances of AttrType.

8.6.4 Is_derived

   The “isDerived? flag indicates whether the notional relationship between a Class instance and the Attribute type instances is stored or computed.

8.6.5 Aggregation

   The possible aggregation semantics of an Attribute depend on its type:

   In cases where an Attribute has “composite? semantics, the Class instance that is the value of the Attribute is a component of the Class instance that contains the Attribute, not vice-versa.

   NOTE: The above description reflects the fact that the Attribute model element does not have an “aggregation? attribute. A Class-valued Attribute with “non-aggregate? semantics is currently expressed by making the Attribute’s type a DataType, where the DataType’s “typeCode? is an object reference type that is linked to the Class via a TypeAlias.

8.6.6 Visibility and is_changeable

   The “visibility? property of an Attribute determines whether or not any operations for the notional relation should be present. Similarly, the “isChangeable? property determines whether update operations are present. The presence or absence of these operations do not alter the semantics of the Attribute.