Bug 579217 - [Designer, components] Code generation for abstract components generated wrong code
Bug 579408 - [Designer, C++ codegen] Non required includes for abstract operation

- Changed order in which the component-to-OO transformation applies the ptr stereotype
  This assures the right dereferencing operaitons are produced in the createConnections call.
	(and a comment that indiciates that order has an impact).

- The component-to-OO transformation adds a abstract "get-port" operation to a class (pure virtual),
  if the class is abstract and the port is thus not implemented by the class. It is currently not
  possible to implement a part of the ports in case of an abstract component.

- Add comment to PortUtils that outlines the original idea of a separation between component-type and
  implementation. This sepearation needs to be documented in the wiki as well.

- The error message (implying a stop of code generation) is kept, as the check is only done for ports of
  the own component and those in an abstract superclass (and therefore not implemented there). This is
  aligned with the automatic synchronisation of the "implements-interface" which is not done in the
  superclass.

- Filter operations depending on their abstract status, when generting code for bodies

Change-Id: I0dc5baa1755a6c4910a10410fc84a61b122c2ba4
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/AbstractCompToOO.xtend b/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/AbstractCompToOO.xtend
index 497dfea..94c3dbf 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/AbstractCompToOO.xtend
+++ b/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/AbstractCompToOO.xtend
@@ -6,7 +6,7 @@
  * are made available under the terms of the Eclipse Public License 2.0
  * which accompanies this distribution, and is available at
  * https://www.eclipse.org/legal/epl-2.0/
- *
+ * 
  * SPDX-License-Identifier: EPL-2.0
  * 
  * Contributors:
@@ -57,16 +57,16 @@
  * replaced with attributes and access operations, connectors within a composite
  * by an operation that creates the initial setup. It is an abstract class that is
  * refined for C++ and Java
- *
+ * 
  * 1. add an operation that allows to retrieve the reference to an interface provided
  *    by a port. This operation has a mapping to a specific name, e.g. get_<port_name>
- *
+ * 
  * 2. add an operation that allows to connect a specific port.
  *    the connect_q operation (*including a storage attribute*) for a port with a required interface
- *
+ * 
  * 3. add an implementation for the getcnx_q operation for a port
  *    with a required interface (the operation itself has been added before)
- *
+ * 
  */
 abstract class AbstractCompToOO implements IOOTrafo {
 
@@ -95,13 +95,9 @@
 	 * Return the reference of an attribute
 	 */
 	abstract def String getRef(Property attribute)
-	
+
 	override addPortOperations(Class implementation) {
-		// only implementations (non abstract classes) have get operations for ports
-		if (!implementation.isAbstract) {
-			addGetPortOperation(implementation)
-		}
-		// but all classes need a connection operation, since it does not rely on an implementation 
+		addGetPortOperation(implementation)
 		addConnectPortOperation(implementation)
 	}
 
@@ -120,7 +116,7 @@
 				if (providedIntfs.size == 1 && portInfo.port.type instanceof Interface) {
 					addGetPortOperation(implementation, portInfo, providedIntfs.get(0), portInfo.name);
 				} else {
-					for(Interface providedIntf : providedIntfs) {
+					for (Interface providedIntf : providedIntfs) {
 						addGetPortOperation(implementation, portInfo, providedIntf, portInfo.name + providedIntf.name);
 					}
 				}
@@ -144,74 +140,87 @@
 			val retParam = op.getOwnedParameters().get(0)
 			retParam.setName(Constants.retParamName)
 			applyRef(retParam)
+			if (implementation.isAbstract) {
+				// since component is abstract, create abstract delegation operation
+				op.isAbstract = true;
+			}
+			else {	
+				addGetPortOperationImpl(implementation, portInfo, providedIntf, portName);
+			}
+		}
+	}
 
