1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*******************************************************************************
* Copyright (c) 2012 protos software gmbh (http://www.protos.de).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
* Juergen Haug
*
*******************************************************************************/
import ecore;
import xtext;
process(xtext::GeneratedMetamodel this) :
process(ePackage)
;
process(ecore::EPackage this) :
this.eClassifiers.typeSelect(ecore::EClass).process()
;
process(EClass this) :
switch(name){
case("ConfigModel"):
(addOperation(
"getActorClassConfigs",
ePackage.getEClassifier("ActorClassConfig"),
-1,
'EList<ActorClassConfig> list = new org.eclipse.emf.common.util.BasicEList<ActorClassConfig>();
for(ConfigElement element : this.getConfigElements())
if(element instanceof ActorClassConfig)
list.add((ActorClassConfig) element);
return list;'
)->addOperation(
"getActorInstanceConfigs",
ePackage.getEClassifier("ActorInstanceConfig"),
-1,
'EList<ActorInstanceConfig> list = new org.eclipse.emf.common.util.BasicEList<ActorInstanceConfig>();
for(ConfigElement element : this.getConfigElements())
if(element instanceof ActorInstanceConfig)
list.add((ActorInstanceConfig) element);
return list;'
))
default: null
}
;
create ecore::EOperation addOperation(ecore::EClassifier c, String strName, ecore::EClassifier type, Integer upperBound, String strBody):
setName(strName) ->
setEType(type) ->
setUpperBound(upperBound)->
addBodyAnnotation(strBody)->
((ecore::EClass)c).eOperations.add(this);
create ecore::EAnnotation addBodyAnnotation(ecore::EOperation op, String strBody):
setSource("http://www.eclipse.org/emf/2002/GenModel") ->
this.createBody(strBody) ->
op.eAnnotations.add(this);
create ecore::EStringToStringMapEntry createBody(ecore::EAnnotation anno, String strBody):
setKey("body") ->
setValue(strBody) ->
anno.details.add(this);
|