• No results found

5 Model Integration Concept

5.3 Overview of the Parts of the Model Integration Concept

and meta model view on the attribute version: The attribute is expressed as declaration of an annotation member. Its type is declared correspondingly.

The relation between the model element and the type declaration with the attached annota-tion in the example is based on the relaannota-tionship between the type declaraannota-tion and the attached annotation. The fact that the annotation is attached to the type defines that this type repre-sents an instance of a ComponentType meta model element. The name of the type is declared to be equivalent with the value of the attribute name. The value of the annotation member version is equivalent to the value of the attribute in the corresponding model element.

The example shows that two categories of bidirectional translations are necessary, one be-tween the meta model and program code, and one bebe-tween the model and program code. The translations have to be set up so that the relationship between meta model elements and their model instances are consistently translated into program code. E.g. the type of the annotation member version enforces that the values entered can be used as values for the attribute.

The Model Integration Concept declares translations between the abstract syntax elements of models and code, and their respective language elements. The translations must preserve the semantics of the translated elements. When an execution runtime exists that interprets the annotation of the type declaration to create a component instance, then the semantics of the model element is declared in the execution runtime. The runtime could e.g. manage a life cycle for the component instance, and announce its existence in a component instance registry.

These semantics must be reflected in the modelling language element that represents this code element.

An execution runtime could also call methods within the declared type to execute behaviour.

The behaviour is not part of the meta model presented in Figure 5.2. It could be subject to another modelling language, that is also integrated in the type declaration, or not be modelled at all, in which case it would be considered an implementation detail in the context of the Model Integration Concept. Therefore the body of the type declaration is called an entry point for further details of the program.

5.3 Overview of the Parts of the Model Integration Concept

Figure 5.3 gives an overview of the elements in the Model Integration Concept and their interrelationships. The Model Integration Concept consists of the following elements.

• Modelling Language Meta Models and Models: Modelling language meta models define the abstract syntax of a modelling language. Models are instances of these meta models.

In Figure 5.3 the modelling languages meta models and models are shown on the left hand side.

• Programming Language Meta Models and Program Code: Programming language meta models in the context of the Model Integration Concept define the abstract syntax of a programming language. Program code is an in an instance of such a meta model. In Figure 5.3 programming language meta models and program code are shown on the right hand side.

• Modelling Language Meta Model Code Structures: Modelling language meta model code structures are parts of a program, that are defined to represent meta model elements of modelling languages. These code structures are part of the program code in Figure 5.3.

5 Model Integration Concept

Figure 5.3: An overview of the elements in the Model Integration Concept and their interre-lationships. Well-defined program code structures represent meta model elements and model elements of modelling languages. Entry points within the code structures can be used to enter arbitrary other code.

• Modelling Language Model Code Structures: Modelling language model code structures are parts of a program, that are defined to represent model elements of modelling lan-guages. These code structures may link other code structures, which represent meta model elements of modelling languages, to define that a code structure represent an in-stance of the corresponding meta model element. These code structures are part of the program code in Figure 5.3.

• Implementation Details: Every program code, that does not represent a model element or a meta model element, is considered an implementation detail. Implementation details are not subject to translation in the approach presented in this thesis. Implementation details are part of the program code in Figure 5.3.

• Entry Points: Some parts of the code structures are fixed, so that the model-code mapping is well-defined. Other parts of the structures are explicitly declared to be flexible, so that a relationship to the rest of a program can be created. Entry points are these flexible places within modelling language model code structures, that can include implementation details. Entry points are part of the modelling language model code structures in Figure 5.3.

• Notations: Notations describe how a modelling language meta model element (meta model notations) or model element (model notations) are represented using program code structures written in a specific programming language. They describe an equivalence relation between meta model or model elements and program code structures. Notation are shown in Figure 5.3 as bidirectional edges with the label represents between the

5.3 Overview of the Parts of the Model Integration Concept

modelling language meta model and the modelling language meta model code structures, and between the modelling language model and the modelling language model code structures.

