-
Notifications
You must be signed in to change notification settings - Fork 0
3. Generator
The Generator in the package eme.generator
consists out of different generator classes:
-
EcoreMetamodelGenerator
is the main generator class, it manages the whole generation process and handles the other generator classes. To create an Ecore metamodel, use this class exclusivly, it manages the calls to all other generators. Creating a metamodle can be achieved with the methodgenerateMetamodelFrom()
. The main generator class also manages the saving strategy. Initially the saving strategy is set according to the properties class, but it can be changed during the runtime with the method callchangeSavingStrategy()
. A metamodel is saved (if previously generated) with the methodsaveMetamodel()
-
EObjectGenerator
is the the class that actually generates the metamodel components (Ecore objects) from the intermediate model. The functionality of the class is tied to its instance of a intermediate model. Creating metamodel components with this class without previously setting the intermediate model with the methodprepareFor()
is not recommended because it can lead to unwanted behavior. Between the creation of components for two different models, the class is cleared with theprepareFor()
method call. The class offers methods for the creation of anEClass
and anEPackage
. In both methods the Ecore objects for all the contained elements (subpackages, classes, methods etc.) are automatically created. That means those methods should be called for root elements. The creation process ist divided in two steps to avoid problems with cyclic data type references. Thats why it is important to callcompleteGeneration()
after the desired packages and classes are generated. Only then it can be guarenteed that the classes are complete and all the methods and attributes are generated. The recommended workflow is: 1. callprepareFor()
, 2. callgenerateEPackage()
on model root, 3. callcompleteGeneration()
-
EDataTypeGenerator
is used by the classEObjectGenerator
to manage data types. The class basically maps data type names to the data types. It also creates and stores new data types. It offers the methodsgenerateFrom()
andaddGenericArguments()
.generateFrom()
creates anEClassifier
from anExtractedDataType
. There are three possibilities what thatEClassifier
can be in that context:- The
EClassifier
is an already created classifier (class, interface or enumeration). - The
EClassifier
is an basicEDataType
which has an Ecore äquivalent (e.g.int
,java.lang.Integer
orjava.lang.Object
). - The
EClassifier
is an external data type without an Ecore äquivalent and is created and stored as newEDataType
which is contained in the root package.
The method
addGenericArguments()
adds all generic arguments with their own generic arguments from anExtractedDataType
to anEGenericType
. This method is seperated from the previous method, because generic type arguments are added to theEGenericType
instead of theEType
of anETypedElement
. To use theEDataTypeGenerator
one has to set the root package of the metamodel with the methodsetRoot()
. Between the use for two different metamodels theEDataTypeGenerator
should be reseted with the methodreset()
. - The
-
SelectionHelper
contains the check methods. These methods check for a specific model element whether it may be generated. This depends on whether the element is selected or not and whether the properties allow the generation of such elements. Whenever a element may must not be generated, theSelectionHelper
stores that information. The methodgenerateReport()
then allows to produce a report about what kind of elements were not generated and how many of them were not generated. The report distuingishes between Packages, Interfaces, Classes, Enumerations, Constructos, Methods and Attributes. -
EMFProjectGenerator
can be used by saving strategies to create an empty EMF project in for the Eclipse IDE. -
The subpackage
eme.generator.saving
is explained in the next chapter.