-
Notifications
You must be signed in to change notification settings - Fork 0
/
operPerish.mtl
62 lines (56 loc) · 1.83 KB
/
operPerish.mtl
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
[comment encoding = UTF-8 /]
[module operPerish('http://www.eclipse.org/uml2/5.0.0/UML')]
[import dsl3s::mdd3s::templates::services/]
[comment
Date: 21-07-2012 Author: Luís de Sousa
Generates the Perish function to be included in the Animat class.
Instead of filtering for the Perish stereotype, this module starts with
the Animat stereotype, so that it only generates the code for a specific
class of that type.
/]
[template public operPerish(c : Class) ? (c.hasStereotype('Animat'))]
[comment Get Simulation name /]
[for (assS:Association | c.getAssociations())]
[for (e:Element | assS.relatedElement) ]
[let sim: Class = e.oclAsType(Class)]
[if (sim.isNotNull())]
[if (sim.hasStereotype('Simulation'))]
protected void perish([sim.name/] sim)
{
[/if]
[/if]
[/let]
[/for]
[/for]
[comment Iterate through linked Attributes /]
[for (ass:Association | c.getAssociations())]
[comment Association: [ass.name/]
[for (s:Element | ass.relatedElement) ]
[let sClass: Class = s.oclAsType(Class)]
[if (sClass.hasStereotype('Attribute'))]
[comment Iterate through linked Perish /]
[for (assP:Association | sClass.getAssociations())]
[for (p:Element | assP.relatedElement) ]
[let pClass : Class = p.oclAsType(Class)]
[if (pClass.isNotNull())]
[if (pClass.hasStereotype('Perish'))]
[if pClass.getTaggedValue(pClass, 'Perish', 'upperThreshold').isNotNull()]
if(attribute[sClass.name/].getValue() >= upperThresh[pClass.name/])
sim.addTo[c.name/]Garbage(this);
[/if]
[if pClass.getTaggedValue(pClass, 'Perish', 'lowerThreshold').isNotNull()]
if(attribute[sClass.name/].getValue() <= lowerThresh[pClass.name/])
sim.addTo[c.name/]Garbage(this);
[/if]
[/if]
[/if]
[/let]
[/for]
[/for]
[/if]
[comment [/if /]
[/let]
[/for]
[/for]
}
[/template]