• Integration Mechanisms: Integration mechanisms are a generalisation of notations. Inte-gration mechanisms define a translation between placeholders of meta model elements or model elements and program code elements and can therefore be used as templates for building specific notations between languages. Integration mechanisms are not shown in Figure 5.3.

The following sections describe these elements and their interrelationships in more details, before they are defined in Section 5.4.

5.3.1 Modelling Language Meta Models

The abstract syntax of modelling languages in the context of the Model Integration Concept is described with meta models. These meta models define classes, attributes, and references.

Classes own attributes and references. Attributes are typed. References define the allowed relationships between instances of classes. References target classes and have a cardinality. A subset of references are containment references, meaning that the reference’s source owns the reference’s target. Classes, attributes, and references are named. Figure 5.4 shows an example of a graphical notation2 of a simple meta model with classes, attributes, and references. The nodes are classes with their name at the top and a list of attributes below. Attributes are notated with their name and their type. References are represented as edges between the nodes. Their name and cardinality is attached as label. Containment references have a black diamond at their source class. All references have an arrow head at their target class.

Figure 5.4: A graphical notation of a simple meta model

5.3.2 Modelling Language Models

Models are instances of meta models. They comprise objects, assign values to attributes and assign targets to references of objects. Figure 5.5 shows an example of a graphical notation of a

