Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util')
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java124
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java105
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java89
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java59
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java71
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java52
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java72
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java88
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java71
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java130
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java63
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java68
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java63
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java134
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java97
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java113
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java113
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java71
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java84
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java69
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java142
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java171
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java64
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java62
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java118
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java158
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java82
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java76
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java111
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java90
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java102
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java63
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java69
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java75
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java68
35 files changed, 3187 insertions, 0 deletions
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java
new file mode 100644
index 00000000000..faad5c04422
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeDeclaration.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.*;
+
+public class CppAttributeDeclaration
+{
+ protected static String nl;
+ public static synchronized CppAttributeDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppAttributeDeclaration result = new CppAttributeDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = NL + "\t";
+ protected final String TEXT_2 = NL + "\t";
+ protected final String TEXT_3 = " ";
+ protected final String TEXT_4 = ";";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+ String typeName = "";
+ String prefix = "";
+ String suffix = "";
+ String multiple = "";
+
+ // For property documentation
+ String propDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+ propDoc = jDoc.generate(currentAttribute);
+ propDoc = propDoc.replaceAll(NL, NL+" ");
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined";
+ } else {
+ typeName = GenUtils.qualifiedName (currentAttribute.getType());
+ }
+
+ // Static attribute
+ if (currentAttribute.isStatic()) {
+ prefix = "static"+" ";
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+ // Treat multiplicity for association attributes
+ int multiplicity = currentAttribute.getUpper();
+ if (multiplicity == 1) {
+ multiple = "";
+ } else if (multiplicity == -1) {
+ multiple = "*";
+ } else {
+ multiple = "";
+ modifier.array = "[" + multiplicity + "]";
+ }
+
+ // If attribute is aggregation
+ if (GenUtils.isAggregation(currentAttribute)) {
+ // attributeName = "(*"+attributeName+")"; // this produce a pointer on a tab
+ attributeName = "*"+attributeName; // this produce a tab of pointers
+ }
+
+
+ if (GenUtils.hasStereotype(currentAttribute, CppConst.class) && currentAttribute.isStatic()) {
+ // const & static attributes may be initialized within class declaration
+ // check if initial value UML or profile
+ if (currentAttribute.getDefaultValue() != null) {
+ suffix = " = " + currentAttribute.getDefaultValue().stringValue();
+ }
+ else {
+ CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class);
+ if (cppDefault != null) {
+ suffix = " = " + cppDefault.getValue();
+ }
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( propDoc );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( prefix );
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( typeName );
+ stringBuffer.append( multiple );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( attributeName );
+ stringBuffer.append( modifier.array );
+ stringBuffer.append( suffix );
+ stringBuffer.append(TEXT_4);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java
new file mode 100644
index 00000000000..ab85473afbc
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppAttributeImplementation.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.*;
+
+public class CppAttributeImplementation
+{
+ protected static String nl;
+ public static synchronized CppAttributeImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppAttributeImplementation result = new CppAttributeImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "\t";
+ protected final String TEXT_2 = NL + "\t";
+ protected final String TEXT_3 = " ";
+ protected final String TEXT_4 = ";";
+ protected final String TEXT_5 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+// String className = currentAttribute.getOwner().getName();
+ String typeName = "";
+ String scopeName = "";
+// String prefix = "";
+ String suffix = "";
+ String multiple = "";
+
+ // For property documentation
+ String propDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+ propDoc = jDoc.generate(currentAttribute);
+ propDoc = propDoc.replaceAll(NL, NL+" ");
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined";
+ }
+ else {
+ Type type = currentAttribute.getType();
+ typeName = GenUtils.qualifiedName (type);
+ /*
+ // If type is owned by a class add the scope
+ if (type.getOwner() instanceof Class) {
+ scopeName = ((Class) type.getOwner()).getName();
+ typeName = scopeName+"::"+typeName;
+ }
+ */
+ }
+
+ // Multiple
+ // TODO? need to evaluate limitMultiplicity stereotype?
+ int upper = currentAttribute.getUpper();
+ if ((upper == -1) || (upper > 1)) {
+ multiple = "*";
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( propDoc );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( typeName );
+ stringBuffer.append( multiple );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( attributeName );
+ stringBuffer.append( modifier.array );
+ stringBuffer.append( suffix );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(TEXT_5);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java
new file mode 100644
index 00000000000..acc9eb087fa
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAllIncludesDeclaration.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.*;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.emf.common.util.UniqueEList;
+import java.util.*;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.Classifier;
+
+public class CppClassAllIncludesDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassAllIncludesDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassAllIncludesDeclaration result = new CppClassAllIncludesDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+
+ // Get the package name
+ // String className = currentClass.getName();
+
+ // Prepare Dependency includes declarations ...
+ // Retrieve package used by current package (dependencies)
+ // use a unique list to avoid duplicates
+ EList<Classifier> usedClasses = new UniqueEList<Classifier> ();
+
+ String newInclude = "";
+
+ // class attributes dependencies
+ usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentClass));
+ // operation parameters dependencies
+ usedClasses.addAll (GenUtils.getIncludesFromOperations(currentClass));
+ // realized interface dependencies
+ if (currentClass instanceof Class) {
+ usedClasses.addAll (GenUtils.getImplementedInterfaces((Class) currentClass));
+ }
+ // dependencies and associations
+ usedClasses.addAll (GenUtils.getRelationshipsNoDeps(currentClass));
+
+ // template parameters are declared locally (if owned) and do not correspond to a file
+ // that can be included
+ usedClasses.removeAll (GenUtils.getTemplateParameteredElements(currentClass));
+
+ Iterator<Classifier> usedClassesIt = usedClasses.iterator();
+ // Parsing all as NamedElement
+ String includes = ClassUtils.createIncludeDecl (usedClasses, currentClass);
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( includes );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java
new file mode 100644
index 00000000000..a0de92709c3
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesDeclaration.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.Iterator;
+
+public class CppClassAttributesDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassAttributesDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassAttributesDeclaration result = new CppClassAttributesDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument1, Object argument2)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument1;
+ String attrDecl = "";
+
+ // Retrieve public attributes
+ Iterator<Property> attributes = currentClass.getAttributes().iterator();
+ while (attributes.hasNext()) {
+ Property attribute = attributes.next();
+ if (attribute.getVisibility() == argument2) {
+ CppAttributeDeclaration jetAttDecl = new CppAttributeDeclaration();
+ attrDecl = attrDecl+jetAttDecl.generate(attribute);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( attrDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java
new file mode 100644
index 00000000000..4c30ed0bedd
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassAttributesImplementation.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.Iterator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppClassAttributesImplementation
+{
+ protected static String nl;
+ public static synchronized CppClassAttributesImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassAttributesImplementation result = new CppClassAttributesImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+ String attrDecl = "";
+ String attrSDecl = "";
+
+ CppAttributeImplementation jetAttDecl = new CppAttributeImplementation();
+ CppStaticAttributeImplementation jetSAttDecl = new CppStaticAttributeImplementation();
+
+ Iterator<Property> attributesIt = currentClass.getAttributes().iterator();
+ while (attributesIt.hasNext()) {
+ Property attribute = (Property) attributesIt.next();
+
+ // just check that this property is not a static const
+ // in that case it declared and defined in the header file
+
+ // Static
+ if (attribute.isStatic()) {
+ attrSDecl = attrSDecl+jetSAttDecl.generate(attribute);
+ } else {
+ attrDecl = attrDecl+jetAttDecl.generate(attribute);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( attrSDecl );
+ stringBuffer.append( attrDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java
new file mode 100644
index 00000000000..030fae595ff
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassFriendDeclaration.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.NamedElement;
+
+public class CppClassFriendDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassFriendDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassFriendDeclaration result = new CppClassFriendDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "friend class ";
+ protected final String TEXT_2 = ";";
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ NamedElement currentNE = (NamedElement) argument;
+ String cClassName = currentNE.getName();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( cClassName );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java
new file mode 100644
index 00000000000..e7fc0246e6e
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeClassDeclaration.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassIncludeClassDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassIncludeClassDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassIncludeClassDeclaration result = new CppClassIncludeClassDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL;
+ protected final String TEXT_4 = "class ";
+ protected final String TEXT_5 = ";";
+ protected final String TEXT_6 = NL;
+ protected final String TEXT_7 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ NamedElement currentNE = (NamedElement) argument;
+ String cClassName = currentNE.getName();
+ String isTemplate = "";
+ String openNS = GenUtils.openNS (currentNE);
+ String closeNS = GenUtils.closeNS (currentNE);
+
+ if (GenUtils.hasStereotype(currentNE, CppTemplate.class)) {
+ isTemplate = "template ";
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( openNS );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( isTemplate );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( cClassName );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append( closeNS );
+ stringBuffer.append(TEXT_7);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java
new file mode 100644
index 00000000000..a10b49edd59
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeDeclaration.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.papyrus.cpp.codegen.Activator;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassIncludeDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassIncludeDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassIncludeDeclaration result = new CppClassIncludeDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "#include <";
+ protected final String TEXT_2 = ">";
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ // Retrieve header file suffix
+ String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix");
+
+
+ // Retrieve the class
+ NamedElement currentNE = (NamedElement) argument;
+ String cClassPath = "";
+ Package nearestPkg = currentNE.getNearestPackage();
+ String cClassName = currentNE.getName();
+
+ if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model)
+ /*&& */!(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) {
+ cClassPath = GenUtils.getFullPath(nearestPkg)+"/";
+ }
+
+
+ // If an external class is referred
+ CppExternClass extClass = GenUtils.getApplication(currentNE, CppExternClass.class);
+ CppTemplate template = GenUtils.getApplication(currentNE, CppTemplate.class);
+ if (extClass != null) {
+ cClassPath = "";
+ cClassName = extClass.getName();
+ if ((cClassName == null) || cClassName.equals ("")) {
+ // default value
+ cClassName = currentNE.getQualifiedName ().replace ("::", "/") + "." + headerFileSuffix;
+ // strip model name
+ cClassName = cClassName.substring (currentNE.getModel ().getName ().length () + 1);
+ }
+ } else if (template != null) {
+ cClassPath = "";
+ cClassName = template.getDeclaration();
+ }
+ else cClassName=cClassName+"."+headerFileSuffix;
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( cClassPath );
+ stringBuffer.append( cClassName );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java
new file mode 100644
index 00000000000..1b37bcb57aa
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassIncludeFriendDeclaration.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassIncludeFriendDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassIncludeFriendDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassIncludeFriendDeclaration result = new CppClassIncludeFriendDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+// NamedElement currentElt = (NamedElement) argument;
+
+ // Prepare Dependency includes declarations ...
+ // Retrieve package used by current package (dependencies)
+ Iterator<Classifier> friendClassesIt = GenUtils.getUsedClassifiers(currentClass).iterator();
+
+ // Parsing all as NamedElement
+ String friendClass = "";
+
+ while (friendClassesIt.hasNext()) {
+ Classifier cClass = friendClassesIt.next();
+
+ if (GenUtils.hasStereotype(cClass, CppFriend.class) &&
+ (!GenUtils.hasStereotype(cClass, CppNoCodeGen.class))) {
+
+ CppClassFriendDeclaration jetIDecl
+ = new CppClassFriendDeclaration();
+
+ friendClass = friendClass+jetIDecl.generate(cClass);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( friendClass );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java
new file mode 100644
index 00000000000..9081b1f7aaa
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInheritedDeclarations.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassInheritedDeclarations
+{
+ protected static String nl;
+ public static synchronized CppClassInheritedDeclarations create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassInheritedDeclarations result = new CppClassInheritedDeclarations();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+ String targetName = "";
+ String visibility = "";
+ String decl = "";
+
+ // Get generalization and implementation relationships
+ Iterator<DirectedRelationship> relationshipIt =
+ currentClass.getSourceDirectedRelationships().iterator();
+ // Iterator impIt = currentClass.getImplementations().iterator();
+
+ while (relationshipIt.hasNext()) {
+
+ DirectedRelationship relationship = relationshipIt.next();
+
+ if ((relationship instanceof Generalization) ||
+ (relationship instanceof InterfaceRealization))
+ {
+ org.eclipse.uml2.uml.Classifier target = null;
+ if (relationship.getTargets ().size() > 0) {
+ // there should always be at least one element in the target
+ // list and it should be a classifier, but better check.
+ org.eclipse.uml2.uml.Element element =
+ relationship.getTargets().get(0);
+ if (element instanceof org.eclipse.uml2.uml.Classifier) {
+ target = (org.eclipse.uml2.uml.Classifier) element;
+ }
+ }
+ if (target != null) {
+ // If not <NoCodeGen>
+ if (!GenUtils.hasStereotype(target, CppNoCodeGen.class))
+ {
+ CppVisibility cppVisibility = GenUtils.getApplication(relationship, CppVisibility.class);
+ if (cppVisibility != null) {
+ visibility = cppVisibility.getValue();
+ } else {
+ visibility = "public";
+ }
+
+ targetName = GenUtils.qualifiedName (target);
+ if (!decl.equals("")) {
+ decl = decl + ", ";
+ }
+ decl = decl+visibility+" "+targetName;
+ }
+ }
+ }
+ }
+
+ // Parse implementations
+ // RS: removed code: Implementation does not exist in UML2 v2.
+ // TODO: replace Implementation with new UML2 constructions?
+// Implementation currentImp;
+//
+// while (impIt.hasNext()) {
+//
+// currentImp = (Implementation) impIt.next();
+// currentNE = (NamedElement) currentImp;
+//
+// // get visibility and target name
+// visibility = currentNE.getVisibilityAsString();
+//
+// // If not <NoCodeGen>
+// if (!GenUtils.hasStereotype(currentImp.getTarget(), CppNoCodeGen.class)) {
+//
+// targetName = currentImp.getTarget().getName();
+//
+// if (!decl.equals("")) {
+// decl = decl + ", ";
+// }
+// decl = decl+visibility+" "+targetName;
+//
+// }
+// }
+
+
+ // ":" if decl non empty
+ String prefix = "";
+ if (!decl.equals("")) {
+ prefix = " : ";
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( prefix );
+ stringBuffer.append( decl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java
new file mode 100644
index 00000000000..4ff043d4116
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassInlineOperationsImplementation.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.Iterator;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassInlineOperationsImplementation
+{
+ protected static String nl;
+ public static synchronized CppClassInlineOperationsImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassInlineOperationsImplementation result = new CppClassInlineOperationsImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+ String opDecl = "";
+
+ // Retrieve operations
+ Iterator<Operation> operations = currentClass.getOperations().iterator();
+ while (operations.hasNext()) {
+ Operation currentOp = operations.next();
+ if (GenUtils.hasStereotype (currentOp, CppInline.class) &&
+ !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class)) {
+
+ CppOperationImplementation jetOpImpl = new CppOperationImplementation();
+ opDecl = opDecl+jetOpImpl.generate(currentOp);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java
new file mode 100644
index 00000000000..1ba52bc71f5
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsDeclaration.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.Iterator;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassOperationsDeclaration
+{
+ protected static String nl;
+ public static synchronized CppClassOperationsDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassOperationsDeclaration result = new CppClassOperationsDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument1, Object argument2)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument1;
+ String opDecl = "";
+
+ // Retrieve attributes
+ Iterator<Operation> operations = currentClass.getOperations().iterator();
+ while (operations.hasNext()) {
+ Operation operation = operations.next();
+ if (!GenUtils.hasStereotype (operation, CppNoCodeGen.class)) {
+ if (operation.getVisibility() == argument2) {
+ CppOperationDeclaration jetOpDecl = new CppOperationDeclaration();
+ String cOpDecl = jetOpDecl.generate(operation);
+
+ // if main cOpDecl = "";
+ if (!cOpDecl.equals("")) {
+ opDecl = opDecl+NL+cOpDecl+";";
+ }
+ }
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java
new file mode 100644
index 00000000000..377e7f579bf
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassOperationsImplementation.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.Iterator;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppClassOperationsImplementation
+{
+ protected static String nl;
+ public static synchronized CppClassOperationsImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassOperationsImplementation result = new CppClassOperationsImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+ String opDecl = "";
+
+ // Retrieve operations
+ Iterator<Operation> operations = currentClass.getOperations().iterator();
+ while (operations.hasNext()) {
+ Operation currentOp = operations.next();
+ if (!GenUtils.hasStereotype (currentOp, CppInline.class) &&
+ !GenUtils.hasStereotype (currentOp, CppNoCodeGen.class) &&
+ !currentOp.isAbstract()) {
+ CppOperationImplementation jetOpImpl = new CppOperationImplementation();
+ opDecl = opDecl+jetOpImpl.generate(currentOp);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java
new file mode 100644
index 00000000000..db433ffb881
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnum.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import org.eclipse.uml2.uml.*;
+
+public class CppClassTypeAndEnum
+{
+ protected static String nl;
+ public static synchronized CppClassTypeAndEnum create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassTypeAndEnum result = new CppClassTypeAndEnum();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+
+ // Prepare owned type and enum declaration
+ String publicTypeDef = "";
+ String privateTypeDef = "";
+ String protectedTypeDef = "";
+ String publicEnumDef = "";
+ String privateEnumDef = "";
+ String protectedEnumDef = "";
+ String publicKeyword = "public:";
+ String protectedKeyword = "protected:";
+ String privateKeyword = "private:";
+
+ for (Element currentElt : currentClass.getOwnedElements()) {
+ if (!GenUtils.hasStereotype(currentElt, Cpp.CppNoCodeGen.class)) {
+ if (currentElt instanceof PrimitiveType) {
+
+ org.eclipse.uml2.uml.PrimitiveType currentType = (org.eclipse.uml2.uml.PrimitiveType) currentElt;
+ CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition();
+ // Execute the util template
+ if (currentType.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
+ publicTypeDef = publicTypeDef+jetPrimitiveType.generate(currentType);
+ } else if (currentType.getVisibility() == VisibilityKind.PROTECTED_LITERAL) {
+ protectedTypeDef = protectedTypeDef+jetPrimitiveType.generate(currentType);
+ } else if (currentType.getVisibility() == VisibilityKind.PRIVATE_LITERAL) {
+ privateTypeDef = privateTypeDef+jetPrimitiveType.generate(currentType);
+ }
+ }
+ else if (currentElt instanceof Enumeration) {
+
+ Enumeration currentEnum = (Enumeration) currentElt;
+ CppEnumerationDefinition jetEnum = new CppEnumerationDefinition();
+ // Execute the util template
+ if (currentEnum.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
+ publicEnumDef = publicEnumDef+jetEnum.generate(currentEnum);
+ } else if (currentEnum.getVisibility() == VisibilityKind.PROTECTED_LITERAL) {
+ protectedEnumDef = protectedEnumDef+jetEnum.generate(currentEnum);
+ } else if (currentEnum.getVisibility() == VisibilityKind.PRIVATE_LITERAL) {
+ privateEnumDef = privateEnumDef+jetEnum.generate(currentEnum);
+ }
+ }
+ }
+ }
+
+ // If not "" add a comment before declarations
+ if (publicTypeDef.equals("") && publicEnumDef.equals("")) {
+ publicKeyword = "";
+ } else {
+ if (!publicTypeDef.equals("")) {
+ publicTypeDef = "/* Public type definitions */"+NL+publicTypeDef+NL;
+ }
+ if (!publicEnumDef.equals("")) {
+ publicEnumDef = "/* Public enumeration definitions */"+NL+publicEnumDef+NL;
+ }
+ }
+
+ if (protectedTypeDef.equals("") && protectedEnumDef.equals("")) {
+ protectedKeyword = "";
+ } else {
+ if (!protectedTypeDef.equals("")) {
+ protectedTypeDef = "/* Protected type definitions */"+NL+protectedTypeDef+NL;
+ }
+ if (!protectedEnumDef.equals("")) {
+ protectedEnumDef = "/* Protected enumeration definitions */"+NL+protectedEnumDef+NL;
+ }
+ }
+
+ if (privateTypeDef.equals("") && privateEnumDef.equals("")) {
+ privateKeyword = "";
+ } else {
+ if (!privateTypeDef.equals("")) {
+ privateTypeDef = "/* Private type definitions */"+NL+privateTypeDef+NL;
+ }
+ if (!privateEnumDef.equals("")) {
+ privateEnumDef = "/* Private enumeration definitions */"+NL+privateEnumDef+NL;
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( publicKeyword );
+ stringBuffer.append( publicTypeDef );
+ stringBuffer.append( publicEnumDef );
+ stringBuffer.append( protectedKeyword );
+ stringBuffer.append( protectedTypeDef );
+ stringBuffer.append( protectedEnumDef );
+ stringBuffer.append( privateKeyword );
+ stringBuffer.append( privateTypeDef );
+ stringBuffer.append( privateEnumDef );
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java
new file mode 100644
index 00000000000..4818c9dd823
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppClassTypeAndEnumPackage.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import java.util.Iterator;
+import Cpp.*;
+
+public class CppClassTypeAndEnumPackage
+{
+ protected static String nl;
+ public static synchronized CppClassTypeAndEnumPackage create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppClassTypeAndEnumPackage result = new CppClassTypeAndEnumPackage();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Classifier currentClass = (Classifier) argument;
+
+
+ // Prepare owned type and enum declaration
+ String packageTypeDef = "";
+ String packageEnumDef = "";
+
+ Iterator<Element> typeIt = currentClass.getOwnedElements().iterator();
+ while (typeIt.hasNext()) {
+ Element currentElt = typeIt.next();
+ if (!GenUtils.hasStereotype(currentElt, CppNoCodeGen.class)) {
+ if (currentElt instanceof PrimitiveType) {
+
+ PrimitiveType currentType = (PrimitiveType) currentElt;
+ CppPrimitiveTypeDefinition jetPrimitiveType = new CppPrimitiveTypeDefinition();
+ // Execute the util template
+ if (currentType.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
+ packageTypeDef = packageTypeDef+jetPrimitiveType.generate(currentType);
+ }
+
+
+ } else if (currentElt instanceof Enumeration) {
+
+ Enumeration currentEnum = (Enumeration) currentElt;
+ CppEnumerationDefinition jetEnum = new CppEnumerationDefinition();
+ // Execute the util template
+ if (currentEnum.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
+ packageEnumDef = packageEnumDef+jetEnum.generate(currentEnum);
+ }
+
+ }
+ }
+ }
+
+ // If not "" add a comment before declarations
+ if (!packageEnumDef.equals("")) {
+ packageEnumDef = "/* Package enumeration definitions */"+NL+packageEnumDef;
+ }
+ if (!packageTypeDef.equals("")) {
+ packageTypeDef = "/* Package type definitions */"+NL+packageTypeDef;
+ }
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( packageTypeDef );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( packageEnumDef );
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java
new file mode 100644
index 00000000000..b3589b1a5fe
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppEnumerationDefinition.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import java.util.Iterator;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import Cpp.*;
+
+public class CppEnumerationDefinition
+{
+ protected static String nl;
+ public static synchronized CppEnumerationDefinition create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppEnumerationDefinition result = new CppEnumerationDefinition();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "enum ";
+ protected final String TEXT_3 = " {" + NL + "\t";
+ protected final String TEXT_4 = NL + "};" + NL;
+ protected final String TEXT_5 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // This is an util template to prepare Enumeration definition
+ /////////////////////////////////////////////////////////////
+
+
+ // Retrieve the enumeration
+ Enumeration currentEnumeration = (Enumeration) argument;
+
+ // Get the package name
+ String enumName = currentEnumeration.getName();
+
+ // Doc
+ String enumDoc = "";
+ String enumLitDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+ enumDoc = jDoc.generate(currentEnumeration);
+
+ // Retrieve literals
+ String enumLiterals = "";
+
+ Iterator<EnumerationLiteral> literalsIt = currentEnumeration.getOwnedLiterals().iterator();
+
+ while (literalsIt.hasNext()) {
+
+ // retrieve current
+ EnumerationLiteral currentLiteral = literalsIt.next();
+
+ enumLiterals = enumLiterals+currentLiteral.getName();
+
+ // if current literal is initialised
+ CppInit cppInit = GenUtils.getApplication(currentLiteral, CppInit.class);
+ if (cppInit != null) {
+ // Add the initialisation value
+ int initValue = cppInit.getValue();
+ enumLiterals = enumLiterals + " = " + initValue;
+ }
+
+ // Retrieve doc
+ if (!GenUtils.getComments(currentLiteral).equals("")) {
+ enumLitDoc = " //< "+GenUtils.getComments(currentLiteral);
+ } else {
+ enumLitDoc = "";
+ }
+
+ // if more literal left prepare new line for next literal
+ if (literalsIt.hasNext()) {
+ enumLiterals = enumLiterals+" ,"+enumLitDoc+NL+"\t";
+ } else {
+ enumLiterals = enumLiterals+enumLitDoc;
+ }
+ }
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( enumDoc );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( enumName );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( enumLiterals );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(TEXT_5);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java
new file mode 100644
index 00000000000..ced6f6754b1
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceAllIncludesDeclaration.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.emf.common.util.UniqueEList;
+import java.util.*;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.Classifier;
+
+public class CppInterfaceAllIncludesDeclaration
+{
+ protected static String nl;
+ public static synchronized CppInterfaceAllIncludesDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppInterfaceAllIncludesDeclaration result = new CppInterfaceAllIncludesDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the interface
+ Interface currentInterface = (Interface) argument;
+
+ // Prepare Dependency includes declarations ...
+ // Retrieve package used by current package (dependencies)
+ // use a unique list to avoid duplicates
+ EList<Classifier> usedClasses = new UniqueEList<Classifier> ();
+
+ String newInclude = "";
+
+ // class attributes dependencies
+ usedClasses.addAll (GenUtils.getOwnedAttributeTypes(currentInterface));
+ // operation parameters dependencies
+ usedClasses.addAll (GenUtils.getIncludesFromOperations(currentInterface));
+ // dependencies and associations
+ usedClasses.addAll (GenUtils.getRelationships(currentInterface));
+
+ Iterator<Classifier> usedClassesIt = usedClasses.iterator();
+ // Parsing all as NamedElement
+ String includes = "";
+
+ while (usedClassesIt.hasNext())
+ {
+ Classifier cl = usedClassesIt.next ();
+
+ // Only add include if this is not for the current class
+ if (!currentInterface.equals(cl)) {
+ // ... and if it does not have the stereotype "CppNoCodeGen", unless
+ // it has stereotype "CppExternalClass"
+ if ( (!GenUtils.hasStereotype(cl, CppNoCodeGen.class)) ||
+ GenUtils.hasStereotype(cl, CppExternClass.class)) {
+
+ if ((cl instanceof Enumeration) || (cl instanceof PrimitiveType))
+ {
+ // 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 interface)
+ CppOwnerPackageIncludeDeclaration jetIDecl
+ = new CppOwnerPackageIncludeDeclaration();
+ if (cl.getOwner() instanceof Package) {
+ newInclude = jetIDecl.generate (cl.getOwner ());
+ }
+ else {
+ newInclude = "";
+ }
+ }
+ else {
+ // include the file associated with the classifier
+ CppClassIncludeDeclaration jetIDecl
+ = new CppClassIncludeDeclaration();
+ newInclude = jetIDecl.generate (cl);
+ }
+
+ includes = includes+newInclude;
+ }
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( includes );
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java
new file mode 100644
index 00000000000..63b3a5ebe72
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceIncludeDeclaration.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.papyrus.cpp.codegen.Activator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppInterfaceIncludeDeclaration
+{
+ protected static String nl;
+ public static synchronized CppInterfaceIncludeDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppInterfaceIncludeDeclaration result = new CppInterfaceIncludeDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "#include <";
+ protected final String TEXT_2 = ".";
+ protected final String TEXT_3 = ">";
+ protected final String TEXT_4 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ // Retrieve header file suffix
+ String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix");
+
+ // Retrieve the interface
+ NamedElement currentNE = (NamedElement) argument;
+ String iInterfacePath = "";
+ Package nearestPkg = currentNE.getNearestPackage();
+ String iInterfaceName = currentNE.getName();
+
+ if ( //!(nearestPkg.getUml2Package() instanceof org.eclipse.uml2.uml.Model)
+ /*&&*/ !(GenUtils.hasStereotype(nearestPkg, CppRoot.class))) {
+ iInterfacePath = GenUtils.getFullPath (nearestPkg) + "/";
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( iInterfacePath );
+ stringBuffer.append( iInterfaceName );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( headerFileSuffix );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(TEXT_4);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java
new file mode 100644
index 00000000000..309f94f1d57
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Generalization;
+import java.util.Iterator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppInterfaceInheritedDeclarations
+{
+ protected static String nl;
+ public static synchronized CppInterfaceInheritedDeclarations create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppInterfaceInheritedDeclarations result = new CppInterfaceInheritedDeclarations();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the interface
+ Classifier currentClass = (Classifier) argument;
+ String decl = "";
+ String visibility = "";
+
+ // Get generalization and implementation relationships
+ Iterator<Generalization> genIt = currentClass.getGeneralizations().iterator();
+
+ // Parse generalizations
+ while (genIt.hasNext()) {
+
+ Generalization currentGen = genIt.next();
+
+ visibility = GenUtils.getVisibility(currentGen);
+
+ // If not <NoCodeGen>
+ Classifier tmpClassifier = currentGen.getGeneral();
+ if (!GenUtils.hasStereotype(tmpClassifier, CppNoCodeGen.class)) {
+
+ String targetName = tmpClassifier.getName();
+
+ if (!decl.equals("")) {
+ decl = decl + ", ";
+ }
+ decl = decl+visibility+" "+targetName;
+ }
+ }
+
+ // ":" only if decl not empty
+ String prefix = "";
+ if (!decl.equals("")) {
+ prefix = ": ";
+ visibility = "public ";
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( prefix );
+ stringBuffer.append( decl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java
new file mode 100644
index 00000000000..84debe54ae5
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfacePublicOperationsDeclaration.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.VisibilityKind;
+import java.util.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppInterfacePublicOperationsDeclaration
+{
+ protected static String nl;
+ public static synchronized CppInterfacePublicOperationsDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppInterfacePublicOperationsDeclaration result = new CppInterfacePublicOperationsDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Interface currentInterface = (Interface) argument;
+ String opDecl = "";
+
+ // Retrieve operations
+ Iterator<Operation> operations = currentInterface.getOwnedOperations().iterator();
+ while (operations.hasNext()) {
+ Operation currentOperation = operations.next();
+ if ((currentOperation.getVisibility() == VisibilityKind.PUBLIC_LITERAL) &&
+ !GenUtils.hasStereotype (currentOperation, CppNoCodeGen.class)) {
+ CppOperationDeclaration jetOpDecl = new CppOperationDeclaration();
+ String cOpDecl = jetOpDecl.generate(currentOperation);
+
+ // if main cOpDecl = "";
+ if (!cOpDecl.equals("")) {
+ opDecl = opDecl+"\t"+cOpDecl+";";
+ }
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java
new file mode 100644
index 00000000000..28ff6878080
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationDeclaration.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.StdStereo;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppOperationDeclaration
+{
+ protected static String nl;
+ public static synchronized CppOperationDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationDeclaration result = new CppOperationDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL + "\t";
+ protected final String TEXT_4 = "(";
+ protected final String TEXT_5 = ")";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+
+ String operationName = currentOperation.getName();
+
+ String opParameters = "";
+
+ String returnTypeName = "void";
+ String pVirtualSuffix = "";
+ String prefix = "";
+ String constOp = "";
+
+
+ String opDoc = "";
+
+ // Doc for the template
+ CppOperationDoc jDoc = new CppOperationDoc();
+ opDoc = GenUtils.indent (jDoc.generate(currentOperation), "\t");
+
+ // Prepare return type
+ CppOperationReturnType jetRT = new CppOperationReturnType();
+ returnTypeName = jetRT.generate(currentOperation);
+ if (!returnTypeName.equals ("")) {
+ returnTypeName += " ";
+ }
+
+ boolean isInterface = currentOperation.getOwner () instanceof Interface;
+
+ // Static attribute
+ if (currentOperation.isStatic()) {
+ prefix = prefix+"static"+" ";
+ }
+
+ // Inline attribute
+ if (GenUtils.hasStereotype(currentOperation, CppInline.class)) {
+ prefix = prefix+"inline"+" ";
+ }
+
+ // Creator / Destructor: use function within StdStereo
+ if (StdStereo.isApplied(currentOperation, StdStereo.create)) {
+ returnTypeName = "";
+ }
+ if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) {
+ returnTypeName = "";
+ operationName = "~"+operationName;
+ }
+
+ // Const attribute on operation
+ if (GenUtils.hasStereotype(currentOperation, CppConst.class)) {
+ constOp = " const";
+ }
+
+ // Virtual attribute on operation
+ if (GenUtils.hasStereotype(currentOperation, CppVirtual.class)) {
+ prefix = "virtual "+prefix;
+ }
+
+ // Pure Virtual attribute on operation
+ if (isInterface || currentOperation.isAbstract ()) {
+ prefix = "virtual "+prefix;
+ pVirtualSuffix = " = 0";
+ }
+
+ // Friend attribute on operation
+ if (GenUtils.hasStereotype(currentOperation, CppFriend.class)) {
+ prefix = "friend "+prefix;
+ }
+
+ // Prepare parameters
+ CppOperationParameters jetParams = new CppOperationParameters();
+ opParameters = jetParams.generate(currentOperation);
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template only if current operation is not main
+// else nothing is return...
+//////////////////////////////////////////////////////////////////////////////////////////
+
+if (!operationName.equals("main")) {
+
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( opDoc );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( prefix );
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append( operationName );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( opParameters );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( constOp );
+ stringBuffer.append( pVirtualSuffix );
+ //////////////////////////////////////////////////////////////////////////////////////////
+} // else nothing done
+//////////////////////////////////////////////////////////////////////////////////////////
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java
new file mode 100644
index 00000000000..af6da84736b
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationImplementation.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.StdStereo;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppOperationImplementation
+{
+ protected static String nl;
+ public static synchronized CppOperationImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationImplementation result = new CppOperationImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL;
+ protected final String TEXT_4 = " ";
+ protected final String TEXT_5 = " (";
+ protected final String TEXT_6 = ") {";
+ protected final String TEXT_7 = NL;
+ protected final String TEXT_8 = NL + "}" + NL;
+ protected final String TEXT_9 = "\t" + NL;
+ protected final String TEXT_10 = NL;
+ protected final String TEXT_11 = NL;
+ protected final String TEXT_12 = " ";
+ protected final String TEXT_13 = "::";
+ protected final String TEXT_14 = "(";
+ protected final String TEXT_15 = ")";
+ protected final String TEXT_16 = " {";
+ protected final String TEXT_17 = NL;
+ protected final String TEXT_18 = NL + "}" + NL;
+ protected final String TEXT_19 = "\t";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+
+ String body = "";
+ String className = "";
+ String operationName = currentOperation.getName();
+ String opParameters = "";
+ String returnTypeName = "void";
+ String isInline = "";
+ String isConst = "";
+ String constInit = "";
+
+ String opDoc = "";
+
+ // Doc for the template
+ CppOperationDoc jDoc = new CppOperationDoc();
+ opDoc = jDoc.generate(currentOperation);
+
+ // Retrieve class name. Operation may belong to a class or datatype, thus use
+ // generic getOwner function
+ Element opOwner = currentOperation.getOwner();
+ className = (opOwner instanceof NamedElement) ? ((NamedElement) opOwner).getName() : "";
+
+ // Retrieve body content
+ body = GenUtils.getBody (currentOperation, "C/C++");
+
+ // Prepare return type
+ CppOperationReturnType jetRT = new CppOperationReturnType();
+ returnTypeName = jetRT.generate(currentOperation);
+
+ // Creator / Destructor: use function within StdStereo
+ if (StdStereo.isApplied(currentOperation, StdStereo.create)) {
+ returnTypeName = "";
+ }
+ if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) {
+ returnTypeName = "";
+ operationName = "~"+operationName;
+ }
+
+ // If is inline operation
+ if (GenUtils.hasStereotype(currentOperation, CppInline.class)) {
+ isInline = "inline ";
+ }
+
+ // Const op
+ if (GenUtils.hasStereotype(currentOperation, CppConst.class)) {
+ isConst = " const";
+ }
+
+ // Constructor init list
+ CppConstInit cppConstInit = GenUtils.getApplication(currentOperation, CppConstInit.class);
+ if ((cppConstInit != null)
+ && StdStereo.isApplied(currentOperation, StdStereo.create)) {
+ constInit = " : " + cppConstInit.getInitialisation();
+ }
+
+ // Prepare parameters
+ CppOperationParametersWithoutDefaultValue jetParams = new CppOperationParametersWithoutDefaultValue();
+ opParameters = jetParams.generate(currentOperation);
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template two cases main operation or classical
+//////////////////////////////////////////////////////////////////////////////////////////
+
+// main
+ if (operationName.equals("main")) {
+
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( opDoc );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( operationName );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( opParameters );
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( body );
+ stringBuffer.append(TEXT_8);
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ }
+ else {
+
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append( opDoc );
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append( isInline );
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append( className );
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append( operationName );
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append( opParameters );
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append( isConst );
+ stringBuffer.append( constInit );
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append( body );
+ stringBuffer.append(TEXT_18);
+ //////////////////////////////////////////////////////////////////////////////////////////
+ }
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_19);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java
new file mode 100644
index 00000000000..fc67d3ec185
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParameters.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.*;
+
+public class CppOperationParameters
+{
+ protected static String nl;
+ public static synchronized CppOperationParameters create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationParameters result = new CppOperationParameters();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+ Parameter currentParameter;
+
+ String paramDecl = "";
+
+ Iterator<Parameter> parameters = currentOperation.getOwnedParameters().iterator();
+ while(parameters.hasNext()) {
+ currentParameter = parameters.next();
+ if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) {
+ // Prepare parameters
+ CppParameter jetParam = new CppParameter();
+ if (!paramDecl.equals("")) {
+ paramDecl += ", ";
+ }
+ paramDecl = paramDecl+jetParam.generate(currentParameter);
+ }
+ }
+
+ paramDecl.replaceAll(NL, "");
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( paramDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java
new file mode 100644
index 00000000000..d3e0dc8d710
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationParametersWithoutDefaultValue.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import java.util.*;
+
+public class CppOperationParametersWithoutDefaultValue
+{
+ protected static String nl;
+ public static synchronized CppOperationParametersWithoutDefaultValue create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationParametersWithoutDefaultValue result = new CppOperationParametersWithoutDefaultValue();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+ Parameter currentParameter;
+
+ String paramDecl = "";
+
+ Iterator<Parameter> parameters = currentOperation.getOwnedParameters().iterator();
+ while(parameters.hasNext()) {
+ currentParameter = parameters.next();
+ if (currentParameter.getDirection () != ParameterDirectionKind.RETURN_LITERAL) {
+ // Prepare parameters
+ CppParameterWithoutDefaultValue jetParam = new CppParameterWithoutDefaultValue();
+ if (!paramDecl.equals("")) {
+ paramDecl += ", ";
+ }
+ paramDecl = paramDecl+jetParam.generate(currentParameter);
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( paramDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java
new file mode 100644
index 00000000000..5a75d7009e8
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationReturnType.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import org.eclipse.uml2.uml.Class;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.*;
+
+public class CppOperationReturnType
+{
+ protected static String nl;
+ public static synchronized CppOperationReturnType create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationReturnType result = new CppOperationReturnType();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "::";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+
+ String returnTypeName = "void";
+ String ownerName = "";
+ Modifier modifier = new Modifier();
+
+ // Return type
+ if (currentOperation.getType() == null) {
+ returnTypeName = "void";
+ } else {
+ if (currentOperation.getType() == null) {
+ returnTypeName = "undefined";
+ } else {
+ // Treat the type if it is not "package visibility" and owned by a class
+ Type currentType = currentOperation.getType();
+ returnTypeName = GenUtils.qualifiedName (currentType);
+
+ if (currentType.getVisibility() != VisibilityKind.PACKAGE_LITERAL) {
+ if (currentType.getOwner() instanceof Class) {
+ ownerName = ((Class) currentType.getOwner()).getName();
+ }
+ }
+ }
+
+ // Treat pointer or ref on return parameter (only one return parameter should exists)
+ // retrieve return parameter
+// RS: changed test: now getReturnResult returns only one param
+// if (currentOperation.getUml2Operation().getReturnResults().size() == 1) {
+// org.eclipse.uml2.uml.Parameter uml2Param
+// = (org.eclipse.uml2.uml.Parameter) currentOperation.getUml2Operation().getReturnResults().get(0);
+// Parameter currentRParameter
+// = new Parameter(uml2Param);
+// // case Pointer
+// if (currentRParameter.hasStereotype(xy, CppPtr.class)) {
+// isPointer = " "+currentRParameter.getTaggedValue(CppPtr.class, "declaration");
+// }
+// if (currentRParameter.hasStereotype(xy, CppRef.class)) {
+// isRef = " "+currentRParameter.getTaggedValue(CppRef.class, "declaration");
+// }
+// if (currentRParameter.hasStereotype(xy, CppConst.class_)) {
+// isConst = "const ";
+// }
+// }
+ if (currentOperation.getReturnResult() instanceof Parameter) {
+ Parameter uml2Param = (Parameter) currentOperation.getReturnResult();
+ modifier = new Modifier(uml2Param);
+ }
+ }
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template two cases : scope required or not
+//////////////////////////////////////////////////////////////////////////////////////////
+
+// No scope details
+ if (ownerName.equals("")) {
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ //////////////////////////////////////////////////////////////////////////////////////////
+} else {
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( ownerName );
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ //////////////////////////////////////////////////////////////////////////////////////////
+}
+//////////////////////////////////////////////////////////////////////////////////////////
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java
new file mode 100644
index 00000000000..18487bed8a5
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOperationTemplateImplementation.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import org.eclipse.uml2.uml.Class;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.StdStereo;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppOperationTemplateImplementation
+{
+ protected static String nl;
+ public static synchronized CppOperationTemplateImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOperationTemplateImplementation result = new CppOperationTemplateImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "(";
+ protected final String TEXT_2 = ")";
+ protected final String TEXT_3 = " {";
+ protected final String TEXT_4 = NL;
+ protected final String TEXT_5 = NL + "}";
+ protected final String TEXT_6 = "<";
+ protected final String TEXT_7 = ">::";
+ protected final String TEXT_8 = "(";
+ protected final String TEXT_9 = ")";
+ protected final String TEXT_10 = " {";
+ protected final String TEXT_11 = NL;
+ protected final String TEXT_12 = NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Operation
+ Operation currentOperation = (Operation) argument;
+
+ String operationName = currentOperation.getName();
+ String opParameters = "";
+ String returnTypeName = "void";
+ String isConst = "";
+ String isInline = "";
+
+ // Retrieve class & class name
+ Class currentClass = currentOperation.getClass_ ();
+ String className = currentClass.getName();
+
+ // Retrieve body content
+ String body = GenUtils.getBody (currentOperation, "C/C++");
+
+ // Prepare return type
+ CppOperationReturnType jetRT = new CppOperationReturnType();
+ returnTypeName = jetRT.generate(currentOperation);
+ if (! "".equals(returnTypeName)) {
+ returnTypeName = returnTypeName + " ";
+ }
+
+ // Creator / Destructor: use function within StdStereo
+ if (StdStereo.isApplied(currentOperation, StdStereo.create)) {
+ returnTypeName = "";
+ }
+ if (StdStereo.isApplied(currentOperation, StdStereo.destroy)) {
+ returnTypeName = "";
+ operationName = "~"+operationName;
+ }
+
+ // If inline operation
+ if (GenUtils.hasStereotype(currentOperation, CppInline.class)) {
+ isInline = "inline ";
+ }
+
+ // Const op
+ if (GenUtils.hasStereotype(currentOperation, CppConst.class)) {
+ isConst = " const";
+ }
+
+ // Prepare parameters
+ CppOperationParametersWithoutDefaultValue jetParams
+ = new CppOperationParametersWithoutDefaultValue();
+ opParameters = jetParams.generate(currentOperation);
+
+
+ // Prepare template parameter declaration without type
+ String tparamWoType = "";
+
+ if (currentClass != null) {
+ tparamWoType = GenUtils.getTemplateParametersWoType(currentClass);
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+// Package visibility
+ if (currentOperation.getVisibility() == VisibilityKind.PACKAGE_LITERAL) {
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ stringBuffer.append( isInline );
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append( operationName );
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( opParameters );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( isConst );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( body );
+ stringBuffer.append(TEXT_5);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ } else { // Default case
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ stringBuffer.append( isInline );
+ stringBuffer.append( returnTypeName );
+ stringBuffer.append( className );
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append( tparamWoType );
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( operationName );
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append( opParameters );
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append( isConst );
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append( body );
+ stringBuffer.append(TEXT_12);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+ }
+//////////////////////////////////////////////////////////////////////////////////////////
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java
new file mode 100644
index 00000000000..777e4798740
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppOwnerPackageIncludeDeclaration.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.papyrus.cpp.codegen.Activator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppOwnerPackageIncludeDeclaration
+{
+ protected static String nl;
+ public static synchronized CppOwnerPackageIncludeDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppOwnerPackageIncludeDeclaration result = new CppOwnerPackageIncludeDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " \t" + NL + "/* Owner package header include */" + NL + "#include <";
+ protected final String TEXT_2 = "/Pkg_";
+ protected final String TEXT_3 = ".";
+ protected final String TEXT_4 = ">";
+ protected final String TEXT_5 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the type passed as argument
+ Package currentPkg = (Package) argument;
+ String currentPkgName = currentPkg.getName();
+ String currentPkgPath = GenUtils.getFullPath (currentPkg);
+
+ // Retrieve header file suffix
+ String headerFileSuffix = Activator.getDefault().getPluginPreferences().getString("headSuffix");
+
+ // Prepare Father include declaration
+ boolean isRoot = false;
+
+ // The currentElt has the CppRoot stereotype
+ if (GenUtils.hasStereotype(currentPkg, CppRoot.class)) {
+ isRoot = true;
+ }
+ // The currentPkg is the model root package
+ //if (currentPkg instanceof org.eclipse.uml2.uml.Model){
+ // isRoot = true;
+ //}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ // if currentPkg is not root it is referenced here
+ if (!isRoot) {
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( currentPkgPath );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( currentPkgName );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( headerFileSuffix );
+ stringBuffer.append(TEXT_4);
+ // endif
+ }
+ stringBuffer.append(TEXT_5);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java
new file mode 100644
index 00000000000..87ac2c0bfac
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameter.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Parameter;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.Modifier;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppParameter
+{
+ protected static String nl;
+ public static synchronized CppParameter create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppParameter result = new CppParameter();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " ";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Parameter
+ Parameter currentParameter = (Parameter) argument;
+
+ String parameterName = currentParameter.getName();
+
+ String typeName = "";
+ String suffix = "";
+ Modifier modifier = new Modifier(currentParameter);
+
+ if (currentParameter.getType() == null) {
+ typeName = "undefined";
+ } else {
+ typeName = GenUtils.qualifiedName (currentParameter.getType());
+ }
+
+ // Initial value
+ CppDefault cppDefault = GenUtils.getApplication(currentParameter, CppDefault.class);
+ if (cppDefault != null) {
+ suffix = " = " + cppDefault.getValue();
+ }
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( typeName );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( parameterName );
+ stringBuffer.append( modifier.array );
+ stringBuffer.append( suffix );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java
new file mode 100644
index 00000000000..1bb92004f6d
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppParameterWithoutDefaultValue.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Classifier;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.Modifier;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppParameterWithoutDefaultValue
+{
+ protected static String nl;
+ public static synchronized CppParameterWithoutDefaultValue create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppParameterWithoutDefaultValue result = new CppParameterWithoutDefaultValue();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "<";
+ protected final String TEXT_2 = ">";
+ protected final String TEXT_3 = " ";
+ protected final String TEXT_4 = " ";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the Parameter
+ Parameter currentParameter = (Parameter) argument;
+
+ String parameterName = currentParameter.getName();
+
+ String typeName = "";
+ Modifier modifier = new Modifier(currentParameter);
+
+ // Prepare template parameter declaration without type
+ String tparamWoType = "";
+
+ if (currentParameter.getType() == null) {
+ typeName = "undefined";
+ }
+ else if (currentParameter.getType() instanceof Classifier) {
+ Classifier classifier = (Classifier) currentParameter.getType();
+ tparamWoType = GenUtils.getTemplateParametersWoType(classifier);
+
+ typeName = GenUtils.qualifiedName (currentParameter.getType());
+ }
+ else {
+ typeName = GenUtils.qualifiedName (currentParameter.getType());
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+// Package visibility
+ if (!"".equals(tparamWoType)) {
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( typeName );
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( tparamWoType );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append( parameterName );
+ stringBuffer.append( modifier.array );
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ } else { // Default case
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ stringBuffer.append( modifier.isConst );
+ stringBuffer.append( typeName );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( parameterName );
+ stringBuffer.append( modifier.array );
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+ }
+//////////////////////////////////////////////////////////////////////////////////////////
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java
new file mode 100644
index 00000000000..c014caf01d6
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppPrimitiveTypeDefinition.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppPrimitiveTypeDefinition
+{
+ protected static String nl;
+ public static synchronized CppPrimitiveTypeDefinition create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppPrimitiveTypeDefinition result = new CppPrimitiveTypeDefinition();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the type passed as argument
+ PrimitiveType currentPType = (PrimitiveType) argument;
+ String currentPTypeName = currentPType.getName();
+ String definition = "";
+
+ // Doc
+ String typeDoc = "";
+
+ // Retrieve enum doc
+ CppElementDoc jDoc = new CppElementDoc();
+
+ /**
+ * 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)
+ */
+ // Retrieve type definition
+ CppType cppType = GenUtils.getApplication(currentPType, CppType.class);
+ if (cppType != null) {
+ typeDoc = jDoc.generate(currentPType);
+ definition = "typedef " + cppType.getDefinition();
+
+ // If definition string contains "typeName" it should be replaced with type name...
+ if (definition.indexOf("typeName") != -1) {
+ definition = definition.replaceAll("typeName", currentPTypeName);
+ } else {
+ definition = definition + " " + currentPTypeName;
+ }
+ definition = definition + ";";
+ }
+ else {
+ definition = GenUtils.getStdtypes(currentPType);
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( typeDoc );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( definition );
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java
new file mode 100644
index 00000000000..e24233da4ab
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppStaticAttributeImplementation.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.*;
+
+public class CppStaticAttributeImplementation
+{
+ protected static String nl;
+ public static synchronized CppStaticAttributeImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppStaticAttributeImplementation result = new CppStaticAttributeImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = "::";
+ protected final String TEXT_3 = ";";
+ protected final String TEXT_4 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the property
+ Property currentAttribute = (Property) argument;
+
+ String attributeName = currentAttribute.getName();
+ String className = GenUtils.qualifiedName (currentAttribute.getClass_());
+ String typeName = "";
+ String suffix = "";
+ String multiple = "";
+ String isAgg = ""; // attribute is an aggregation or association
+
+
+ if (currentAttribute.getType() == null) {
+ typeName = "undefined"+" ";
+ } else {
+ typeName = GenUtils.qualifiedName (currentAttribute.getType()) + " ";
+ }
+
+ // Multiple
+ // if (currentAttribute.isMultiple()) {
+ // multiple = "*";
+ // }
+
+ // 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
+ }
+
+ Modifier modifier = new Modifier(currentAttribute);
+
+ // Initial value
+ if (currentAttribute.getDefaultValue() != null) {
+ // via UML
+ suffix = " = " + currentAttribute.getDefaultValue().stringValue();
+ }
+ else {
+ CppDefault cppDefault = GenUtils.getApplication(currentAttribute, CppDefault.class);
+ if (cppDefault != null) {
+ suffix = " = " + cppDefault.getValue();
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( typeName );
+ stringBuffer.append( multiple );
+ stringBuffer.append( modifier.ptr );
+ stringBuffer.append( isAgg );
+ stringBuffer.append( modifier.ref );
+ stringBuffer.append( className );
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append( attributeName );
+ stringBuffer.append( modifier.array );
+ stringBuffer.append( suffix );
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(TEXT_4);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java
new file mode 100644
index 00000000000..09feb0868b5
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateBindingParameter.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.*;
+
+public class CppTemplateBindingParameter
+{
+ protected static String nl;
+ public static synchronized CppTemplateBindingParameter create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppTemplateBindingParameter result = new CppTemplateBindingParameter();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ // Retrieve the TemplateParameter
+ // Retrieve the TemplateParameter
+ TemplateParameterSubstitution currentTParam = (TemplateParameterSubstitution) argument;
+
+ String typeName = "";
+
+ if (currentTParam.getActual() == null) {
+ typeName ="param undefined";
+ }
+ else {
+ ParameterableElement actual = currentTParam.getActual();
+
+ if (actual instanceof LiteralInteger) {
+ typeName = "" + ((LiteralInteger) currentTParam.getActual()).getValue();
+ }
+ else {
+ typeName = ((NamedElement) currentTParam.getActual()).getName();
+ } // value = currentTParam.getFormal().getParameteredElement().getName();
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( typeName );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java
new file mode 100644
index 00000000000..567a6ce365f
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateDeclaration.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.TemplateParameter;
+import java.util.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppTemplateDeclaration
+{
+ protected static String nl;
+ public static synchronized CppTemplateDeclaration create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppTemplateDeclaration result = new CppTemplateDeclaration();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "template <";
+ protected final String TEXT_2 = ">";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Class currentClass = (Class) argument;
+
+
+ // Prepare template parameter declaration
+ Iterator<TemplateParameter> tparam = GenUtils.getTemplateParameters(currentClass).iterator();
+ String tParamDecl = "";
+
+ while(tparam.hasNext()) {
+ TemplateParameter currentTParam = tparam.next();
+
+ CppTemplateParameter jetTParam = new CppTemplateParameter();
+ tParamDecl = tParamDecl+jetTParam.generate(currentTParam);
+
+ if (tparam.hasNext()) {
+ tParamDecl = tParamDecl+", ";
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( tParamDecl );
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java
new file mode 100644
index 00000000000..999e3789ce1
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateInlineOperationsImplementation.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.papyrus.cpp.codegen.jet.doc.*;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+import java.util.Iterator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppTemplateInlineOperationsImplementation
+{
+ protected static String nl;
+ public static synchronized CppTemplateInlineOperationsImplementation create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppTemplateInlineOperationsImplementation result = new CppTemplateInlineOperationsImplementation();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the class
+ Class currentClass = (Class) argument;
+ String opDecl = "";
+ String tDecl = "";
+
+ // Retrieve template declaration
+ CppTemplateDeclaration jetTDecl = new CppTemplateDeclaration();
+ // tDecl should contain something like "template <class x, class y>"
+ tDecl = jetTDecl.generate(currentClass) + " ";
+
+ // Retrieve operations
+ Iterator<Operation> operations = currentClass.getOwnedOperations().iterator();
+ while (operations.hasNext()) {
+ Operation currentOperation = operations.next();
+
+ if (GenUtils.hasStereotype (currentOperation, CppInline.class) &&
+ !GenUtils.hasStereotype (currentOperation, CppNoCodeGen.class)) {
+ String opDoc = "";
+
+ // Doc for the template
+ CppOperationDoc jDoc = new CppOperationDoc();
+ opDoc = jDoc.generate(currentOperation);
+
+ CppOperationTemplateImplementation jetOpImpl = new CppOperationTemplateImplementation();
+ opDecl = opDecl+opDoc+NL+tDecl+jetOpImpl.generate(currentOperation)+NL;
+ }
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( opDecl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java
new file mode 100644
index 00000000000..30e4dc8da32
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppTemplateParameter.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+import org.eclipse.uml2.uml.TemplateParameter;
+
+public class CppTemplateParameter
+{
+ protected static String nl;
+ public static synchronized CppTemplateParameter create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppTemplateParameter result = new CppTemplateParameter();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " ";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+ // Retrieve the TemplateParameter
+ TemplateParameter currentTParam = (TemplateParameter) argument;
+
+ String parameterName = "";
+ String typeName = "";
+
+
+ if (GenUtils.getType(currentTParam) == "") {
+ typeName = "undefined";
+ } else {
+ typeName = GenUtils.getType(currentTParam); //.getName();
+ }
+
+ // Retrieve name under stereotype CppTemplateParameter/name
+ Cpp.CppTemplateParameter ctp = GenUtils.getApplication(currentTParam, Cpp.CppTemplateParameter.class);
+ if (ctp != null) {
+ parameterName = ctp.getName();
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ stringBuffer.append( typeName );
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( parameterName );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file

Back to the top