Tutorial | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Downloads


QVT Tutorial - 2

A metamodel is a model of a model. In our case, the metamodel of the machine simply is a model of the automaton (remember, the automaton itself is a model of a machine).
There are many ways to model the automaton, I created two different versions, metamodel MMA and metamodel MMB. The purpose of this tutorial is to transform MMA to MMB.


MMA. The root class is "Project", and has a Title. A project can contain multiple Automata. Each Automaton has a Name and contains at least one Location. Each Location has a Name as well, and a boolean attribute IsInitial (whether the location is the initial state or not).
The Edges are contained within the Locations. A Location can have multiple outgoingEdges, but an Edge can only have one targetLocation (it is just a line). Furthermore, a Location might contain an Update. An Update can be Urgent, and can contain multiple Variables. The Variable class has attributes Name and Type.
Finally, the classes Rectangle, Ellipse and Triangle inherit all properties and containments from Location. Again, this is not really functional, but it serves well for demonstrating some QVT functions later on.


Ok, I hope you are still with me. Lets define MMB:


MMB. The root class is now called "Model". It has a Name. A model can contain multiple Automata. Each Automaton has a Name, and at least one Mode. Additionally, the Automaton can have multiple Edges (they are now contained within the Automaton). Therefore, an Edge has references to a sourceMode and a targetMode.
The Mode class has a name and a boolean attribute InitialState. Furthermore it has the attributes Shape and Dimension: whether it is a Rectangle, Ellipse or Triangle, and their Dimension (Edge, Radius or Side).
Finally, a Mode can contain Modifications. Each Modification has a VarName and a VarType. In this metamodel I decided to leave out the Urgent attribute.


Please take a moment to convince yourself that both metamodels are models of the same type of automaton (except for the Urgent property. This is to demonstrate that you don't have to transform everything from a metamodel).

I recommend that you print both metamodels, because you will need them further on in the tutorial. Continue...