2The graphical notation for meta models used in this thesis is closely related to the one used by the EcoreTools (https://www.eclipse.org/ecoretools/overview.html) for Ecore meta models

5 Model Integration Concept

simple model3. The model is an instance of the meta model in Figure 5.4. The nodes are object with the name of their class after a colon at the top, and a list of value assignments to attributes below. Attribute assignments show the name of the attribute of the class, an equality sign and the assigned value. The targets of references are represented as edges between the objects.

Containment references have a black diamond at the source. Other references have an arrow head at the target. When a model is the instance of a meta model, it must be conform to the constraints regarding the classes, attributes, and references available, their typing, cardinalities, and naming, expressed by the meta model.

Figure 5.5: A graphical notation of a simple model. The model is an instance of the meta model shown in Figure 5.4.

5.3.3 Programming Language Meta Models

Programming languages in the context of the Model Integration Concept are defined like modelling languages, but with a specific set of abstract syntax elements and their interrelations in the meta model. Figure 5.6 shows an excerpt of the required abstract syntax. The excerpt defines the class Type which corresponds to an object-oriented type declaration. A type is named. An Annotation corresponds to annotations in Java. They are typed meta data declarations, that can be attached to other program code elements. Annotations are named, and can have Annotation Parameters. Annotation parameters are named and typed properties of annotations. When annotations are attached to an element, this can be represented using the class AttachedAnnotation. An attached annotation has an annotation as type and a list of Attached Annotation Parameters which correspond to the parameters of the attached annotation. The attached annotations parameters may have values corresponding to the types of their respective parameters4.

The Model Integration Concept does not provide a thorough definition of a specific program-ming language, but describes abstract concepts, which need to be available in a programprogram-ming language to be applicable in this context. A programming language is usable with the Model Integration Concept, when the necessary abstract syntax elements are mappable to abstract

5.3 Overview of the Parts of the Model Integration Concept

Figure 5.6: An excerpt of elements in the meta model of programming languages in the Model Integration Concept

syntax elements of the programming language.

5.3.4 Program Code

Programs are descriptions of structures and behaviour. They are typically notated with a textual syntax of a programming language. In the context of the Model Integration Con-cept, programs are models that instantiate programming language meta models. Figure 5.7 shows a very simple instance of the programming language meta model described above. List-ing 5.1 shows this program in the Java programmList-ing language. It first declares the annotation ComponentType with a parameter version, a String. It then declares a type with the name BarcodeScanner, with the annotation ComponentType attached to it. The attachment assigns the value 1.0 to the parameter. In the context of this thesis, only descriptions of structures are considered. Imperative behaviour descriptions in program code, such as the content of operation bodies, are not within the scope of this thesis.

Figure 5.7: An example of a simple program

3The graphical notation for models in this thesis is the one used by the HenshinTGG Editor (http://

de-tu-berlin-tfs.github.io/Henshin-Editor/)

4In the definition of programming languages in Section 5.4.4, attached annotation parameters can actually take multiple values for handling arrays. In this example, only single values are allowed.

5 Model Integration Concept

p u b l i c @ i n t e r f a c e C o m p o n e n t T y p e { 1

S t r i n g v e r s i o n () ; 2

} 3

4

@ C o m p o n e n t T y p e ( v e r s i o n = " 1.0 " ) 5

p u b l i c c l a s s B a c o d e S c a n n e r { } 6

Listing 5.1: The simple program of Figure 5.7 written in Java

5.3.5 Modelling Language Meta Model Code Structures

Modelling language meta model code structures are parts of program code, that represent meta model elements in the Model Integration Concept. Figure 5.8 shows an excerpt of the example of Figure 5.2. On the left side, it shows the class ComponentType, with its two attributes name and version, both of the type String. On the right side, the figure shows the code structure, that represents this meta model element in Java: an annotation declaration ComponentType with an annotation parameter version of the type String. The name attribute has no direct representation in the code structure.

Modeling Language Meta Model Program Code in Java

Meta Model Level

public @interface ComponentType { String version();

}

Figure 5.8: The meta model code structure (right hand side) extracted from the example of Figure 5.2

5.3.6 Modelling Language Model Code Structures

Modelling language model code structures are parts of program code, that represent model elements in the Model Integration Concept. Figure 5.9 shows an excerpt of the example of Figure 5.2. On the left side, it shows an object of the class ComponentType, which is shown in Figure 5.8. Its name attribute value is set to BarcodeScanner. Its version attribute value is set to 1.0. On the right side, the figure shows the code structure, that represents this model element in Java: The type declaration BarcodeScanner represents the object. The annotation ComponentType is attached to the type, thus indicating, that the declared type represents an object of the class ComponentType. The name attribute’s value corresponds to the declared type name. The version attribute’s value is declared in the attached annotation parameter.

5.3.7 Notations

Notations define an equivalence relation between model elements and program code structures.

There are two types of notations: Meta model notations define equivalence relationships

be-5.3 Overview of the Parts of the Model Integration Concept

Modeling Language Model Program Code in Java

Model Level

@ComponentType(version="1.0") public class BarcodeScanner { }

Figure 5.9: The model code structure (right hand side) extracted from the example of Figure 5.2

tween meta model elements and program code structures. Model notations define equivalence relationships between model elements and program code structures.

Figure 5.10 shows the meta model notation for the example meta model element and program code structure given in Figure 5.8. The attribute name is not declared in the meta model notation. This attribute is subject to the model notation.

Modeling Language Meta Model Program Code in Java

Meta Model Level

public @interface ComponentType { String version();

}

Figure 5.10: The meta model notation highlighted in the example of Figure 5.2

Figure 5.11 shows the model notation for the example model element and program code structure given in Figure 5.9.

Modeling Language Model Program Code in Java

Model Level

@ComponentType(version="1.0") public class BarcodeScanner { } Entry Point

Figure 5.11: The model notation highlighted in the example of Figure 5.2

5 Model Integration Concept 5.3.8 Entry Points

Entry points are parts of modelling language model code structures, that can include arbitrary other program code. Notations declare entry points in their program code structures. In Figure 5.11 the type declaration is considered the entry point in the code structure, indicated by the dashed box in the type’s body. The entry point means that the type can be extended with arbitrary other code, e.g. further annotations, interface implementations, member attributes, or operations.

5.3.9 Integration Mechanisms

Integration mechanisms are templates for meta model notations and model notations. Instead of describing notations for specific meta model or model elements such as those described infor-mally in the Figures 5.10 and 5.11, integration mechanisms describe notations for placeholder elements of meta models or models respectively. Several integration mechanisms are described in Section 5.6 for representing classes, attributes, containment references, or non-containment references.

This section gave an overview of the elements in the Model Integration Concept. In the next section, the elements will be described in detail.