| authors : | Arnaud Thimel |
|---|---|
| Florian Desbois | |
| Jean Couteau | |
| contact : | eugene-devel@list.nuiton.org or eugene-users@list.nuiton.org |
| revision : | 1079 |
| date : | 2011-06-28 11:15:23 +0200 (Tue, 28 Jun 2011) |
This document does not take into account modifications made on EUGene 2.0 version
TODO : revoir cette documentation
ObjectModelGenerator generator is aimed to read and analyse object models and generate code from them. In UML, an object model is represented by a class diagram. This object models vision being wildly spread, it is ObjectModelGenerator's basis (please note that this is not mandatory).
Let start from the principle that we got a model (class diagram) created from an XMI (XML Metadata Interchange format modeling tool.
Code generation is made into three steps :
XMI purification into an XML code that keeps only useful information ;
Simplified model put into memory ;
Templates used / code generation.
Most of the modelign tools describe their models using XMI, but XMI is too verbose to be easily understood.
Eugene uses XSLT transformation allowing to get a purified XML describing the model and keeping the main information.
This intermediate model insure EUGene's stability and durability as it is always based on its own models and not external models (XMI) that changes too much from a version to another.
If we want to support a new XMI version, for example, we just need to create the appropriate transformation stylesheet.
Amongst the extracted information, we can name :
Objects (classes, abstract classes, interfaces)
Attributes (names, type, visibility, ...)
Relations between classes (all multiplicities, navigability, association classes, ...)
Operations (name, return type, arguments name and type, thrown exceptions, ...)
Stereotypes
From the following diagram :

We got the following ObjectModel :

Once XMI has been changed into an understandable XML, the model is loaded into memory so that it is generated.
The instanciated model is based on the following class diagram (meta-model) :

Available interfaces for the generators are the following :

ObjectModelGenerator :

Each template is itself a generator inheriting from ObjectModelGenerator. All the parts of this generator can be overloaded allowing a strong personalisation of the generators. ObjectModelGenerator's aim is to navigate through the model and on each key element of the model (model, classes, interfaces, classifier, ...) call the appropriate methods. By default, the methods described in the generator are empty, so no code is generated. The templates are aimed to overload those methods and describe the code that will be generated.
The templates can be of all kind because they can generate a different file by model, by interface, by class or even by classifier (common stub to classes and interfaces). Moreover, they can generate every kind of code what so ever : Java, XML, text, C++, ...