Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl22
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl14
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl29
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl26
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl12
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl15
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl40
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl19
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl24
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl11
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl15
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl30
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl79
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl18
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl21
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl35
16 files changed, 410 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl
new file mode 100644
index 00000000000..644096558af
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppDocumentation.mtl
@@ -0,0 +1,22 @@
+[module CppDocumentation('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+
+
+[template public CppElementDoc(argument : Element)]
+/**
+ * [getComments().replaceAll('\n', '\n * ')/]
+ */
+[/template]
+
+
+[template public CppOperationDoc(operation : Operation)]
+/**
+ * [getComments().replaceAll('\n', '\n * ')/]
+ * [for (ownedParameter)][CppParamDoc()/][/for]
+ */
+[/template]
+
+
+[template public CppParamDoc(parameter : Parameter)]
+@param [name/] [getComments().replaceAll('\n', '\n * ')/]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl
new file mode 100644
index 00000000000..97f7653d5c2
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppEnumerations.mtl
@@ -0,0 +1,14 @@
+[module CppEnumerations('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+
+[template public CppEnumerationDefinition(enum : Enumeration)]
+[CppElementDoc()/]
+enum [enum.name/] {
+[for (ownedLiteral)]/
+ [CppElementDoc()/]
+ [name/][if hasStereotype(CppInit)] = [getApplication(CppInit).oclAsType(CppInit).value/][/if],
+[/for]
+};
+
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl
new file mode 100644
index 00000000000..28072961454
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppPrimitiveTypes.mtl
@@ -0,0 +1,29 @@
+[module CppPrimitiveTypes('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+
+
+[comment
+ * Support two different kinds of primitive types
+ * (1) those that are native types of the programming language such as long
+ * For these, no additional definition has to be done and they should be referenced
+ * with their name only
+ * (2) those that correspond to a typedef (e.g. typedef long ErrorType). These require
+ * a typedef definition within the package and need to be referenced with their
+ * fully qualified name (e.g. MyPackage::ErrorType)
+ * (3) Sometimes the name of the type defined by a typedef does not appear at the end, e.g.
+ * when defining functionPointers such as "typedef int (*HandlerFct) (void*);"
+ * (a function with a void* argument returning int)
+ * Support this case via a specific 'typeName' constant that gets replaced by the name of the
+ * type
+ */
+/]
+[template public CppPrimitiveTypeDefinition(primitiveType : PrimitiveType)]
+[CppElementDoc()/]
+[if (hasStereotype(Typedef))]
+typedef [getApplication(Typedef).oclAsType(Typedef).definition.replaceAll('typeName', primitiveType.name)
+ /][if (not getApplication(Typedef).oclAsType(Typedef).definition.contains('typeName'))] [primitiveType.name/][/if];
+[else]
+[getStdtypes(primitiveType)/];
+[/if]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl
new file mode 100644
index 00000000000..0cb88942a45
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/CppTemplates.mtl
@@ -0,0 +1,26 @@
+[module CppTemplates('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+
+
+[query public CppTemplateBindingParameter(tps : TemplateParameterSubstitution) : String =
+if (tps.actual.oclIsKindOf(LiteralInteger)) then
+ tps.actual.oclAsType(LiteralInteger).value
+else
+ tps.actual.oclAsType(NamedElement).name
+endif
+/]
+
+[query public isTemplate(class : Classifier) : Boolean =
+ getTemplateParameters()->size() > 0
+/]
+
+
+[template public templateSignature(class : Classifier)]
+[if isTemplate()]
+template<[for (getTemplateParameters()) separator(', ')][getType()/][/for]> [/if]
+[/template]
+
+
+[template public templateSignature(operation : Operation)]
+[owner.oclAsType(Classifier).templateSignature()/]
+[/template] \ No newline at end of file
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl
new file mode 100644
index 00000000000..0b184a07bc2
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassAttributesDeclaration.mtl
@@ -0,0 +1,12 @@
+[module CppClassAttributesDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::property::CppAttributeDeclaration/]
+
+
+
+[template public CppClassAttributesDeclaration(class : Classifier, visibilityFilter : VisibilityKind)]
+[for (attribute->select(visibility = visibilityFilter))]
+
+ [CppAttributeDeclaration()/]
+[/for]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl
new file mode 100644
index 00000000000..8477e8483dc
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassFriendDeclaration.mtl
@@ -0,0 +1,15 @@
+[module CppClassFriendDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+
+
+[template public CppClassFriendDeclaration(friend : Classifier)]
+friend class [friend.qualifiedName()/];
+[/template]
+
+[template public CppClassIncludeFriendDeclaration(class : Classifier)]
+[for (getUsedClassifiers())]
+ [if hasStereotype(C_Cpp::Friend) and (not hasStereotype(C_Cpp::NoCodeGen))]
+ [CppClassFriendDeclaration()/]
+ [/if]
+[/for]
+[/template] \ No newline at end of file
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl
new file mode 100644
index 00000000000..8db26305532
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeClassDeclaration.mtl
@@ -0,0 +1,40 @@
+[module CppClassIncludeClassDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::ClassUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::clazz::CppClassIncludeDeclaration/]
+
+[comment USED??? /]
+[template public CppClassIncludeClassDeclarationTemplate(class : Class)]
+[openNS()/]
+[if hasStereotype(class, 'CppTemplate.class')]template [/if]class [class.name/];
+[closeNS()/]
+[/template]
+
+
+[template public CppOwnerPackageIncludeDeclaration(pkg : Package)]
+[comment if currentPkg is not root it is referenced here/]
+[if ((pkg <> null) and (not hasStereotype(CppRoot)))]
+/* Owner package header include */
+#include <[getFullPath()/]/Pkg_[pkg.name/].h>
+[/if]
+[/template]
+
+
+[template public CppClassAllIncludesDeclaration(class : Classifier)]
+[for (cl : Classifier | includedClassifiers())]
+ [comment Only add include if this is not for the current class and if it does not have the stereotype "CppNoCodeGen", unless
+ it has stereotype "CppExternalClass"/]
+ [if((cl <> class) and (not hasStereotype(NoCodeGen)) or hasStereotype(ExternClass))]
+ [if(oclIsKindOf(Enumeration) or oclIsKindOf(PrimitiveType))]
+ [comment Enumeration is not defined in a separate file, but in the package that owns it
+ => include the owning package (might be a duplicate input, if owning package is also the owner of current class/]
+ [if (cl.owner.oclIsKindOf(Package))]
+[cl.owner.oclAsType(Package).CppOwnerPackageIncludeDeclaration()/]
+ [/if]
+ [else]
+ [comment include file associated with the classifier/]
+[CppClassIncludeDeclaration()/]
+ [/if]
+ [/if]
+[/for]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl
new file mode 100644
index 00000000000..9634496107a
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassIncludeDeclaration.mtl
@@ -0,0 +1,19 @@
+[module CppClassIncludeDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::preferences::CppCodeGenUtils/]
+
+
+[query public includeName(ne : NamedElement) : String =
+if (hasStereotype(Template)) then
+ getApplication(Template).oclAsType(Template).declaration
+else
+ if (hasStereotype(ExternClass)) then getApplication(ExternClass).oclAsType(ExternClass).name
+ else ne.name + '.' + getHeaderSuffix()
+ endif
+endif
+/]
+
+[comment TODO: original code did not use nearest package, if stereotype CppRoot was applied/]
+[template public CppClassIncludeDeclaration(ne : NamedElement)]
+#include <[getNearestPackage().getFullPath()/]/[ne.includeName()/]>
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl
new file mode 100644
index 00000000000..22eb62b8de0
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassInheritedDeclarations.mtl
@@ -0,0 +1,24 @@
+[module CppClassInheritedDeclarations('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+
+[comment
+Return a list of relationships that are either Generalizations or InterfaceRealiazations
+and the target does not point to a classifier that has the no-code-gen Stereotype
+TODO: not sure if it makes sense NOT to declare an inheritance, since we do not generate code.
+/]
+[query public filteredRelationships(class : Classifier) : Set(DirectedRelationship) =
+ getSourceDirectedRelationships()->select(
+ (oclIsKindOf(Generalization) or oclIsKindOf(InterfaceRealization)) and
+ (not target->asSequence()->first().hasStereotype(NoCodeGen))
+ )
+/]
+
+[query public getCppVisibility(relationship : Relationship) : String =
+if (hasStereotype(Visibility)) then getApplication(Visibility).oclAsType(Visibility).value else 'public' endif
+/]
+
+[template public CppClassInheritedDeclarations(class : Classifier)]
+[if (filteredRelationships()->size() > 0)] : [/if]
+[for (filteredRelationships()) separator(', \n')]
+ [getCppVisibility()/] [target->asSequence()->first().oclAsType(Classifier).qualifiedName()/][/for]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl
new file mode 100644
index 00000000000..e15580adddf
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsDeclaration.mtl
@@ -0,0 +1,11 @@
+[module CppClassOperationsDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppOperationDeclaration/]
+
+
+[template public CppClassOperationsDeclaration(class : Classifier, visibilityFilter : VisibilityKind)]
+[for (getOperations()->select(visibility = visibilityFilter))]
+
+ [CppOperationDeclaration()/]
+[/for]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl
new file mode 100644
index 00000000000..aeaf01f3fe6
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassOperationsImplementation.mtl
@@ -0,0 +1,15 @@
+[module CppClassOperationsImplementation('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppOperationDeclaration/]
+
+
+[comment implementations of a classifier, parameter controls whether only inline (or only not inline) operations
+ are produced/]
+[template public CppClassOperationsImplementation(class : Classifier, inline : Boolean)]
+[for (getOperations()->select(
+ (not (hasStereotype(NoCodeGen) or isAbstract)) and
+ (hasStereotype(C_Cpp::Inline) = inline)))]
+
+[CppOperationImplementation()/]
+[/for]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl
new file mode 100644
index 00000000000..50f2a7c4928
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/clazz/CppClassTypeAndEnum.mtl
@@ -0,0 +1,30 @@
+[module CppClassTypeAndEnum('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppPrimitiveTypes/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppEnumerations/]
+
+[template public TypeAndEnumForVisibility(element : Element, visibilityFilter : VisibilityKind)]
+[if (not hasStereotype(NoCodeGen) and oclIsKindOf(Classifier) and oclAsType(Classifier).visibility = visibilityFilter)]
+[ if (oclIsKindOf(Enumeration))][oclAsType(Enumeration).CppEnumerationDefinition()/][/if]
+[ if (oclIsKindOf(PrimitiveType))][oclAsType(PrimitiveType).CppPrimitiveTypeDefinition()/][/if]
+[/if]
+[/template]
+
+[template public TypesAndEnumsForVisibility(ne : Namespace, visibilityFilter : VisibilityKind)]
+[for (ownedElement)][TypeAndEnumForVisibility(visibilityFilter)/][/for]
+[/template]
+
+[template public CppClassTypeAndEnum(class : Classifier)]
+ public:
+ [TypesAndEnumsForVisibility(VisibilityKind::public)/]
+ protected:
+ [TypesAndEnumsForVisibility(VisibilityKind::protected)/]
+ private:
+ [TypesAndEnumsForVisibility(VisibilityKind::private)/]
+[/template]
+
+
+[template public CppClassTypeAndEnumPackage(pkg : Package)]
+[TypesAndEnumsForVisibility(VisibilityKind::_package)/]
+[TypesAndEnumsForVisibility(VisibilityKind::public)/]
+[/template] \ No newline at end of file
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl
new file mode 100644
index 00000000000..f37e2687c9d
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppOperationDeclaration.mtl
@@ -0,0 +1,79 @@
+[module CppOperationDeclaration('http://www.eclipse.org/uml2/4.0.0/UML', 'http://papyrus/C_CppProfile/1', 'http://www.eclipse.org/uml2/4.0.0/UML/Profile/L2')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::operation::CppParameter/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppTemplates/]
+
+
+[template public virtualTxt(operation : Operation)]
+[if((operation.interface <> null) or (operation.isAbstract) or (operation.hasStereotype(Virtual)))]virtual [/if]
+[/template]
+
+
+[template public virtualSuffix(operation : Operation)]
+[if((operation.interface <> null) or (operation.isAbstract))] = 0[/if]
+[/template]
+
+
+[query public ConsDestructorOrVoid(operation : Operation) : String =
+if (hasStereotype(l2::Create)) then
+ ''
+else
+ if (hasStereotype(l2::Destroy)) then
+ '~'
+ else
+ 'void '
+ endif
+endif
+/]
+
+
+[template public CppReturnSpec(operation : Operation)]
+[modConst()/][if (type = null)][ConsDestructorOrVoid()/][else][type.qualifiedName()/] [/if][returnResult().modPtr()/][returnResult().modRef()/]
+[/template]
+
+
+[template public CppConstOp(operation : Operation)]
+[if (hasStereotype(operation, 'Const'))] const[/if]
+[/template]
+
+
+[template public InlineTxt(element : Element)]
+[if (hasStereotype(Inline))]inline [/if]
+[/template]
+
+
+[template public staticTxt(operation : Operation)]
+[if (isStatic)]static [/if]
+[/template]
+
+[template public CppOperationDeclaration(operation : Operation)]
+[CppOperationDoc()/]
+[InlineTxt()/][virtualTxt()/][staticTxt()/][CppReturnSpec()/] [operation.name/]([CppOperationParameters()/])[CppConstOp()/][virtualSuffix()/];
+[/template]
+
+
+[template public CppConstInit(operation : Operation)]
+[if (hasStereotype(ConstInit) and hasStereotype(l2::Create))] : [getApplication(ConstInit).oclAsType(ConstInit).initialisation/][/if]
+[/template]
+
+
+[comment wrapper for native query (otherwise Acceleo does not indent properly)/]
+[template public getBodyInTemplate(operation : Operation, language : String)]
+[getBody(language).trim()/]
+[/template]
+
+
+[template public CppOperationImplementation(operation : Operation)]
+[CppOperationDoc()/]
+[if (operation.name = 'main')]
+[CppReturnSpec()/][operation.name/]([CppOperationParameters()/]) {
+ [getBody('C/C++')/]
+}
+[else]
+[templateSignature()/][InlineTxt()/][CppReturnSpec()/][operation.class.name/]::[operation.name/]([CppOperationParameters()/])[CppConstOp()/][CppConstInit()/] {
+ [getBodyInTemplate('C/C++')/]
+}
+[/if]
+[/template]
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl
new file mode 100644
index 00000000000..5b5e08e92ca
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/operation/CppParameter.mtl
@@ -0,0 +1,18 @@
+[module CppParameter('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
+
+
+
+[template public defaultValue(parameter : Parameter)]
+[if (hasStereotype(C_Cpp::Default))] = [getApplication(C_Cpp::Default).oclAsType(C_Cpp::Default).value/][/if]
+[/template]
+
+[template public CppParameter(parameter : Parameter)]
+[modConst()/][parameter.type.qualifiedName()/][modPtr()/][modRef()/] [parameter.name/][modArray()/][defaultValue()/]
+[/template]
+
+
+[template public CppOperationParameters(operation : Operation)]
+[for (ownedParameter->select(direction <> ParameterDirectionKind::return)) separator(', ')][CppParameter()/][/for]
+[/template] \ No newline at end of file
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl
new file mode 100644
index 00000000000..9a22ee68143
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeDeclaration.mtl
@@ -0,0 +1,21 @@
+[module CppAttributeDeclaration('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+
+
+
+
+[template public defaultValue(attribute : Property)]
+[if (defaultValue <> null) and isStatic] = [attribute.defaultValue.stringValue()/][/if]
+[/template]
+
+[template public staticValue(attribute : Property)]
+[if (attribute.isStatic)]static [/if]
+[/template]
+
+[template public CppAttributeDeclaration(attribute : Property)]
+[CppElementDoc()/]
+[staticValue()/][modConst()/][attribute.type.qualifiedName()/][modPtr()/][modRef()/] [attribute.name/][modArray()/][defaultValue()/];
+[/template]
+
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl
new file mode 100644
index 00000000000..57aae8be4d8
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/acceleo/util/property/CppAttributeImplementation.mtl
@@ -0,0 +1,35 @@
+[module CppAttributeImplementation('http://www.eclipse.org/uml2/4.0.0/UML')/]
+[import org::eclipse::papyrus::cpp::codegen::utils::GenUtils/]
+[import org::eclipse::papyrus::cpp::codegen::utils::Modifier/]
+[import org::eclipse::papyrus::cpp::codegen::acceleo::util::CppDocumentation/]
+
+
+[comment
+// for static implementation:
+// If attribute is aggregation then generate a pointer
+ if (GenUtils.isAggregation(currentAttribute)) {
+ // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab
+ isAgg = "*"; // this produce a tab of pointers
+ }
+/]
+
+[template public CppAttributeImplementation(attribute : Property)]
+ [CppElementDoc()/]
+ [modConst()/][attribute.type.qualifiedName()/][modPtr()/][modRef()/] [attribute.name/][modArray()/];
+[/template]
+
+[template public CppStaticAttributeImplementation(attribute : Property)]
+ [CppElementDoc()/]
+ [type.qualifiedName()/][modPtr()/][modRef()/][attribute.class.name/]::[attribute.name/][modArray()/];
+[/template]
+
+[comment
+Loop over attributes. Check that the attribute is not a static const.
+Constant static attributes are declared within the class declaration/]
+[template public CppStaticAttributes(classifier : Classifier)]
+[for (classifier.attribute)]
+ [if(isStatic and (not hasStereotype(C_Cpp::Const)))]
+ [CppStaticAttributeImplementation()/]
+ [/if]
+[/for]
+[/template]

Back to the top