summaryrefslogtreecommitdiffstats
path: root/scripts/templates/common.tmpl
blob: 442825eec779ecb824617062e430b0332a8a12bc (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
[% USE xmi = XML.XPath("$xmi") -%]
[% SET class = xmi.findnodes("//packagedElement[@xmi:type='uml:Class' and @name='$className']") -%]
[% SET uml2qt_type = {
      "Boolean" = "bool",
      "Integer" = "int",
      "UnlimitedNatural" = "int",
      "String" = "QString",
      "Real" = "double"
   };
-%]
[%- MACRO QT_TYPE(namespace, attribute, external) BLOCK -%]
    [%- SET multiplicity = attribute.findnodes("upperValue").findvalue("@value") -%]
    [%- SET isUnique = attribute.findvalue("@isUnique") -%]
    [%- SET isOrdered = attribute.findvalue("@isOrdered") -%]
    [%- IF multiplicity == "*" %][% IF (isUnique == "true" || isUnique == "") && (isOrdered == "false" || isOrdered == "") %]QSet[% ELSE %]QList[% END %]<[% END -%]
    [%- attributeType = attribute.findvalue("@type") -%]
    [%- IF attributeType != "" -%]
    [%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$attributeType']").findvalue("@name") != "" -%]
Qt${namespace}::${attributeType} 
    [%- ELSE -%]
[% IF external == "false" %]QObject *[% ELSE %]Q${namespace}${attributeType} *[% END %]
    [%- END -%]
    [%- ELSE -%]
${uml2qt_type.item(attribute.findnodes("type").findvalue("@href").split("#").last)}[%- IF multiplicity != "*" %] [% END -%]
    [%- END -%]
    [%- IF multiplicity == "*" %]> [% END -%]
[%- END -%]
[% SET uml2qt_attribute = {
      "namespace" = "namespace_",
      "interface" = "interface_",
      "class" = "class_",
      "default" = "default_",
      "template" = "template_",
      "slot" = "slot_",
      "delete" = "delete_"
   };
-%]
[%- MACRO QT_ATTRIBUTE(attribute) BLOCK -%]
[%- SET attributeName = attribute.findvalue("@name") -%]
[%- IF uml2qt_attribute.item(attributeName) != "" -%]
${uml2qt_attribute.item(attributeName)}
[%- ELSE -%]
${attributeName}
[%- END -%]
[%- END -%]
[%- MACRO POPULATE_REDEFINED_PROPERTIES(class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- POPULATE_REDEFINED_PROPERTIES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- FOREACH attribute IN class.findnodes("ownedAttribute[@redefinedProperty]") -%]
    [%- FOREACH redefinedProperty IN attribute.findvalue("@redefinedProperty").split(' ') -%]
        [%- redefinedProperties.push("${redefinedProperty}") -%]
    [%- END -%]
[%- END -%]
[%- END -%]
[%- MACRO POPULATE_REDEFINED_OPERATIONS(class, visitedClasses, redefinedOperations) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- POPULATE_REDEFINED_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%]
    [%- END -%]
[%- END -%]
[%- FOREACH operation IN class.findnodes("ownedOperation[@redefinedOperation]") -%]
    [%- FOREACH redefinedOperation IN operation.findvalue("@redefinedOperation").split(' ') -%]
        [%- redefinedOperations.push("${redefinedOperation}") -%]
    [%- END -%]
[%- END -%]
[%- END -%]
[%- MACRO GENERATE_QPROPERTIES(class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_QPROPERTIES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[%- FOREACH attribute IN class.findnodes("ownedAttribute") -%]
    [%- SET className = class.findvalue("@name") -%]
    [%- IF found == "false" %]

    // Properties [${className}]
    [%- SET found = "true" -%]
    [%- END -%]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- SET qtType = QT_TYPE(namespace, attribute, "false") %]
    Q_PROPERTY(${qtType.trim} ${qtAttribute} READ ${qtAttribute})
[%- END %]
[%- END -%]
[%- MACRO GENERATE_ATTRIBUTES(class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_ATTRIBUTES(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- SET attributes = class.findnodes("ownedAttribute") -%]
[%- SET found = "false" -%]
[%- FOREACH attribute IN attributes -%]
    [%- SET className = class.findvalue("@name") -%]
    [%- IF found == "false" %]

    // Owned attributes [${className}]
    [%- SET found = "true" -%]
    [%- END -%]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
    [%- IF qtType.match("QList|QSet") %]
    Q_INVOKABLE const ${qtType}${qtAttribute}() const;
    [%- ELSIF qtType.match('\*$') %]
    Q_INVOKABLE ${qtType}${qtAttribute}() const;
    [%- ELSE %]
    Q_INVOKABLE ${qtType}${qtAttribute}() const;
    [%- END %]
    [%- IF loop.last %]
    [%- END %]
[%- END -%]
[%- END -%]
[%- MACRO GENERATE_OPERATIONS(class, visitedClasses, redefinedOperations) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_OPERATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[%- FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- SET className = class.findvalue("@name") -%]
[%- IF found == "false" %]

    // Operations [${className}]
[%- SET found = "true" -%]
[%- END %]
[%- SET operationName = operation.findvalue("@name") -%]
[%- NEXT IF redefinedOperations.grep("^${className}-${operationName}$").size > 0 -%]

    Q_INVOKABLE [% QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") -%]
${operationName}(
    [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
        [%- QT_TYPE(namespace, parameter, "false") -%]
${parameter.findvalue("@name")}
        [%- IF !loop.last %], [% END -%]
    [%- END -%]
)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %];
[%- END %]
[%- END -%]
[%- MACRO GENERATE_SLOTS(class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_SLOTS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[%- FOREACH attribute IN class.findnodes("ownedAttribute") -%]
[%- SET className = class.findvalue("@name") -%]
[%- IF found == "false" %]

    // Slots for owned attributes [${className}]
[%- SET found = "true" -%]
[%- END %]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) %]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
    [%- SET readOnly = attribute.findvalue("@isReadOnly") -%]
    [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
    [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
        [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*') %]${qtAttribute});
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*') %]${qtAttribute});
        [%- ELSE %]
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]add${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]remove${attributeName}(${qtType.remove("QSet<").remove("QList<").replace(">", "")}${qtAttribute});
        [%- END -%]
    [%- ELSE -%]
        [%- IF qtType.match('QList|QSet') %]
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]set${attributeName}(${qtType}${qtAttribute});
        [%- ELSIF qtType.match('\*$') %]
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]set${attributeName}(${qtType}${qtAttribute} = 0);
        [%- ELSE %]
    void [%- IF readOnly == "true" -%]Q_DECL_HIDDEN [% END %]set${attributeName.remove("^Is")}(${qtType}${qtAttribute});
            [%- END -%]
    [%- END -%]
[%- END %]
[%- END -%]
[%- MACRO GENERATE_CPP_ATTRIBUTES(originalClassName, class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_CPP_ATTRIBUTES(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
    [%- SET className = class.findvalue("@name") -%]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- IF found == "false" -%]
// OWNED ATTRIBUTES [${className}]

[%- SET found = "true" -%]
[% END -%]
    [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
    [%- SET originalQtType = QT_TYPE(namespace, attribute, "true") -%]
    [%- SET derived = attribute.findvalue("@isDerived") -%]
    [%- SET derivedUnion = attribute.findvalue("@isDerivedUnion") %]
[% IF qtType.match("QList|QSet") %]const [% END %]${qtType}Q${namespace}${originalClassName}Object::${qtAttribute}() const
{
    [%- IF qtType.match("QList|QSet") %]
    ${qtType}[% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
    foreach (Q${originalQtType.remove("QList<").remove("QSet<").remove(">").trim.remove("^Q")}element, qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${qtAttribute}())
        [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF qtType.match("QList") %]append[% ELSE %]insert[% END %](element->asQObject());
    return [% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
    [%- ELSIF qtType.match('\*$') %]
    return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${qtAttribute}()->asQObject();
    [%- ELSE %]
    return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${qtAttribute}();
    [%- END %]
}

[%- IF loop.last %]
[% END -%]
[%- END -%]
[%- END -%]
[%- MACRO GENERATE_CPP_OPERATIONS(originalClassName, class, visitedClasses, redefinedOperations) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_CPP_OPERATIONS(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedOperations) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[% FOREACH operation = class.findnodes("ownedOperation[@name != ../ownedAttribute[@isDerived='true']/@name]") -%]
[%- SET className = class.findvalue("@name") -%]
[%- IF found == "false" -%]
// OPERATIONS [${className}]

[%- SET found = "true" -%]
[% END -%]
[% SET operationName = operation.findvalue("@name") -%]
[%- NEXT IF redefinedOperations.grep("^${className}-${operationName}$").size > 0 -%]
[%- SET return = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "false") %]
[%- SET originalReturn = QT_TYPE(namespace, operation.findnodes("ownedParameter[@direction='return']"), "true") %]
[% return -%]
Q${namespace}${originalClassName}Object::${operationName}(
    [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
        [%- QT_TYPE(namespace, parameter, "false") -%]
${parameter.findvalue("@name")}
        [%- IF !loop.last %], [% END -%]
    [%- END -%]
)[% IF operation.findvalue("@isQuery") == "true" %] const[% END %]
{
    [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
        [%- IF QT_TYPE(namespace, parameter, "true").match("QList|QSet") %]
    ${QT_TYPE(namespace, parameter, "true")}${parameter.findvalue("@name")}Converted;
    foreach (QObject *object, ${parameter.findvalue("@name")})
        ${parameter.findvalue("@name")}Converted.[% IF QT_TYPE(namespace, parameter, "true").match("QList") %]append[% ELSE %]insert[% END %](qmodelingobjectproperty_cast<${QT_TYPE(namespace, parameter, "true").remove("QList<").remove("QSet<").remove(">").trim}>(object));
        [%- END -%]
    [%- END -%]
    [%- IF return.match("QList|QSet") && return.match('\*') %]
    ${return}[% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
    foreach (${originalReturn.remove("QList<").remove("QSet<").remove(">").trim}element, qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
        [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
            [%- qtType = QT_TYPE(namespace, parameter, "true") -%]
        [%- IF qtType.match('QList|QSet') -%]
${parameter.findvalue("@name")}Converted
        [%- ELSIF qtType.match('\*$') -%]
qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
        [%- ELSE -%]
${parameter.findvalue("@name")}
        [%- END -%]
            [%- IF !loop.last %], [% END -%]
        [%- END -%]))
        [% IF qtType.match("QList") %]list[% ELSE %]set[% END %].[% IF return.match("QList") %]append[% ELSE %]insert[% END %](element->asQObject());
    return [% IF qtType.match("QList") %]list[% ELSE %]set[% END %];
    [%- ELSIF !return.match("QList|QSet") && return.match('\*$') %]
    return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
        [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
        [%- qtType = QT_TYPE(namespace, parameter, "true") -%]
        [%- IF qtType.match('\*$') -%]
qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
        [%- ELSE -%]
${parameter.findvalue("@name")}
        [%- END -%]
            [%- IF !loop.last %], [% END -%]
        [%- END -%])->asQObject();
    [%- ELSE %]
    return qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->${operationName}(
        [%- FOREACH parameter = operation.findnodes("ownedParameter[@direction!='return']") -%]
            [%- qtType = QT_TYPE(namespace, parameter, "true") -%]
        [%- IF qtType.match('\*$') -%]
qmodelingobjectproperty_cast<${qtType.remove("QList<").remove("QSet<").remove(">")}>(${parameter.findvalue("@name")})
        [%- ELSE -%]
${parameter.findvalue("@name")}
        [%- END -%]
            [%- IF !loop.last %], [% END -%]
        [%- END -%]);
    [%- END %]
}

[%- IF loop.last %]
[% END -%]
[%- END -%]
[%- END -%]
[%- MACRO GENERATE_CPP_SLOTS(originalClassName, class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_CPP_SLOTS(originalClassName, xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- SET found = "false" -%]
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
    [%- SET className = class.findvalue("@name") -%]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- IF found == "false" -%]
// SLOTS FOR OWNED ATTRIBUTES [${className}]

[%- SET found = "true" -%]
[% END -%]
    [%- SET attributeName = attribute.findvalue("@name").ucfirst -%]
    [%- SET qtType = QT_TYPE(namespace, attribute, "false") -%]
    [%- SET originalQtType = QT_TYPE(namespace, attribute, "true") -%]
    [%- IF attribute.findnodes("upperValue").findvalue("@value") == "*" -%]
        [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
void Q${namespace}${originalClassName}Object::add${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*') %]${qtAttribute})
        [%- ELSE %]
void Q${namespace}${originalClassName}Object::add${attributeName}(${originalQtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
        [%- END %]
{
        [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(qmodelingobjectproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute}));
        [%- ELSE %]
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->add${attributeName}(${qtAttribute});
        [%- END %]
}

    [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
void Q${namespace}${originalClassName}Object::remove${attributeName}([% qtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*') %]${qtAttribute})
    [%- ELSE %]
void Q${namespace}${originalClassName}Object::remove${attributeName}(${originalQtType.remove("QSet<").remove("QList<").replace(">", "")} ${qtAttribute})
    [%- END %]
{
    [%- IF qtType.remove("QSet<").remove("QList<").match('\*') %]
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(qmodelingobjectproperty_cast<${originalQtType.remove("QSet<").remove("QList<").replace(">", "").replace('\* $', '*')}>(${qtAttribute}));
    [%- ELSE %]
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->remove${attributeName}(${qtAttribute});
    [%- END %]
}

    [%- ELSIF qtType.match('\*$') %]
void Q${namespace}${originalClassName}Object::set${attributeName}(${qtType}${qtAttribute})
{
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName}(qmodelingobjectproperty_cast<${originalQtType}>(${qtAttribute}));
}

    [%- ELSE %]
void Q${namespace}${originalClassName}Object::set${attributeName.remove("^Is")}(${qtType}${qtAttribute})
{
    qmodelingobjectproperty_cast<Q${namespace}${originalClassName} *>(this)->set${attributeName.remove("^Is")}(${qtAttribute});
}
    [% END -%]
[%- IF loop.last %]
[% END -%]
[%- END %]
[%- END -%]
[%- MACRO GENERATE_FWD_DECLARATIONS(class, visitedClasses, forwards, useNamespace) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_FWD_DECLARATIONS(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, forwards, useNamespace) -%]
    [%- END -%]
[%- END -%]
[%- FOREACH forward = class.findnodes("ownedAttribute[@type] | ownedOperation/ownedParameter[@type]") -%]
[%- SET forwardName = forward.findvalue('@type') -%]
[%- IF xmi.findnodes("//packagedElement[@xmi:type='uml:Enumeration' and @name='$forwardName']").findvalue("@name") != "" -%]
    [%- useNamespace.push("true") -%]
[%- ELSE -%]
[%- IF forwardName != className -%][%- forwards.push("Q${namespace}${forwardName}") -%][%- END -%]
[%- END -%]
[%- END -%]
[%- END -%]
[%- MACRO GENERATE_CLONE(class, visitedClasses, redefinedProperties) BLOCK -%]
[%- FOREACH parent IN class.findnodes("generalization") -%]
    [%- SET parentName = parent.findvalue("@general") -%]
    [%- IF visitedClasses.grep("^${parentName}$").size == 0 -%]
    [%- visitedClasses.push("${parentName}") -%]
    [%- GENERATE_CLONE(xmi.findnodes("//packagedElement[@xmi:type=\"uml:Class\" and @name=\"${parentName}\"]"), visitedClasses, redefinedProperties) -%]
    [%- END -%]
[%- END -%]
[%- FOREACH attribute = class.findnodes("ownedAttribute[@isDerived=\"false\" or not(@isDerived)]") -%]
    [%- SET qtType = QT_TYPE(namespace, attribute) -%]
    [%- SET attributeName = attribute.findvalue("@name") -%]
    [%- SET className = class.findvalue("@name") -%]
    [%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
    [%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
    [%- IF qtType.match("QList|QSet") && qtType.match('\*') %]
    foreach (${qtType.remove("QList<").remove("QSet<").remove(">").replace('\* ', '*')}element, ${attributeName}())
        c->add${attributeName.ucfirst}(dynamic_cast<${qtType.remove("QList<").remove("QSet<").remove(">").replace('\* ', '*')}>(element->clone()));
    [%- ELSIF qtType.match('\*') %]
    if (${attributeName}())
        c->set${attributeName.ucfirst}(dynamic_cast<${qtType.remove("QList<").remove("QSet<").remove(">").replace('\* ', '*')}>(${attributeName}()->clone()));
    [%- ELSE %]
    c->set${attributeName.ucfirst}(${attributeName}());
    [%- END -%]
[%- END %]
[%- END -%]