-			val behavior = implementation.createOwnedBehavior(opName,
-				UMLPackage.eINSTANCE.getOpaqueBehavior()) as OpaqueBehavior
-			op.getMethods().add(behavior)
+	def addGetPortOperationImpl(Class implementation, PortInfo portInfo, Interface providedIntf, String portName) {
+		val opName = PrefixConstants.getP_Prefix + portName
+		var op = implementation.getOwnedOperation(opName, null, null)
+		// op must exist (checked by caller)
+		val behavior = implementation.createOwnedBehavior(opName,
+			UMLPackage.eINSTANCE.getOpaqueBehavior()) as OpaqueBehavior
+		op.getMethods().add(behavior)
 
-			val ces = ConnectorUtil.getDelegations(implementation, portInfo.getModelPort())
+		val ces = ConnectorUtil.getDelegations(implementation, portInfo.getModelPort())
 
-			// if there is an delegation to an inner property, delegate to it
-			// Make distinction between delegation to component (with a port) or
-			// "normal" class (without).
-			var String body
-			if (!ces.empty) {
-				body = "return "
-				
-				var i = 0
-				while (i < ces.size && body.equals("return ")) {
-					val part = ces.get(i).partWithPort
-					val role = ces.get(i).role
-					
-					if (role instanceof Port) {
-						val rolePort = role as Port
-						if (rolePort.provideds.contains(providedIntf)) {
-							if (rolePort.provideds.size > 1) {
-								body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»«providedIntf.name»();'''
-							} else {
-								body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»();'''
-							}
-							
+		// if there is an delegation to an inner property, delegate to it
+		// Make distinction between delegation to component (with a port) or
+		// "normal" class (without).
+		var String body
+		if (!ces.empty) {
+			body = "return "
+
+			var i = 0
+			while (i < ces.size && body.equals("return ")) {
+				val part = ces.get(i).partWithPort
+				val role = ces.get(i).role
+
+				if (role instanceof Port) {
+					val rolePort = role as Port
+					if (rolePort.provideds.contains(providedIntf)) {
+						if (rolePort.provideds.size > 1) {
+							body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»«providedIntf.name»();'''
+						} else {
+							body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»();'''
 						}
-					} else {
-						// role is not a port: connector connects directly to a
-						// structural feature without passing via a port
-						if (role instanceof Property) {
-							val roleType = (role as Property).type;
-							if (roleType instanceof BehavioredClassifier && (roleType as BehavioredClassifier).getInterfaceRealization(null, providedIntf) !== null) {
-								body += role.name
-							}
+
+					}
+				} else {
+					// role is not a port: connector connects directly to a
+					// structural feature without passing via a port
+					if (role instanceof Property) {
+						val roleType = (role as Property).type;
+						if (roleType instanceof BehavioredClassifier &&
+							(roleType as BehavioredClassifier).getInterfaceRealization(null, providedIntf) !== null) {
+							body += role.name
 						}
 					}
-					i++
 				}
-			} else {
-
-				// no delegation, check whether port implements provided interface
-				var implementsIntf = implementation.getInterfaceRealization(null, providedIntf) !== null
-				if (!implementsIntf) {
-
-					// The extended port itself is not copied to the target
-					// model (since referenced via a stereotype). Therefore,
-					// a port of an extended port still points to the
-					// original model. We try whether the providedIntf
-					// within the target model is within the interface
-					// realizations.
-					val providedIntfInCopy = copier.getCopy(providedIntf)
-					implementsIntf = implementation.getInterfaceRealization(null, providedIntfInCopy) !== null
-				}
-				if (implementsIntf) {
-					body = "return this;"
-				} else {
-					throw new RuntimeException(
-						String.format(
-							"Interface <%s> provided by port <%s> of class <%s> is not implemented by the component itself nor does the port delegate to a part",
-							providedIntf.name, portName, implementation.name))
-				}
+				i++
 			}
-			behavior.getLanguages().add(progLang)
-			behavior.getBodies().add(body)
+		} else {
+
+			// no delegation, check whether port implements provided interface
+			var implementsIntf = implementation.getInterfaceRealization(null, providedIntf) !== null
+			if (!implementsIntf) {
+
+				// The extended port itself is not copied to the target
+				// model (since referenced via a stereotype). Therefore,
+				// a port of an extended port still points to the
+				// original model. We try whether the providedIntf
+				// within the target model is within the interface
+				// realizations.
+				val providedIntfInCopy = copier.getCopy(providedIntf)
+				implementsIntf = implementation.getInterfaceRealization(null, providedIntfInCopy) !== null
+			}
+			if (implementsIntf) {
+				body = "return this;"
+			} else {
+				throw new RuntimeException(
+					String.format(
+						"Interface <%s> provided by port <%s> of class <%s> is not implemented by the component itself nor does the port delegate to a part",
+						providedIntf.name, portName, implementation.name))
+			}
 		}
+		behavior.getLanguages().add(progLang)
+		behavior.getBodies().add(body)
 	}
 
 	/**
@@ -230,14 +239,15 @@
 				if (requiredIntfs.size == 1 && portInfo.port.type instanceof Interface) {
 					addConnectPortOperation(implementation, portInfo, requiredIntfs.get(0), portInfo.name);
 				} else {
-					for(Interface requiredIntf : requiredIntfs) {
-						addConnectPortOperation(implementation, portInfo, requiredIntf, portInfo.name + requiredIntf.name);
+					for (Interface requiredIntf : requiredIntfs) {
+						addConnectPortOperation(implementation, portInfo, requiredIntf,
+							portInfo.name + requiredIntf.name);
 					}
 				}
 			}
 		}
 	}
-	
+
 	def addConnectPortOperation(Class implementation, PortInfo portInfo, Interface requiredIntf, String portName) {
 		// port requires an interface, add "connect_p" operation and implementation
 		val opName = PrefixConstants.connectQ_Prefix + portName
@@ -267,24 +277,24 @@
 				var i = 0
 				while (i < ces.size && body.empty) {
 					val part = ces.get(i).partWithPort
-					
+
 					val role = ces.get(i).role
 					if (role instanceof Port) {
 						if ((role as Port).requireds.contains(requiredIntf)) {
 							body = part.name
-							
+
 							// in case of a delegation, use name of target port which might be different
 							var targetOpName = PrefixConstants.connectQ_Prefix + role.name
 							if ((role as Port).requireds.size > 1) {
 								targetOpName += requiredIntf.name
 							}
-							
+
 							body = '''«part.nameRef»«targetOpName»(ref);'''
 						}
 					} else {
-						if (part.type instanceof Classifier
-							&& (part.type as Classifier).getAllUsedInterfaces().contains(requiredIntf))
-						body += '''«part.name»;'''
+						if (part.type instanceof Classifier &&
+							(part.type as Classifier).getAllUsedInterfaces().contains(requiredIntf))
+							body += '''«part.name»;'''
 					}
 					i++
 				}
@@ -314,7 +324,6 @@
 			// TODO: reconsider optimization that delegated required ports do not have a
 			// local attribute and associated operation (an inner class may delegate, but the
 			// composite may be using it as well).
-			
 			if ((PrefixConstants.getConnQ_Prefix.length() > 0) && (!ces.empty)) {
 				val getConnOpName = PrefixConstants.getConnQ_Prefix + portName
 				var getConnOp = implementation.getOwnedOperation(getConnOpName, null, null)
@@ -406,8 +415,8 @@
 	 * @return
 	 * @throws TransformationException
 	 */
-	def connectPorts(Connector connector, ConnectorEnd receptacleEnd,
-		ConnectorEnd facetEnd, Port subPort) throws TransformationException {
+	def connectPorts(Connector connector, ConnectorEnd receptacleEnd, ConnectorEnd facetEnd,
+		Port subPort) throws TransformationException {
 		val association = connector.type
 		if ((receptacleEnd.role instanceof Port) && (facetEnd.role instanceof Port)) {
 			val facetPort = facetEnd.role as Port
@@ -421,21 +430,21 @@
 
 				var subPortName = ""
 				if(subPort !== null) subPortName += "_" + subPort.name
-				
+
 				var result = ""
-				
+
 				if (receptaclePI.getRequireds().size > 1) { // receptaclePort requires several interfaces
 					for (requiredInterface : receptaclePI.getRequireds()) {
 						var receptaclePortName = receptaclePI.name + requiredInterface.name
 						var facetPortName = ""
-						
+
 						if (facetPI.getProvideds().contains(requiredInterface)) {
 							facetPortName += facetPI.name
 							if (facetPI.getProvideds().size > 1) {
 								facetPortName += requiredInterface.name
-							} 
+							}
 						}
-						
+
 						if (!facetPortName.empty) {
 							val setter = '''«receptaclePart.nameRef»connect_«receptaclePortName»«subPortName»'''
 							val getter = '''«facetPart.nameRef»get_«facetPortName»«subPortName»()'''
@@ -444,20 +453,21 @@
 					}
 				} else { // receptaclePort requires only 1 interface
 					var facetPortName = ""
-						
-					if (facetPI.getProvideds().size > 1 && facetPI.getProvideds().contains(receptaclePI.getRequired())) {
+
+					if (facetPI.getProvideds().size > 1 &&
+						facetPI.getProvideds().contains(receptaclePI.getRequired())) {
 						facetPortName += facetPI.name + receptaclePI.getRequired().name
 					} else if (facetPI.getProvideds().size == 1) { // Original behavior in case of single interface, where we always connect without check of interface consistency
 						facetPortName = facetPI.name
 					}
-					
+
 					if (!facetPortName.empty) {
 						val setter = '''«receptaclePart.nameRef»connect_«receptaclePort.name»«subPortName»'''
 						val getter = '''«facetPart.nameRef»get_«facetPortName»«subPortName»()'''
 						result += '''«setter»(«getter»);''' + NL
 					}
 				}
-				
+
 				return result
 			}
 		} else if (receptacleEnd.role instanceof Port) {
@@ -469,11 +479,11 @@
 				val receptaclePart = facetEnd.partWithPort
 
 				var result = ""
-				
+
 				if (receptaclePort.getRequireds().size > 1) { // receptaclePort requires several interfaces
 					for (requiredInterface : receptaclePort.getRequireds()) {
 						var receptaclePortName = receptaclePort.name + requiredInterface.name
-						
+
 						val setter = '''«receptaclePart.nameRef»connect_«receptaclePortName»'''
 						val getter = '''«facetPart.getRef»'''
 						result += '''«setter»(«getter»);''' + NL
@@ -483,7 +493,7 @@
 					val getter = '''«facetPart.getRef»'''
 					result += '''«setter»(«getter»);''' + NL
 				}
-				
+
 				return result
 			}
 		} else if (facetEnd.role instanceof Port) {
@@ -493,13 +503,13 @@
 			if (PortUtils.getProvided(facetPort) !== null) {
 				val facetPart = facetEnd.partWithPort
 				val receptaclePart = facetEnd.role as Property
-				
+
 				var result = ""
-				
+
 				if (facetPort.getProvideds().size > 1) { // facetPort provides several interfaces
 					for (providedInterface : facetPort.getProvideds()) {
 						var facetPortName = facetPort.name + providedInterface.name
-						
+
 						val setter = receptaclePart.name
 						val getter = '''«facetPart.nameRef»get_«facetPortName»();'''
 						result += '''«setter» = «getter»;''' + NL
@@ -509,7 +519,7 @@
 					val getter = '''«facetPart.nameRef»get_«facetPort.name»();'''
 					result += '''«setter» = «getter»;''' + NL
 				}
-				
+
 				return result
 			}
 		} else if (association !== null) {
@@ -586,7 +596,7 @@
 		}
 		return false
 	}
-	
+
 	/**
 	 * Returns true if the port delegates to multiple parts/ports. Checks in depth.
 	 * @param port
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/ExecuteOOTrafo.java b/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/ExecuteOOTrafo.java
index 1e35ef3..4c4e6e9 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/ExecuteOOTrafo.java
+++ b/plugins/components/org.eclipse.papyrus.designer.components.modellibs.core/src/org/eclipse/papyrus/designer/components/modellibs/core/transformations/ExecuteOOTrafo.java
@@ -55,9 +55,11 @@
 				Class implementation = (Class) element;
 				// do not apply transformation to port-kinds
 				if (!StereotypeUtil.isApplied(implementation, PortKind.class)) {
+					// CAVEAT: oder is important, addConnectionOperation relies on point that is
+					//  applied in transformParts
+					ooTrafo.transformParts(implementation);
 					ooTrafo.addPortOperations(implementation);
 					ooTrafo.addConnectionOperation(implementation);
-					ooTrafo.transformParts(implementation);
 				}
 			}
 		}
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
index 10326ec..5a44edc 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
@@ -12,6 +12,18 @@
 #include "ProducerConsumer/DataExchange_PubData/Pkg_DataExchange_PubData.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class PullConsumer_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -19,6 +31,13 @@
  * 
  */
 class PullC {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::PullConsumer_PubData* get_pullCPullConsumer_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
index a3c1ccf..1d9871f 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
@@ -12,6 +12,18 @@
 #include "ProducerConsumer/DataExchange_PubData/Pkg_DataExchange_PubData.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class Push_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -19,6 +31,13 @@
  * 
  */
 class PushP {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::Push_PubData* get_pushPPush_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
index 2d2a76f..20598a2 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
@@ -15,6 +15,29 @@
 #include "ProducerConsumer/DataExchange_PubData/PushP.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class PullConsumer_PubData;
+}
+}
+}
+}
+}
+namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class Push_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -22,6 +45,19 @@
  * 
  */
 class PushPull: public PushP, public PullC {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::Push_PubData* get_pushPPush_PubData() = 0;
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::PullConsumer_PubData* get_pullCPullConsumer_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/ContainerServices/LifeCycle.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/ContainerServices/LifeCycle.h
index 19a9a7c..d15ef12 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/ContainerServices/LifeCycle.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/ContainerServices/LifeCycle.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/ContainerServices/Pkg_ContainerServices.h"
 
+namespace sysinterfaces {
+class ILifeCycle;
+}
+
 namespace componentlib {
 namespace ContainerServices {
 
@@ -19,6 +23,13 @@
  * 
  */
 class LifeCycle {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::ILifeCycle* get_lc() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Crun.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Crun.h
index 5dc42e9..a6f9a2a 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Crun.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Crun.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/StdPorts/Pkg_StdPorts.h"
 
+namespace sysinterfaces {
+class IRunnable;
+}
+
 namespace componentlib {
 namespace StdPorts {
 
@@ -19,6 +23,13 @@
  * 
  */
 class Crun {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::IRunnable* get_run() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Cstart.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Cstart.h
index 36c0865..3be3255 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Cstart.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull1/src-gen/componentlib/StdPorts/Cstart.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/StdPorts/Pkg_StdPorts.h"
 
+namespace sysinterfaces {
+class IStart;
+}
+
 namespace componentlib {
 namespace StdPorts {
 
@@ -19,6 +23,13 @@
  * 
  */
 class Cstart {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::IStart* get_start() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
index 10326ec..5a44edc 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PullC.h
@@ -12,6 +12,18 @@
 #include "ProducerConsumer/DataExchange_PubData/Pkg_DataExchange_PubData.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class PullConsumer_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -19,6 +31,13 @@
  * 
  */
 class PullC {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::PullConsumer_PubData* get_pullCPullConsumer_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
index a3c1ccf..1d9871f 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushP.h
@@ -12,6 +12,18 @@
 #include "ProducerConsumer/DataExchange_PubData/Pkg_DataExchange_PubData.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class Push_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -19,6 +31,13 @@
  * 
  */
 class PushP {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::Push_PubData* get_pushPPush_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
index 2d2a76f..20598a2 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/ProducerConsumer/DataExchange_PubData/PushPull.h
@@ -15,6 +15,29 @@
 #include "ProducerConsumer/DataExchange_PubData/PushP.h"
 
 namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class PullConsumer_PubData;
+}
+}
+}
+}
+}
+namespace ProducerConsumer {
+namespace derivedTypes {
+namespace ProducerConsumer {
+namespace components {
+namespace interfaces {
+class Push_PubData;
+}
+}
+}
+}
+}
+
+namespace ProducerConsumer {
 namespace DataExchange_PubData {
 
 /************************************************************/
@@ -22,6 +45,19 @@
  * 
  */
 class PushPull: public PushP, public PullC {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::Push_PubData* get_pushPPush_PubData() = 0;
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::ProducerConsumer::derivedTypes::ProducerConsumer::components::interfaces::PullConsumer_PubData* get_pullCPullConsumer_PubData() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/ContainerServices/LifeCycle.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/ContainerServices/LifeCycle.h
index 19a9a7c..d15ef12 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/ContainerServices/LifeCycle.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/ContainerServices/LifeCycle.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/ContainerServices/Pkg_ContainerServices.h"
 
+namespace sysinterfaces {
+class ILifeCycle;
+}
+
 namespace componentlib {
 namespace ContainerServices {
 
@@ -19,6 +23,13 @@
  * 
  */
 class LifeCycle {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::ILifeCycle* get_lc() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Crun.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Crun.h
index 5dc42e9..a6f9a2a 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Crun.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Crun.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/StdPorts/Pkg_StdPorts.h"
 
+namespace sysinterfaces {
+class IRunnable;
+}
+
 namespace componentlib {
 namespace StdPorts {
 
@@ -19,6 +23,13 @@
  * 
  */
 class Crun {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::IRunnable* get_run() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Cstart.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Cstart.h
index 36c0865..3be3255 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Cstart.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPull2/src-gen/componentlib/StdPorts/Cstart.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/StdPorts/Pkg_StdPorts.h"
 
+namespace sysinterfaces {
+class IStart;
+}
+
 namespace componentlib {
 namespace StdPorts {
 
@@ -19,6 +23,13 @@
  * 
  */
 class Cstart {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::IStart* get_start() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/ContainerServices/LifeCycle.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/ContainerServices/LifeCycle.h
index 19a9a7c..d15ef12 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/ContainerServices/LifeCycle.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/ContainerServices/LifeCycle.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/ContainerServices/Pkg_ContainerServices.h"
 
+namespace sysinterfaces {
+class ILifeCycle;
+}
+
 namespace componentlib {
 namespace ContainerServices {
 
@@ -19,6 +23,13 @@
  * 
  */
 class LifeCycle {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::ILifeCycle* get_lc() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/StdPorts/Cstart.h b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/StdPorts/Cstart.h
index 36c0865..3be3255 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/StdPorts/Cstart.h
+++ b/plugins/components/org.eclipse.papyrus.designer.components.tests/expectedResult/ProducerConsumer_monoNode_monoPush/src-gen/componentlib/StdPorts/Cstart.h
@@ -11,6 +11,10 @@
 
 #include "componentlib/StdPorts/Pkg_StdPorts.h"
 
+namespace sysinterfaces {
+class IStart;
+}
+
 namespace componentlib {
 namespace StdPorts {
 
@@ -19,6 +23,13 @@
  * 
  */
 class Cstart {
+public:
+
+	/**
+	 * 
+	 * @return ret 
+	 */
+	virtual ::sysinterfaces::IStart* get_start() = 0;
 
 };
 /************************************************************/
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.transformation.cpp/src/org/eclipse/papyrus/designer/components/transformation/cpp/xtend/StaticCppToOO.xtend b/plugins/components/org.eclipse.papyrus.designer.components.transformation.cpp/src/org/eclipse/papyrus/designer/components/transformation/cpp/xtend/StaticCppToOO.xtend
index 1dd06e9..9abeba8 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.transformation.cpp/src/org/eclipse/papyrus/designer/components/transformation/cpp/xtend/StaticCppToOO.xtend
+++ b/plugins/components/org.eclipse.papyrus.designer.components.transformation.cpp/src/org/eclipse/papyrus/designer/components/transformation/cpp/xtend/StaticCppToOO.xtend
@@ -100,8 +100,7 @@
 				typedef.definition = '''class «type.name» *'''
 			}
 			return ptrType;
-		}
-		else {
+		} else {
 			return type;
 		}
 	}
@@ -136,117 +135,107 @@
 		}
 	}
 
-	override addGetPortOperation(Class implementation, PortInfo portInfo, Interface providedIntf, String portName) {
+	override addGetPortOperationImpl(Class implementation, PortInfo portInfo, Interface providedIntf, String portName) {
 		// port provides an interface, add "get_p" operation and implementation
 		val opName = PrefixConstants.getP_Prefix + portName
 		var op = implementation.getOwnedOperation(opName, null, null)
-		if (op !== null) {
-			// operation already exists. Assume that user wants to
-			// override standard delegation
-			if (op.type != providedIntf) {
-				op.createOwnedParameter(Constants.retParamName, providedIntf)
+		// op must exist (checked by caller)
+		val retParam = op.getOwnedParameters().get(0)
+		retParam.setName(Constants.retParamName)
+		applyRef(retParam)
+
+		val behavior = implementation.createOwnedBehavior(opName,
+			UMLPackage.eINSTANCE.getOpaqueBehavior()) as OpaqueBehavior
+		op.getMethods().add(behavior)
+
+		val ces = ConnectorUtil.getDelegations(implementation, portInfo.getModelPort())
+		var connectedDelegations = 0
+		for (ce : ces) {
+			val role = ce.role
+
+			if (role instanceof Port) {
+				val rolePort = role as Port
+				if (rolePort.provideds.contains(providedIntf)) {
+					connectedDelegations++
+				}
+			} else {
+				if (role instanceof Property) {
+					val roleType = (role as Property).type;
+					if (roleType instanceof BehavioredClassifier &&
+						(roleType as BehavioredClassifier).getInterfaceRealization(null, providedIntf) !== null) {
+						connectedDelegations++
+					}
+				}
 			}
-		} else {
-			op = implementation.createOwnedOperation(opName, null, null, providedIntf)
-			val retParam = op.getOwnedParameters().get(0)
-			retParam.setName(Constants.retParamName)
-			applyRef(retParam)
+		}
+		val isMultipleDelegations = connectedDelegations > 1
 
-			val behavior = implementation.createOwnedBehavior(opName,
-				UMLPackage.eINSTANCE.getOpaqueBehavior()) as OpaqueBehavior
-			op.getMethods().add(behavior)
+		var String body
 
-			val ces = ConnectorUtil.getDelegations(implementation, portInfo.getModelPort())
-			var connectedDelegations = 0
-			for (ce : ces) {
-				val role = ce.role
+		if (isMultipleDelegations) {
+			val dc = new CreateMultiRefClass(this, copier)
+			body = dc.createDelegationProvided(implementation, ces, portInfo.port, portName, providedIntf);
+		} else if (!ces.empty) {
+			// If there is an delegation to one, and one only, inner property, delegate to it
+			// Make distinction between delegation to a port of the class typing an inner property or the property itself
+			body = "return "
+
+			var i = 0
+			while (i < ces.size && body.equals("return ")) {
+				val part = ces.get(i).partWithPort
+				val role = ces.get(i).role
 
 				if (role instanceof Port) {
 					val rolePort = role as Port
 					if (rolePort.provideds.contains(providedIntf)) {
-						connectedDelegations++
+						if (rolePort.provideds.size > 1 || !(rolePort.type instanceof Interface)) {
+							body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»«providedIntf.name»();'''
+						} else {
+							body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»();'''
+						}
 					}
 				} else {
+					// role is not a port: connector connects directly to a
+					// structural feature without passing via a port
 					if (role instanceof Property) {
 						val roleType = (role as Property).type;
 						if (roleType instanceof BehavioredClassifier &&
 							(roleType as BehavioredClassifier).getInterfaceRealization(null, providedIntf) !== null) {
-							connectedDelegations++
+							body += role.name
 						}
 					}
 				}
+				i++
 			}
-			val isMultipleDelegations = connectedDelegations > 1
 
-			var String body
+			if (body.equals("return ")) {
+				body += "NULL;"
+			}
+		} else {
+			// no delegation, check whether port implements provided interface
+			var implementsIntf = implementation.getInterfaceRealization(null, providedIntf) !== null
+			if (!implementsIntf) {
 
-			if (isMultipleDelegations) {
-				val dc = new CreateMultiRefClass(this, copier)
-				body = dc.createDelegationProvided(implementation, ces, portInfo.port, portName, providedIntf);
-			} else if (!ces.empty) {
-				// If there is an delegation to one, and one only, inner property, delegate to it
-				// Make distinction between delegation to a port of the class typing an inner property or the property itself
-				body = "return "
-
-				var i = 0
-				while (i < ces.size && body.equals("return ")) {
-					val part = ces.get(i).partWithPort
-					val role = ces.get(i).role
-
-					if (role instanceof Port) {
-						val rolePort = role as Port
-						if (rolePort.provideds.contains(providedIntf)) {
-							if (rolePort.provideds.size > 1 || !(rolePort.type instanceof Interface)) {
-								body +=
-									'''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»«providedIntf.name»();'''
-							} else {
-								body += '''«part.nameRef»«PrefixConstants.getP_Prefix»«role.name»();'''
-							}
-						}
-					} else {
-						// role is not a port: connector connects directly to a
-						// structural feature without passing via a port
-						if (role instanceof Property) {
-							val roleType = (role as Property).type;
-							if (roleType instanceof BehavioredClassifier &&
-								(roleType as BehavioredClassifier).getInterfaceRealization(null, providedIntf) !==
-									null) {
-								body += role.name
-							}
-						}
-					}
-					i++
-				}
-
-				if (body.equals("return ")) {
-					body += "NULL;"
-				}
+				// The extended port itself is not copied to the target
+				// model (since referenced via a stereotype). Therefore,
+				// a port of an extended port still points to the
+				// original model. We try whether the providedIntf
+				// within the target model is within the interface
+				// realizations.
+				val providedIntfInCopy = copier.getCopy(providedIntf)
+				implementsIntf = implementation.getInterfaceRealization(null, providedIntfInCopy) !== null
+			}
+			if (implementsIntf) {
+				body = "return this;"
 			} else {
-				// no delegation, check whether port implements provided interface
-				var implementsIntf = implementation.getInterfaceRealization(null, providedIntf) !== null
-				if (!implementsIntf) {
-
-					// The extended port itself is not copied to the target
-					// model (since referenced via a stereotype). Therefore,
-					// a port of an extended port still points to the
-					// original model. We try whether the providedIntf
-					// within the target model is within the interface
-					// realizations.
-					val providedIntfInCopy = copier.getCopy(providedIntf)
-					implementsIntf = implementation.getInterfaceRealization(null, providedIntfInCopy) !== null
-				}
-				if (implementsIntf) {
-					body = "return this;"
-				} else {
-					throw new RuntimeException(
-						String.format(
-							"Interface <%s> provided by port <%s> of class <%s> is not implemented by the component itself nor does the port delegate to a part",
-							providedIntf.name, portName, implementation.name))
-				}
+				throw new RuntimeException(
+					String.format(
+						"Interface <%s> provided by port <%s> of class <%s> is not implemented by the component itself nor does the port delegate to a part",
+						providedIntf.name, portName, implementation.name))
 			}
-			behavior.getLanguages().add(progLang)
-			behavior.getBodies().add(body)
 		}
+		behavior.getLanguages().add(progLang)
+		behavior.getBodies().add(body)
 	}
 
 	override addConnectPortOperation(Class implementation, PortInfo portInfo, Interface requiredIntf, String portName) {
@@ -373,8 +362,8 @@
 		}
 	}
 
-	override connectPorts(Connector connector, ConnectorEnd receptacleEnd,
-		ConnectorEnd facetEnd, Port subPort) throws TransformationException {
+	override connectPorts(Connector connector, ConnectorEnd receptacleEnd, ConnectorEnd facetEnd,
+		Port subPort) throws TransformationException {
 		val association = connector.type
 		if ((receptacleEnd.role instanceof Port) && (facetEnd.role instanceof Port)) {
 			val facetPort = facetEnd.role as Port
diff --git a/plugins/components/org.eclipse.papyrus.designer.components.transformation/src/org/eclipse/papyrus/designer/components/transformation/PortUtils.java b/plugins/components/org.eclipse.papyrus.designer.components.transformation/src/org/eclipse/papyrus/designer/components/transformation/PortUtils.java
index 1d25cb0..106683a 100644
--- a/plugins/components/org.eclipse.papyrus.designer.components.transformation/src/org/eclipse/papyrus/designer/components/transformation/PortUtils.java
+++ b/plugins/components/org.eclipse.papyrus.designer.components.transformation/src/org/eclipse/papyrus/designer/components/transformation/PortUtils.java
@@ -149,10 +149,11 @@
 
 	/**
 	 * Returns all ports for an encapsulated classifier. Inherited ports are
-	 * included, except if the superclass is already a component implementation.
-	 * The motivation for this function is that ports inherited by a
-	 * component implementation have already corresponding operations/attributes,
-	 * only ports inherited by types need these definitions in subclasses.
+	 * included if the superclass is abstract.
+	 * The motivation for this function is the idea of separating component
+	 * types and components implementations. The latter have already corresponding
+	 * operations/attributes, only ports inherited by types (abstract classes) need
+	 * to redefine operations associated with a port.
 	 * TODO: support for abstract implementations that partially implement ports
 	 *
 	 * @param ec
diff --git a/plugins/languages/common/org.eclipse.papyrus.designer.languages.common.base/src/org/eclipse/papyrus/designer/languages/common/base/GenUtils.java b/plugins/languages/common/org.eclipse.papyrus.designer.languages.common.base/src/org/eclipse/papyrus/designer/languages/common/base/GenUtils.java
index 3eb741c..ad1867d 100644
--- a/plugins/languages/common/org.eclipse.papyrus.designer.languages.common.base/src/org/eclipse/papyrus/designer/languages/common/base/GenUtils.java
+++ b/plugins/languages/common/org.eclipse.papyrus.designer.languages.common.base/src/org/eclipse/papyrus/designer/languages/common/base/GenUtils.java
@@ -63,6 +63,13 @@
 	public static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
 
 	/**
+	 * Enumeration to filter the inclusion of the types of abstract operations
+	 */
+	public enum IncludeAbstract {
+		ONLY_ABSTRACT, ONLY_NON_ABSTRACT, ALL_OPERATIONS
+	}
+
+	/**
 	 * Returns the required types, if a property uses the TemplateBinding stereotype or
 	 * its type is a bound template type
 	 * In any case, it will add the type of the passed element itself
@@ -329,19 +336,34 @@
 	 * @return Collection of classifiers which are the types of the operation parameters
 	 */
 	public static EList<Classifier> getTypesViaOperations(Classifier current) {
+		return getTypesViaOperations(current, IncludeAbstract.ALL_OPERATIONS);
+	}
+
+	/**
+	 * Get a list of types that are referenced via an operation
+	 * 
+	 * @param current
+	 *            Classifier on which the operations are searched for
+	 * @param abstractFilter
+	 *            Include only operations depending on its abstract status
+	 * @return
+	 */
+	public static EList<Classifier> getTypesViaOperations(Classifier current, IncludeAbstract abstractFilter) {
 		EList<Classifier> result = new UniqueEList<Classifier>();
 		for (Operation operation : current.getOperations()) {
-			for (Parameter param : operation.getOwnedParameters()) {
-				List<Type> requiredTypes = getTemplateRequiredTypes(param);
-				for (Type requiredType : requiredTypes) {
-					addFarthestOwnerType(requiredType, result);
+			if (filterAbstract(operation.isAbstract(), abstractFilter)) {
+				for (Parameter param : operation.getOwnedParameters()) {
+					List<Type> requiredTypes = getTemplateRequiredTypes(param);
+					for (Type requiredType : requiredTypes) {
+						addFarthestOwnerType(requiredType, result);
+					}
 				}
-			}
 
-			for (Type type : operation.getRaisedExceptions()) {
-				List<Type> requiredTypes = getTemplateRequiredTypes(type);
-				for (Type requiredType : requiredTypes) {
-					addFarthestOwnerType(requiredType, result);
+				for (Type type : operation.getRaisedExceptions()) {
+					List<Type> requiredTypes = getTemplateRequiredTypes(type);
+					for (Type requiredType : requiredTypes) {
+						addFarthestOwnerType(requiredType, result);
+					}
 				}
 			}
 		}
@@ -351,10 +373,9 @@
 	/**
 	 * Retrieve the operations in the current classifier. For each
 	 * operation, collect types of its parameters.
-	 * This method thus finds types, on
-	 * which the signature depends.
+	 * This method thus finds types, on which the signature depends.
 	 * We check if operations and parameters must have or not have some stereotypes.
-	 *
+	 * 
 	 * @param current
 	 *            Classifier on which the operations are searched for
 	 * @param excludedOperationStereotypes
@@ -1371,4 +1392,23 @@
 		// default folder for generated code
 		return "src-gen/"; //$NON-NLS-1$
 	}
+
+	/**
+	 * Helper function that returns true, if a element should be
+	 * included in a list depending on its abstract state.
+	 * 
+	 * @param isAbstract
+	 *            whether an element is abstract
+	 * @param ia
+	 *            filtering enumeration
+	 * @return true, if element should be include
+	 */
+	private static boolean filterAbstract(boolean isAbstract, IncludeAbstract ia) {
+		if (ia == IncludeAbstract.ONLY_ABSTRACT) {
+			return isAbstract;
+		} else if (ia == IncludeAbstract.ONLY_NON_ABSTRACT) {
+			return !isAbstract;
+		}
+		return true;
+	}
 }
diff --git a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/utils/CppClassUtils.java b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/utils/CppClassUtils.java
index 088d7c7..279f4fa 100644
--- a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/utils/CppClassUtils.java
+++ b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/utils/CppClassUtils.java
@@ -20,6 +20,7 @@
 import org.eclipse.emf.common.util.UniqueEList;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.papyrus.designer.languages.common.base.GenUtils;
+import org.eclipse.papyrus.designer.languages.common.base.GenUtils.IncludeAbstract;
 import org.eclipse.papyrus.designer.languages.common.profile.Codegen.NoCodeGen;
 import org.eclipse.papyrus.designer.languages.cpp.profile.C_Cpp.ExternLibrary;
 import org.eclipse.papyrus.designer.languages.cpp.profile.C_Cpp.External;
@@ -115,7 +116,7 @@
 
 		// Include all declared classifiers in header
 		// Make sure to not include classifiers already included in header
-		usedClasses.addAll(declaredClassifiers(currentClass));
+		usedClasses.addAll(declaredClassifiers(currentClass, Position.FOR_BODY));
 		usedClasses.removeAll(includedClassifiers(currentClass));
 
 		// dependency relationships
@@ -128,13 +129,30 @@
 	}
 
 	/**
-	 * Calculate the list of classifiers that should be forward-declared in a header file
-	 * The background is that forward declarations could avoid inclusion cycles
-	 *
+	 * Calculate the list of classifiers that are declared by a class. It is
+	 * used to calculate the list of forward-declared types in a header file
+	 * as well as the types to use in a body file.
+	 * 
 	 * @param currentClass
+	 *            the current class
 	 * @return a list of classifiers (to be included)
 	 */
 	public static EList<Classifier> declaredClassifiers(Classifier currentClass) {
+		return declaredClassifiers(currentClass, Position.FOR_BOTH);
+	}
+
+	/**
+	 * Calculate the list of classifiers that are declared by a class. It is
+	 * used to calculate the list of forward-declared types in a header file
+	 * as well as the types to use in a body file.
+	 *
+	 * @param currentClass
+	 *            the current class
+	 * @param position
+	 *            whether the for a header, body file or both
+	 * @return a list of classifiers (to be included)
+	 */
+	public static EList<Classifier> declaredClassifiers(Classifier currentClass, Position position) {
 		EList<Classifier> usedClasses = new UniqueEList<Classifier>();
 
 		// List of excluded/included stereotypes
@@ -151,9 +169,11 @@
 		// class attributes dependencies (only ptr and ref and shared aggregation)
 		usedClasses.addAll(GenUtils.getTypesViaAttributes(currentClass, null, ptrRefStereotypes, false, false));
 		usedClasses.addAll(GenUtils.getTypesViaSharedAggregationAttributes(currentClass));
-		// operation parameters dependencies
-		usedClasses.addAll(GenUtils.getTypesViaOperations(currentClass));
-		usedClasses.removeAll(GenUtils.getTypesViaOperations(currentClass, noCodeGenStereotypes, inlineStereotypes, ptrRefStereotypes, null, true)); // Remove inline operation parameter types that have been included previously
+		// operation parameters dependencies, if creating list for a body, only include non abstract classes
+		IncludeAbstract ia = (position == Position.FOR_BODY) ? IncludeAbstract.ONLY_NON_ABSTRACT : IncludeAbstract.ALL_OPERATIONS;
+		usedClasses.addAll(GenUtils.getTypesViaOperations(currentClass, ia));
+		// Remove inline operation parameter types that have been included previously
+		usedClasses.removeAll(GenUtils.getTypesViaOperations(currentClass, noCodeGenStereotypes, inlineStereotypes, ptrRefStereotypes, null, true));
 		// no-specification opaque behavior dependencies
 		usedClasses.addAll(GenUtils.getTypesViaOpaqueBehaviors(currentClass));
 
@@ -201,7 +221,7 @@
 		EList<Classifier> usingClasses = new UniqueEList<Classifier>();
 		if (position == Position.FOR_HEADER || position == Position.FOR_BOTH) {
 			usingClasses.addAll(includedClassifiers(currentClass));
-			usingClasses.addAll(declaredClassifiers(currentClass));
+			usingClasses.addAll(declaredClassifiers(currentClass, Position.FOR_BOTH));
 		}
 		if (position == Position.FOR_BODY || position == Position.FOR_BOTH) {
 			usingClasses.addAll(includedImplementationClassifiers(currentClass));
diff --git a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/xtend/CppClassIncludeClassDeclaration.xtend b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/xtend/CppClassIncludeClassDeclaration.xtend
index ad76dc5..3c185cc 100644
--- a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/xtend/CppClassIncludeClassDeclaration.xtend
+++ b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.codegen/src/org/eclipse/papyrus/designer/languages/cpp/codegen/xtend/CppClassIncludeClassDeclaration.xtend
@@ -45,6 +45,9 @@
 		}
 	}
 
+	/**
+	 * AUtomatic include directives for the body (cpp) file
+	 */
 	static def CppClassAllIncludesDeclarationBody(Classifier classifier) {
 		cppClassAllIncludes(classifier, CppClassUtils.includedImplementationClassifiers(classifier))
 	}
@@ -129,6 +132,9 @@
 		return newList.filter[str|str !== null]
 	}
 
+	/**
+	 * Return automatic include directives for the header (hpp) file
+	 */
 	static def CppClassAllIncludes(Classifier clazz) {
 		cppClassAllIncludes(clazz, CppClassUtils.includedClassifiers(clazz))
 	}