Previous Table of Contents Next


6.3 Class Representations

   [6] ClassInstance := 7:ClassHeader 10:ParametricAttrs ‘{‘ 11:ClassContents ‘}’ (‘;’)?

   [7] ClassHeader := 8:ClassAdjectives < ClassName> (9: ClassIdentifier)?

   [8] ClassAdjectives := ( (‘~’? <AttributeName >) | 25:DataValue) *

   [9] ClassIdentifier := 28:TextualValue

   [10] ParametricAttrs := ‘(‘ 31:ValueList ‘)’

   [11] ClassContents := ( ( 18: AttributeInstance | 21: ReferenceInstance | 12: ContainedObject

    ) (‘;’)? ) *

   [12] ContainedObject := (<AssocName>’:’)? (6: ClassInstance | 13:ClassInstanceRef)

   The representation of a class consists of a number of parts; adjectives, class name, identifier, parametric representation, and contents. The contents consist of attribute, reference, and contained object representations. The parts appear in that order, to form the representation of the class. These attribute, reference, and contained instance representations appear within curly braces, in any order, optionally terminated by semicolons.

   There are two types of adjectives: single-valued boolean attributes, for which adjective representation is enabled by default; and single-valued enumeration-typed attributes, which must be configured as adjectives. Boolean attributes are represented by the attribute name, optionally prefixed by the ‘~’ symbol, representing negation. Enumerated adjectives are represented as the enumerator label corresponding to the value of the attribute. Adjectives can appear in any order.

   Class instances can be identified in one of two ways. Firstly, if a single-valued simple-typed attribute has been configured as the class’ identifying attribute, then the value of that attribute, formatted as appropriate for the attribute’s type, appears as the identifier. Alternatively, if no such identifier has been selected, then an arbitrary string may be used, or the instance may go unidentified. Unidentified instance representations have no identifier, and may only be used when the instance is not referred to from anywhere else in the document.

   If any single-valued, simple-typed attributes have been configured for parametric representation, then their values appear next inside parentheses. The values appear in the order specified by the parametric configuration, and are separated by whitespace or commas.

   Contained objects are those class instances linked by a containment association for which there are no references defined.

    Figure 6-3 and Figure 6-4 show examples of class representations, where the Family class is identified arbitrarily and by the familyName attribute, respectively. In both examples, the boolean nuclear attribute is used as an adjective.

   FamilyPackage “id-001? { Family “id-002? { familyName: “The McDonalds?

   Attribute and Reference representations

   } nuclear Family “id-003? { familyName: “The Smiths?

   Attribute and Reference representations

   } }

   Figure 6-3 An example of the representation of arbitrarily-identified class instances

   FamilyPackage “id-001? { Family “The McDonalds? {

   Attribute and Reference representations

   }nuclear Family “The Smiths? {

   Attribute and Reference representations

   } }

   Figure 6-4 An example of the representation of attribute-identified Class instances

    Figure 6-5 shows an example for metamodel of polygons, with a string attribute for their name, a boolean attribute for whether they are filled or not, and containment association with coordinate class. The coordinate class has only two floating point attributes, X and Y. The HUTN configuration for coordinates places X and Y in parametric form, and for polygons it provides the name attribute as a unique identifier and the default value ‘true’ for the filled attribute. The example shows filled used as a negated boolean adjective and the instance identifier as an undelimited string. The contained coordinate objects are shown inline with all their attribute values in parametric form, and their empty contents denoted by the use of a semicolon.

   ShapePackage triangles { ~filled polygon my_triangle { coordinate (3.6, 7.3); coordinate (5.2, 7.673); coordinate (9.4 ,13); }

   }

   Figure 6-5 An example of the use of various configuration options

   [13] ClassInstanceRef := ( (<ClassName>)? 14: ClassRefString ) | ExternalObjRef

   [14] ClassRefString := 15:PackageRootRef | 16:DocumentRootRef

   [15] PackageRootRef := 17:ClassRefSeparator 28:TextualValue (17:ClassRefSeparator 28:TextualValue) *

   [16] DocumentRootRef := 17:ClassRefSeparator 17:ClassRefSeparator 28:TextualValue (17:ClassRefSeparator 28:TextualValue) *

   [17] ClassRefSeparator:= ‘::’ | ‘.’ | ‘/’

   There are a number of cases in which a class instance can be referred to, either as a non-contained attribute of another class instance, via a MOF Reference, or in an association. The standard representation of one of these references consists of the class name followed by the identifying string for the class instance (explained below). Alternatively, the typeless references shorthand allows for the omission of the type name of the referred instance, leaving just the identifying string. (This is subject to the conditions stated in 4.2.3, “Defining and referencing major concepts?).

   The string used to refer to class instances is structured differently according to the uniqueness scope of the referred class’ identification system. If all_of_type scope is used, then the string is just the class identifier of the class referred to (arbitrary or identifying-attribute value). If container scope is used, then a number of these strings can be separated by either a double-colon, a full-stop, or a forwards-slash. These names are resolved relatively, moving up the containment hierarchy one level at a time until a match is found. If container is used, then a level is represented by a single string, which is the container’s identifier. If property_in_container is used, then a level is represented by two strings separated by a delimiter: the container’s identifier and the property name of the containment association. To indicate that the name should be resolved relative to the current package instance, a separator can be included as a prefix to the string. Regardless of which uniqueness scope is used, instances in other packages can be referenced by prefixing the string with a double separator followed by the identifying string of the package instance that contains the referred object.

   If the class instance referred to exists outside of the scope of the current document (including any references to external imported classes), then it is represented according to the rules in 6.7.5, “Object Reference.?

    Figure 6-6 shows a further example for the metamodel of polygons with an additional class “diagram,? which has a string name and a multi-valued-attribute “shapes? of type polygon. The text below is assumed to be in the same document as Figure 6-5.

   ShapePackage quads { polygon my_quad1 { coordinate (4.6, 78.3); coordinate (4.2, 7.3); coordinate (10.4 ,1.5); coordinate (33 ,8.5); }

   diagram two_shapes { shapes = [ //triangles/my_triangle, /my_quad1 ] } }

   Figure 6-6 An example of the use of package and document references