Prev - Next - Down | SDMetrics - the UML design measurement tool |
The SDMetrics metamodel is defined in an XML file of the following structure (for a formal definition, see Appendix E: "Project File Format Definitions"):
<sdmetricsmetamodel version="2.0" > <modelelement name="element1"> <attribute name="attr1" type="data" multiplicity="one" /> <attribute name="attr2" type="ref" multiplicity="many" /> .. </modelelement> <modelelement name="element2" parent="element1"> <attribute name="attr3" type="extref" multiplicity="one" /> ... </modelelement> ... </sdmetricsmetamodel>The metamodel definition file is a list of metamodel element definitions enclosed in <sdmetricsmetamodel> tags. The attribute "version" indicates the version number of the oldest version of SDMetrics with which the file can be used.
A metamodel element definition is enclosed in <modelelement> tags. The required attribute name specifies the name of the metamodel element (e.g., class, operation etc). The optional attribute parent specifies a parent metamodel element; the inheritance mechanism will be explained at the end of the section. Stored with each metamodel element is a set of metamodel attributes representing data fields and cross-references to other model elements. These are specified in a list of <attribute> definitions. We distinguish data attributes, cross-reference attributes, and extension references.
<modelelement name="operation"> <attribute name="id" /> <attribute name="name" /> <attribute name="context" type="ref" /> <attribute name="visibility" /> </modelelement>An operation has four single-valued attributes: data attributes id, name, and visibility, and cross-reference attribute context. In the example, the meaning of the attributes is as follows:
Note that extension reference attributes must be single-valued. A metamodel element can have at most one extension reference attribute.
Metamodel inheritance
To simplify the specification of metamodels, a metamodel element may inherit the attributes of another metamodel element. The parent metamodel element is specified via the parent attribute in the metamodel element definition:
<modelelement name="element2" parent="element1"> <!-- additional attributes of element2 (optional) --> </modelelement>In the example, an instance of model element "element2" has all attributes of "element1", and possibly additional attributes.
By default, all metamodel elements inherit from a special metamodel element named sdmetricsbase, which must be defined explicitly in every metamodel definition file. In the default metamodel that is shipped with SDMetrics, the sdmetricsbase element defines the attributes "id", "name", and "context" which all elements must possess. See Appendix A: "Metamodels" for a list of all metamodel elements and a description of their attributes.
Note that parent model elements must be defined before any of their child elements in the metamodel definition file. Consequently, the "sdmetricsbase" model element must be the first one defined in the file.
If the parent model element defines an extension reference attribute, the child model elements inherit the extension reference and therefore cannot define new extension references of their own.
Prev | Up | Next |
Section 7 "SDMetrics Metamodel and XMI Transformation Files" | Contents | Section 7.2 "XMI Transformation Files" |