Prechádzať zdrojové kódy

OPEN - issue YAKHMI-895: Create new SCT C++ Code generator
https://intern.itemis.de/jira/browse/YAKHMI-895

markus.muehlbrandt@gmail.com 12 rokov pred
rodič
commit
0e7d2a6a5d
30 zmenil súbory, kde vykonal 1902 pridanie a 53 odobranie
  1. 8 7
      plugins/org.yakindu.sct.generator.cpp/.classpath
  2. 34 34
      plugins/org.yakindu.sct.generator.cpp/.project
  3. 1 1
      plugins/org.yakindu.sct.generator.cpp/.settings/org.eclipse.core.resources.prefs
  4. 3 1
      plugins/org.yakindu.sct.generator.cpp/META-INF/MANIFEST.MF
  5. 24 0
      plugins/org.yakindu.sct.generator.cpp/plugin.xml
  6. 29 10
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java
  7. 51 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppGenerator.xtend
  8. 66 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/IStatemachine.xtend
  9. 66 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ITimedStatemachine.xtend
  10. 64 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ITimerService.xtend
  11. 83 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend
  12. 15 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Navigation.xtend
  13. 203 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend
  14. 46 0
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend
  15. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.CppGenerator.java._trace
  16. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.IStatemachine.java._trace
  17. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.ITimedStatemachine.java._trace
  18. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.ITimerService.java._trace
  19. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Naming.java._trace
  20. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Navigation.java._trace
  21. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.StatemachineHeader.java._trace
  22. BIN
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Types.java._trace
  23. 58 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/CppGenerator.java
  24. 123 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/IStatemachine.java
  25. 126 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/ITimedStatemachine.java
  26. 119 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/ITimerService.java
  27. 114 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Naming.java
  28. 24 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Navigation.java
  29. 576 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/StatemachineHeader.java
  30. 69 0
      plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Types.java

+ 8 - 7
plugins/org.yakindu.sct.generator.cpp/.classpath

@@ -1,7 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="xtend-gen"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 34 - 34
plugins/org.yakindu.sct.generator.cpp/.project

@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>org.yakindu.sct.generator.cpp</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.ManifestBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.SchemaBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.xtend.shared.ui.xtendBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.pde.PluginNature</nature>
-		<nature>org.eclipse.xtend.shared.ui.xtendXPandNature</nature>
-	</natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.yakindu.sct.generator.cpp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+	</natures>
+</projectDescription>

+ 1 - 1
plugins/org.yakindu.sct.generator.cpp/.settings/org.eclipse.core.resources.prefs

@@ -1,3 +1,3 @@
 eclipse.preferences.version=1
 encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
-encoding/<project>=Cp1252
+encoding/<project>=UTF-8

+ 3 - 1
plugins/org.yakindu.sct.generator.cpp/META-INF/MANIFEST.MF

@@ -18,7 +18,9 @@ Require-Bundle: org.yakindu.sct.model.sexec,
  org.eclipse.xtend.typesystem.emf,
  org.yakindu.sct.model.stext,
  org.yakindu.sct.generator.core;bundle-version="1.0.0",
- org.yakindu.sct.generator.genmodel;bundle-version="1.0.0"
+ org.yakindu.sct.generator.genmodel;bundle-version="1.0.0",
+ org.yakindu.sct.generator.c;bundle-version="2.1.0",
+ org.eclipse.xtext.xbase.lib;bundle-version="2.3.1"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Export-Package: org.yakindu.sct.generator.cpp,
  org.yakindu.sct.generator.cpp.templates

+ 24 - 0
plugins/org.yakindu.sct.generator.cpp/plugin.xml

@@ -2,6 +2,30 @@
 <?eclipse version="3.4"?>
 
 <plugin>
+   <extension
+         point="org.yakindu.sct.generator.core.generator">
+      <SCTGenerator
+            class="org.yakindu.sct.generator.cpp.CppCodeGenerator"
+            contentType="statechart"
+            description="YAKINDU SCT C++ Code Generator"
+            elementRefType="org.yakindu.sct.model.sgraph.Statechart"
+            id="yakindu::cpp"
+            name="YAKINDU SCT C++ Code Generator">
+         <FeatureLibrary
+               library_id="org.yakindu.generator.core.features">
+         </FeatureLibrary>
+         <FeatureLibrary
+               library_id="org.yakindu.generator.core.features.sctbase">
+         </FeatureLibrary>
+      </SCTGenerator>
+   </extension>
+   <extension
+         point="org.yakindu.sct.generator.core.extensions">
+      <ExtensionGeneratorMapping
+            fileExtension="sct"
+            generatorId="yakindu::cpp">
+      </ExtensionGeneratorMapping>
+   </extension>
    <!-- extension
          point="org.yakindu.sct.generator.core.generator">
       <SCTGenerator

+ 29 - 10
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java

@@ -10,26 +10,45 @@
  */
 package org.yakindu.sct.generator.cpp;
 
-import org.eclipse.core.resources.IProject;
-import org.yakindu.sct.generator.core.impl.AbstractXpandBasedCodeGenerator;
+import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
+
+import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
+import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
 
 /**
  * 
- * @author andreas muelder - Initial contribution and API
+ * @author Markus Mühlbrandt - Initial contribution and API
  * 
  */
-public class CppCodeGenerator extends AbstractXpandBasedCodeGenerator {
+public class CppCodeGenerator extends GenericJavaBasedGenerator {
 
 	@Override
-	public String getTemplatePath() {
-		return "org::yakindu::sct::generator::cpp::templates::Main::main";
+	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
+		CppGenerator delegate = getInjector(entry).getInstance(
+				CppGenerator.class);
+		ExecutionFlow flow = createExecutionFlow(statechart, entry);
+		if (isDumpSexec(entry)) {
+			dumpSexec(entry, flow);
+		}
+		delegate.generate(flow, entry, getFileSystemAccess(entry));
 	}
 
 	@Override
-	protected void createProject(IProject project, GeneratorEntry entry) {
-		super.createProject(project, entry);
-		// TODO: Set up right project description with C++ related stuff here...
+	protected Module createModule(GeneratorEntry entry) {
+		Module module = super.createModule(entry);
+		return Modules.override(module).with(new Module() {
+			public void configure(Binder binder) {
+				binder.bind(ICodegenTypeSystemAccess.class).to(
+						CTypeSystemAccess.class);
+			}
+		});
 	}
-
 }

+ 51 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppGenerator.xtend

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.cpp
+
+import com.google.inject.Inject
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.yakindu.sct.generator.c.StatemachineC
+import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sgraph.Statechart
+
+/**
+ * This is the CPP code generators main class. 
+ * 
+ * @author Markus Mühlbrandt
+ */
+class CppGenerator implements IExecutionFlowGenerator {
+	 
+	@Inject extension Types
+	@Inject extension ITimedStatemachine
+	@Inject extension ITimerService
+	@Inject extension IStatemachine
+	@Inject extension StatemachineHeader
+	@Inject extension StatemachineC
+
+	@Inject extension Navigation
+	
+	override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
+
+		flow.generateTypesHpp(flow.sourceElement as Statechart, fsa, entry)
+		
+		flow.generateIStatemachine(entry, fsa);
+		
+		if (flow.timed) {
+			flow.generateITimedStatemachine(entry, fsa);
+			flow.generateITimerService(entry, fsa);
+		}
+		
+		flow.generateStatemachineHeader(flow.sourceElement as Statechart, fsa, entry)
+		//flow.generateStatemachineC(flow.sourceElement as Statechart, fsa, entry)
+	}
+}

+ 66 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/IStatemachine.xtend

@@ -0,0 +1,66 @@
+/**
+  Copyright (c) 2013 committers of YAKINDU and others.
+  All rights reserved. This program and the accompanying materials
+  are made available under the terms of the Eclipse Public License v1.0
+  which accompanies this distribution, and is available at
+  http://www.eclipse.org/legal/epl-v10.html
+  Contributors:
+  	Markus Mühlbrandt - Initial contribution and API
+ */
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.eclipse.xtext.generator.IFileSystemAccess
+import com.google.inject.Inject
+import org.yakindu.sct.generator.c.GenmodelEntries
+
+class IStatemachine {
+	
+	@Inject
+	extension Naming
+	
+	@Inject
+	extension GenmodelEntries
+	
+	def generateIStatemachine(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
+		fsa.generateFile(iStatemachine.hpp, flow.content(entry) )
+	}
+	
+	def private content(ExecutionFlow it, GeneratorEntry entry) {
+		'''
+		«entry.licenseText»
+		
+		#ifndef «iStatemachine.define»_H_
+		#define «iStatemachine.define»_H_
+		
+		/*
+		 * Basic interface for statemachines.
+		 */
+		class IStatemachine {
+			public:
+				/*
+				* Initializes the statemachine. Use to init internal variables etc.
+				*/
+				virtual void init() = 0;
+			
+				/*
+				* Enters the statemachine. Sets the statemachine in a defined state.
+				*/
+				virtual void enter() = 0;
+			
+				/*
+				* Exits the statemachine. Leaves the statemachine with a defined state.
+				*/
+				virtual void exit() = 0;
+			
+				/*
+				* Start a run-to-completion cycle.
+				*/
+				virtual void runCycle() = 0;
+		};
+		
+		#endif /* «iStatemachine.define»_H_ */
+		'''
+	}
+}

+ 66 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ITimedStatemachine.xtend

@@ -0,0 +1,66 @@
+/**
+  Copyright (c) 2013 committers of YAKINDU and others.
+  All rights reserved. This program and the accompanying materials
+  are made available under the terms of the Eclipse Public License v1.0
+  which accompanies this distribution, and is available at
+  http://www.eclipse.org/legal/epl-v10.html
+  Contributors:
+  	Markus Mühlbrandt - Initial contribution and API
+ */
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.eclipse.xtext.generator.IFileSystemAccess
+import com.google.inject.Inject
+import org.yakindu.sct.generator.c.GenmodelEntries
+
+class ITimedStatemachine {
+	
+	@Inject
+	extension Naming
+	
+	@Inject
+	extension GenmodelEntries
+	
+	def generateITimedStatemachine(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
+		fsa.generateFile(iTimedStatemachine.hpp, flow.content(entry) )
+	}
+	
+	def private content(ExecutionFlow it, GeneratorEntry entry) {
+		'''
+		«entry.licenseText»
+		
+		#ifndef «iTimedStatemachine.define»_H_
+		#define «iTimedStatemachine.define»_H_
+		
+		#include "«typesModule.hpp»"
+		#include "«iTimerService.hpp»"
+		
+		/*
+		* Interface for state machines which use timed event triggers.
+		*/
+		class ITimedStatemachine {
+			public:
+				/*
+				* Set the ITimerService for the state machine. It must be set
+				* externally on a timed state machine before a run cycle can be correct
+				* executed.
+				*/
+				virtual void setTimerService(ITimerService* timerService) = 0;
+				
+				/*
+				* Returns the currently used timer service.
+				*/
+				virtual ITimerService* getTimerService() = 0;
+				
+				/*
+				* Callback method if a time event occurred.
+				*/
+				virtual void raiseTimeEvent(sc_eventid event) = 0;
+		};
+		
+		#endif /* «iTimedStatemachine.define»_H_ */
+		'''
+	}
+}

+ 64 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ITimerService.xtend

@@ -0,0 +1,64 @@
+/**
+  Copyright (c) 2013 committers of YAKINDU and others.
+  All rights reserved. This program and the accompanying materials
+  are made available under the terms of the Eclipse Public License v1.0
+  which accompanies this distribution, and is available at
+  http://www.eclipse.org/legal/epl-v10.html
+  Contributors:
+  	Markus Mühlbrandt - Initial contribution and API
+ */
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.eclipse.xtext.generator.IFileSystemAccess
+import com.google.inject.Inject
+import org.yakindu.sct.generator.c.GenmodelEntries
+
+class ITimerService {
+	
+	@Inject
+	extension Naming
+	
+	@Inject
+	extension GenmodelEntries
+	
+	def generateITimerService(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
+		fsa.generateFile(iTimerService.hpp, flow.content(entry) )
+	}
+	
+	def private content(ExecutionFlow it, GeneratorEntry entry) {
+		'''
+		«entry.licenseText»
+		
+		#ifndef «iTimerService.define»_H_
+		#define «iTimerService.define»_H_
+		
+		#include "«iTimedStatemachine.hpp»"
+		
+		/*
+		 * Basic interface for statemachines.
+		 */
+		class ITimerService {
+			public:
+				/*
+				 * Starts the timing for a time event.
+				 */ 
+				virtual void setTimer(ITimedStatemachine* statemachine, sc_eventid event, sc_integer time, sc_boolean isPeriodic) = 0;
+				
+				/*
+				 * Unsets the given time event.
+				 */
+				virtual void resetTimer(ITimedStatemachine* statemachine, sc_eventid event) = 0;
+			
+				/*
+				 * Cancel timer service. Use this to end possible timing threads and free
+				 * memory resources.
+				 */
+				virtual void cancel() = 0;
+		};
+		
+		#endif /* «iTimerService.define»_H_ */
+		'''
+	}
+}

+ 83 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Naming.xtend

@@ -0,0 +1,83 @@
+/**
+  Copyright (c) 2013 committers of YAKINDU and others.
+  All rights reserved. This program and the accompanying materials
+  are made available under the terms of the Eclipse Public License v1.0
+  which accompanies this distribution, and is available at
+  http://www.eclipse.org/legal/epl-v10.html
+  Contributors:
+  	Markus Mühlbrandt - Initial contribution and API
+ */
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+
+class Naming extends org.yakindu.sct.generator.c.Naming {
+	
+	def hpp(String it) { it + ".hpp" }
+	def cpp(String it) { it + ".cpp" }
+	
+	def abstractModule(ExecutionFlow it) {
+		'I'+module	
+	}
+	
+	def iStatemachine() {
+		'IStatemachine'
+	}
+	
+	def iTimedStatemachine() {
+		'ITimedStatemachine'
+	}
+	
+	def iTimerService() {
+		'ITimerService'
+	}
+	
+	def timeEvent() {
+		'TimeEvent'
+	}
+	
+	def String getInterfaceName(InterfaceScope it) {  
+		if (name != null) {
+			return "SCI" + name.toFirstUpper()
+		}
+		else {
+			return "SCInterface";
+		}
+	}
+	
+	def String getInterfaceOperationCallbackName(InterfaceScope it) {
+		interfaceName + "OperationCallback"
+	}
+	
+	def String getInternalOperationCallbackName() {
+		"InternalOperationCallback"
+	}
+	
+	override asFunction(OperationDefinition it) {
+		name.asIdentifier.toFirstLower	
+	}
+	
+	override asRaiser(EventDefinition it) {
+		'raise_' + name.asIdentifier.toFirstLower	
+	}
+	
+	override asRaised(EventDefinition it) {
+		'isRaised_' + name.asIdentifier.toFirstLower	
+	}
+	
+	override asGetter(EventDefinition it) {
+		'get_' + name.asIdentifier.toFirstLower	+ '_value'
+	}
+	
+	override asGetter(VariableDefinition it) {
+		'get_' + name.asIdentifier.toFirstLower	
+	}
+	
+	override asSetter(VariableDefinition it) {
+		'set_' + name.asIdentifier.toFirstLower	
+	}
+}

+ 15 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Navigation.xtend

@@ -0,0 +1,15 @@
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+
+class Navigation extends org.yakindu.sct.generator.c.Navigation {
+	
+	def operations(Scope it) {
+		declarations.filter(typeof(OperationDefinition));
+	}
+	
+	def hasOperations(Scope it) {
+		!operations.isEmpty;
+	}
+}

+ 203 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineHeader.xtend

@@ -0,0 +1,203 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.cpp
+
+import com.google.inject.Inject
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.yakindu.base.types.Parameter
+import org.yakindu.sct.generator.c.GenmodelEntries
+import org.yakindu.sct.generator.c.Statemachine
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.sgraph.Statechart
+import org.yakindu.sct.model.stext.stext.Direction
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+
+class StatemachineHeader extends Statemachine {
+	
+	@Inject extension Naming cNaming
+	@Inject extension Navigation
+	@Inject extension ICodegenTypeSystemAccess
+	@Inject extension GenmodelEntries
+	
+	def generateStatemachineHeader(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
+		 fsa.generateFile(flow.module.hpp, flow.statemachineHContent(entry) )
+	}
+	
+	override statemachineHContent(ExecutionFlow it,  GeneratorEntry entry) '''
+		«entry.licenseText»
+		
+		#ifndef «module.define»_H_
+		#define «module.define»_H_
+
+		#include "«typesModule.hpp»"
+		#include "«iStatemachine.hpp»"
+		«IF timed»
+			#include "«iTimedStatemachine.hpp»"
+		«ENDIF»
+
+		/*! \file Header of the state machine '«name»'.
+		*/
+		
+		class «module» : «interfaceExtensions» {
+			
+			public:
+			
+				«FOR s : it.scopes»«s.createScope(entry)»«ENDFOR»
+				
+				«FOR s : it.scopes.filter( typeof(InternalScope) )»
+					«s.scopeFunctionPrototypes»
+				«ENDFOR»
+				
+				/*! Checks if the specified state is active. */
+				virtual sc_boolean «nameOfIsActiveFunction»(«statesEnumType» state) = 0;
+			
+			private:
+				«statesEnumDecl»
+				
+				«statemachineTypeDecl»
+		}
+		
+		#endif /* «module.define»_H_ */
+	'''
+	
+	def getInterfaceExtensions(ExecutionFlow flow) {
+
+		var String interfaces = "";
+
+		if (flow.timed) {
+			interfaces = interfaces + "public " +iTimedStatemachine+", "
+		}
+
+		interfaces = interfaces + "public " + iStatemachine
+		
+		return interfaces;
+	}
+	
+	def private createScope(Scope scope, GeneratorEntry entry) {
+		switch scope {
+			InterfaceScope: scope.createScope(entry)
+			InternalScope: scope.createScope
+		}
+	}
+	
+	def private createScope(InterfaceScope scope, GeneratorEntry entry)
+	'''
+		«scope.createInterface(entry)»
+«««		«scope.createListenerInterface(entry)»
+		«scope.createOperationCallbackInterface»
+		
+		«scope.interfaceName»* get«scope.interfaceName»();
+		
+	'''
+	
+	def private createInterface(InterfaceScope scope, GeneratorEntry entry)
+	'''
+		//! Inner class for statechart «scope.interfaceName» interface scope.
+		class «scope.interfaceName» {
+			
+			public:
+				«FOR d : scope.declarations»
+					«d.functionPrototypes»
+				«ENDFOR»
+				
+			private:
+				«FOR d : scope.declarations»
+				 «d.structDeclaration»
+				«ENDFOR»
+		};
+	'''
+	
+	def private createScope(InternalScope scope) {
+		'''
+		«IF scope.hasOperations()»
+			class «internalOperationCallbackName» {
+				«FOR operation : scope.operations»
+					virtual «operation.asFunction»() = 0;
+				«ENDFOR»
+			}
+			
+			virtual void set«internalOperationCallbackName»(«internalOperationCallbackName»* operationCallback) = 0;
+		«ENDIF»
+		'''
+	}
+	
+	def createOperationCallbackInterface(InterfaceScope scope) {
+		'''
+		«IF scope.hasOperations»
+			
+			public interface «scope.getInterfaceOperationCallbackName()» {
+			«FOR operation : scope.operations»
+				virtual «operation.signature» = 0;
+			«ENDFOR»
+			}
+		«ENDIF»
+		'''
+	}
+	
+	def private signature(OperationDefinition it)
+	'''
+		«type.targetLanguageName» «name.asEscapedIdentifier»(«FOR parameter : parameters SEPARATOR ', '»«parameter.type.targetLanguageName» «parameter.identifier»«ENDFOR»)
+	'''
+	
+	def private identifier(Parameter parameter) {
+		if (parameter.name.isCKeyword()) {
+			return parameter.name + "Arg"
+		}
+		else {
+			parameter.name
+		}
+	}
+
+	override statemachineTypeDecl(ExecutionFlow it) '''
+		//! the maximum number of orthogonal states defines the dimension of the state configuration vector.
+		#define «type.toUpperCase»_MAX_ORTHOGONAL_STATES «stateVector.size»
+		«IF hasHistory»
+		//! dimension of the state configuration vector for history states
+		#define «type.toUpperCase»_MAX_HISTORY_STATES «historyVector.size»«ENDIF»
+		
+		«statesEnumType» stateConfVector[«type.toUpperCase»_MAX_ORTHOGONAL_STATES];
+		«IF hasHistory»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
+		sc_ushort stateConfVectorPosition; 
+	'''
+
+	override dispatch functionPrototypes(EventDefinition it) '''
+		«IF direction == Direction::IN»
+		/*! Raises the in event '«name»' that is defined in the «scope.scopeDescription». */ 
+		void «asRaiser»(«valueParams»);
+		
+		«ELSE»
+			/*! Checks if the out event '«name»' that is defined in the «scope.scopeDescription» has been raised. */ 
+			sc_boolean «asRaised»();
+			
+			«IF hasValue»
+				/*! Gets the value of the out event '«name»' that is defined in the «scope.scopeDescription». */ 
+				«type.targetLanguageName» «asGetter»();
+				
+			«ENDIF»
+		«ENDIF»
+	'''
+
+	override dispatch functionPrototypes(VariableDefinition it) '''
+		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
+		«type.targetLanguageName» «it.asGetter»();
+		«IF ! readonly »
+			/*! Sets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
+			void «asSetter»(«type.targetLanguageName» value);
+		«ENDIF»
+	'''
+}

+ 46 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend

@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	Markus Mühlbrnadt - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.cpp
+
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgraph.Statechart
+import org.eclipse.xtext.generator.IFileSystemAccess
+import com.google.inject.Inject
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.generator.c.GenmodelEntries
+
+class Types {
+	
+	@Inject extension Naming
+	@Inject extension GenmodelEntries
+	 
+	def generateTypesHpp(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
+		 fsa.generateFile(flow.typesModule.hpp, flow.typesHContent(entry))
+	}
+	
+	def typesHContent(ExecutionFlow it, GeneratorEntry entry) '''
+		«entry.licenseText»
+		
+		#ifndef «typesModule.define»_H_
+		#define «typesModule.define»_H_
+		
+		#include <string>
+		
+		typedef unsigned char	sc_ushort;
+		typedef int				sc_integer;  
+		typedef double			sc_real;
+		typedef string			sc_string;
+		
+		typedef void*			sc_eventid;
+		
+		#endif /* «typesModule.define»_H_ */
+	'''
+}

BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.CppGenerator.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.IStatemachine.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.ITimedStatemachine.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.ITimerService.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Naming.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Navigation.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.StatemachineHeader.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Types.java._trace


+ 58 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/CppGenerator.java

@@ -0,0 +1,58 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.inject.Inject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.sct.generator.c.StatemachineC;
+import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator;
+import org.yakindu.sct.generator.cpp.IStatemachine;
+import org.yakindu.sct.generator.cpp.ITimedStatemachine;
+import org.yakindu.sct.generator.cpp.ITimerService;
+import org.yakindu.sct.generator.cpp.Navigation;
+import org.yakindu.sct.generator.cpp.StatemachineHeader;
+import org.yakindu.sct.generator.cpp.Types;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+/**
+ * This is the CPP code generators main class.
+ * 
+ * @author Markus Mühlbrandt
+ */
+@SuppressWarnings("all")
+public class CppGenerator implements IExecutionFlowGenerator {
+  @Inject
+  private Types _types;
+  
+  @Inject
+  private ITimedStatemachine _iTimedStatemachine;
+  
+  @Inject
+  private ITimerService _iTimerService;
+  
+  @Inject
+  private IStatemachine _iStatemachine;
+  
+  @Inject
+  private StatemachineHeader _statemachineHeader;
+  
+  @Inject
+  private StatemachineC _statemachineC;
+  
+  @Inject
+  private Navigation _navigation;
+  
+  public void generate(final ExecutionFlow flow, final GeneratorEntry entry, final IFileSystemAccess fsa) {
+    EObject _sourceElement = flow.getSourceElement();
+    this._types.generateTypesHpp(flow, ((Statechart) _sourceElement), fsa, entry);
+    this._iStatemachine.generateIStatemachine(flow, entry, fsa);
+    boolean _isTimed = this._navigation.isTimed(flow);
+    if (_isTimed) {
+      this._iTimedStatemachine.generateITimedStatemachine(flow, entry, fsa);
+      this._iTimerService.generateITimerService(flow, entry, fsa);
+    }
+    EObject _sourceElement_1 = flow.getSourceElement();
+    this._statemachineHeader.generateStatemachineHeader(flow, ((Statechart) _sourceElement_1), fsa, entry);
+  }
+}

+ 123 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/IStatemachine.java

@@ -0,0 +1,123 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.inject.Inject;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.sct.generator.c.GenmodelEntries;
+import org.yakindu.sct.generator.cpp.Naming;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+@SuppressWarnings("all")
+public class IStatemachine {
+  @Inject
+  private Naming _naming;
+  
+  @Inject
+  private GenmodelEntries _genmodelEntries;
+  
+  public void generateIStatemachine(final ExecutionFlow flow, final GeneratorEntry entry, final IFileSystemAccess fsa) {
+    String _iStatemachine = this._naming.iStatemachine();
+    String _hpp = this._naming.hpp(_iStatemachine);
+    CharSequence _content = this.content(flow, entry);
+    fsa.generateFile(_hpp, _content);
+  }
+  
+  private CharSequence content(final ExecutionFlow it, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _licenseText = this._genmodelEntries.getLicenseText(entry);
+    _builder.append(_licenseText, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#ifndef ");
+    String _iStatemachine = this._naming.iStatemachine();
+    String _define = this._naming.define(_iStatemachine);
+    _builder.append(_define, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#define ");
+    String _iStatemachine_1 = this._naming.iStatemachine();
+    String _define_1 = this._naming.define(_iStatemachine_1);
+    _builder.append(_define_1, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append(" ");
+    _builder.append("* Basic interface for statemachines.");
+    _builder.newLine();
+    _builder.append(" ");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("class IStatemachine {");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("public:");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Initializes the statemachine. Use to init internal variables etc.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void init() = 0;");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Enters the statemachine. Sets the statemachine in a defined state.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void enter() = 0;");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Exits the statemachine. Leaves the statemachine with a defined state.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void exit() = 0;");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Start a run-to-completion cycle.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void runCycle() = 0;");
+    _builder.newLine();
+    _builder.append("};");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("#endif /* ");
+    String _iStatemachine_2 = this._naming.iStatemachine();
+    String _define_2 = this._naming.define(_iStatemachine_2);
+    _builder.append(_define_2, "");
+    _builder.append("_H_ */");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+}

+ 126 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/ITimedStatemachine.java

@@ -0,0 +1,126 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.inject.Inject;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.sct.generator.c.GenmodelEntries;
+import org.yakindu.sct.generator.cpp.Naming;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+@SuppressWarnings("all")
+public class ITimedStatemachine {
+  @Inject
+  private Naming _naming;
+  
+  @Inject
+  private GenmodelEntries _genmodelEntries;
+  
+  public void generateITimedStatemachine(final ExecutionFlow flow, final GeneratorEntry entry, final IFileSystemAccess fsa) {
+    String _iTimedStatemachine = this._naming.iTimedStatemachine();
+    String _hpp = this._naming.hpp(_iTimedStatemachine);
+    CharSequence _content = this.content(flow, entry);
+    fsa.generateFile(_hpp, _content);
+  }
+  
+  private CharSequence content(final ExecutionFlow it, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _licenseText = this._genmodelEntries.getLicenseText(entry);
+    _builder.append(_licenseText, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#ifndef ");
+    String _iTimedStatemachine = this._naming.iTimedStatemachine();
+    String _define = this._naming.define(_iTimedStatemachine);
+    _builder.append(_define, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#define ");
+    String _iTimedStatemachine_1 = this._naming.iTimedStatemachine();
+    String _define_1 = this._naming.define(_iTimedStatemachine_1);
+    _builder.append(_define_1, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#include \"");
+    String _typesModule = this._naming.typesModule(it);
+    String _hpp = this._naming.hpp(_typesModule);
+    _builder.append(_hpp, "");
+    _builder.append("\"");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#include \"");
+    String _iTimerService = this._naming.iTimerService();
+    String _hpp_1 = this._naming.hpp(_iTimerService);
+    _builder.append(_hpp_1, "");
+    _builder.append("\"");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("* Interface for state machines which use timed event triggers.");
+    _builder.newLine();
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("class ITimedStatemachine {");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("public:");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Set the ITimerService for the state machine. It must be set");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* externally on a timed state machine before a run cycle can be correct");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* executed.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void setTimerService(ITimerService* timerService) = 0;");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Returns the currently used timer service.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual ITimerService* getTimerService() = 0;");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("* Callback method if a time event occurred.");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void raiseTimeEvent(sc_eventid event) = 0;");
+    _builder.newLine();
+    _builder.append("};");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("#endif /* ");
+    String _iTimedStatemachine_2 = this._naming.iTimedStatemachine();
+    String _define_2 = this._naming.define(_iTimedStatemachine_2);
+    _builder.append(_define_2, "");
+    _builder.append("_H_ */");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+}

+ 119 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/ITimerService.java

@@ -0,0 +1,119 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.inject.Inject;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.sct.generator.c.GenmodelEntries;
+import org.yakindu.sct.generator.cpp.Naming;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+@SuppressWarnings("all")
+public class ITimerService {
+  @Inject
+  private Naming _naming;
+  
+  @Inject
+  private GenmodelEntries _genmodelEntries;
+  
+  public void generateITimerService(final ExecutionFlow flow, final GeneratorEntry entry, final IFileSystemAccess fsa) {
+    String _iTimerService = this._naming.iTimerService();
+    String _hpp = this._naming.hpp(_iTimerService);
+    CharSequence _content = this.content(flow, entry);
+    fsa.generateFile(_hpp, _content);
+  }
+  
+  private CharSequence content(final ExecutionFlow it, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _licenseText = this._genmodelEntries.getLicenseText(entry);
+    _builder.append(_licenseText, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#ifndef ");
+    String _iTimerService = this._naming.iTimerService();
+    String _define = this._naming.define(_iTimerService);
+    _builder.append(_define, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#define ");
+    String _iTimerService_1 = this._naming.iTimerService();
+    String _define_1 = this._naming.define(_iTimerService_1);
+    _builder.append(_define_1, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#include \"");
+    String _iTimedStatemachine = this._naming.iTimedStatemachine();
+    String _hpp = this._naming.hpp(_iTimedStatemachine);
+    _builder.append(_hpp, "");
+    _builder.append("\"");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append(" ");
+    _builder.append("* Basic interface for statemachines.");
+    _builder.newLine();
+    _builder.append(" ");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("class ITimerService {");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("public:");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("* Starts the timing for a time event.");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("*/ ");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void setTimer(ITimedStatemachine* statemachine, sc_eventid event, sc_integer time, sc_boolean isPeriodic) = 0;");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("* Unsets the given time event.");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void resetTimer(ITimedStatemachine* statemachine, sc_eventid event) = 0;");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("* Cancel timer service. Use this to end possible timing threads and free");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("* memory resources.");
+    _builder.newLine();
+    _builder.append("\t\t ");
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual void cancel() = 0;");
+    _builder.newLine();
+    _builder.append("};");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("#endif /* ");
+    String _iTimerService_2 = this._naming.iTimerService();
+    String _define_2 = this._naming.define(_iTimerService_2);
+    _builder.append(_define_2, "");
+    _builder.append("_H_ */");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+}

+ 114 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Naming.java

@@ -0,0 +1,114 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.common.base.Objects;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class Naming extends org.yakindu.sct.generator.c.Naming {
+  public String hpp(final String it) {
+    String _plus = (it + ".hpp");
+    return _plus;
+  }
+  
+  public String cpp(final String it) {
+    String _plus = (it + ".cpp");
+    return _plus;
+  }
+  
+  public String abstractModule(final ExecutionFlow it) {
+    String _module = this.module(it);
+    String _plus = ("I" + _module);
+    return _plus;
+  }
+  
+  public String iStatemachine() {
+    return "IStatemachine";
+  }
+  
+  public String iTimedStatemachine() {
+    return "ITimedStatemachine";
+  }
+  
+  public String iTimerService() {
+    return "ITimerService";
+  }
+  
+  public String timeEvent() {
+    return "TimeEvent";
+  }
+  
+  public String getInterfaceName(final InterfaceScope it) {
+    String _name = it.getName();
+    boolean _notEquals = (!Objects.equal(_name, null));
+    if (_notEquals) {
+      String _name_1 = it.getName();
+      String _firstUpper = StringExtensions.toFirstUpper(_name_1);
+      return ("SCI" + _firstUpper);
+    } else {
+      return "SCInterface";
+    }
+  }
+  
+  public String getInterfaceOperationCallbackName(final InterfaceScope it) {
+    String _interfaceName = this.getInterfaceName(it);
+    String _plus = (_interfaceName + "OperationCallback");
+    return _plus;
+  }
+  
+  public String getInternalOperationCallbackName() {
+    return "InternalOperationCallback";
+  }
+  
+  public String asFunction(final OperationDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    return _firstLower;
+  }
+  
+  public String asRaiser(final EventDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    String _plus = ("raise_" + _firstLower);
+    return _plus;
+  }
+  
+  public String asRaised(final EventDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    String _plus = ("isRaised_" + _firstLower);
+    return _plus;
+  }
+  
+  public String asGetter(final EventDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    String _plus = ("get_" + _firstLower);
+    String _plus_1 = (_plus + "_value");
+    return _plus_1;
+  }
+  
+  public String asGetter(final VariableDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    String _plus = ("get_" + _firstLower);
+    return _plus;
+  }
+  
+  public String asSetter(final VariableDefinition it) {
+    String _name = it.getName();
+    String _asIdentifier = this.asIdentifier(_name);
+    String _firstLower = StringExtensions.toFirstLower(_asIdentifier);
+    String _plus = ("set_" + _firstLower);
+    return _plus;
+  }
+}

+ 24 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Navigation.java

@@ -0,0 +1,24 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.common.collect.Iterables;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+
+@SuppressWarnings("all")
+public class Navigation extends org.yakindu.sct.generator.c.Navigation {
+  public Iterable<OperationDefinition> operations(final Scope it) {
+    EList<Declaration> _declarations = it.getDeclarations();
+    Iterable<OperationDefinition> _filter = Iterables.<OperationDefinition>filter(_declarations, OperationDefinition.class);
+    return _filter;
+  }
+  
+  public boolean hasOperations(final Scope it) {
+    Iterable<OperationDefinition> _operations = this.operations(it);
+    boolean _isEmpty = IterableExtensions.isEmpty(_operations);
+    boolean _not = (!_isEmpty);
+    return _not;
+  }
+}

+ 576 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/StatemachineHeader.java

@@ -0,0 +1,576 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import java.util.Arrays;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.base.types.Parameter;
+import org.yakindu.base.types.Type;
+import org.yakindu.sct.generator.c.GenmodelEntries;
+import org.yakindu.sct.generator.c.Statemachine;
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
+import org.yakindu.sct.generator.cpp.Naming;
+import org.yakindu.sct.generator.cpp.Navigation;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.Direction;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class StatemachineHeader extends Statemachine {
+  @Inject
+  private Naming cNaming;
+  
+  @Inject
+  private Navigation _navigation;
+  
+  @Inject
+  private ICodegenTypeSystemAccess _iCodegenTypeSystemAccess;
+  
+  @Inject
+  private GenmodelEntries _genmodelEntries;
+  
+  public void generateStatemachineHeader(final ExecutionFlow flow, final Statechart sc, final IFileSystemAccess fsa, final GeneratorEntry entry) {
+    String _module = this.cNaming.module(flow);
+    String _hpp = this.cNaming.hpp(_module);
+    CharSequence _statemachineHContent = this.statemachineHContent(flow, entry);
+    fsa.generateFile(_hpp, _statemachineHContent);
+  }
+  
+  public CharSequence statemachineHContent(final ExecutionFlow it, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _licenseText = this._genmodelEntries.getLicenseText(entry);
+    _builder.append(_licenseText, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#ifndef ");
+    String _module = this.cNaming.module(it);
+    String _define = this.cNaming.define(_module);
+    _builder.append(_define, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#define ");
+    String _module_1 = this.cNaming.module(it);
+    String _define_1 = this.cNaming.define(_module_1);
+    _builder.append(_define_1, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#include \"");
+    String _typesModule = this.cNaming.typesModule(it);
+    String _hpp = this.cNaming.hpp(_typesModule);
+    _builder.append(_hpp, "");
+    _builder.append("\"");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#include \"");
+    String _iStatemachine = this.cNaming.iStatemachine();
+    String _hpp_1 = this.cNaming.hpp(_iStatemachine);
+    _builder.append(_hpp_1, "");
+    _builder.append("\"");
+    _builder.newLineIfNotEmpty();
+    {
+      boolean _isTimed = this._navigation.isTimed(it);
+      if (_isTimed) {
+        _builder.append("#include \"");
+        String _iTimedStatemachine = this.cNaming.iTimedStatemachine();
+        String _hpp_2 = this.cNaming.hpp(_iTimedStatemachine);
+        _builder.append(_hpp_2, "");
+        _builder.append("\"");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    _builder.newLine();
+    _builder.append("/*! \\file Header of the state machine \'");
+    String _name = it.getName();
+    _builder.append(_name, "");
+    _builder.append("\'.");
+    _builder.newLineIfNotEmpty();
+    _builder.append("*/");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("class ");
+    String _module_2 = this.cNaming.module(it);
+    _builder.append(_module_2, "");
+    _builder.append(" : ");
+    String _interfaceExtensions = this.getInterfaceExtensions(it);
+    _builder.append(_interfaceExtensions, "");
+    _builder.append(" {");
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("public:");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    {
+      EList<Scope> _scopes = it.getScopes();
+      for(final Scope s : _scopes) {
+        CharSequence _createScope = this.createScope(s, entry);
+        _builder.append(_createScope, "		");
+      }
+    }
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t\t");
+    _builder.newLine();
+    {
+      EList<Scope> _scopes_1 = it.getScopes();
+      Iterable<InternalScope> _filter = Iterables.<InternalScope>filter(_scopes_1, InternalScope.class);
+      for(final InternalScope s_1 : _filter) {
+        _builder.append("\t\t");
+        CharSequence _scopeFunctionPrototypes = this.scopeFunctionPrototypes(s_1);
+        _builder.append(_scopeFunctionPrototypes, "		");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("/*! Checks if the specified state is active. */");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("virtual sc_boolean ");
+    String _nameOfIsActiveFunction = this.cNaming.nameOfIsActiveFunction(it);
+    _builder.append(_nameOfIsActiveFunction, "		");
+    _builder.append("(");
+    String _statesEnumType = this.cNaming.statesEnumType(it);
+    _builder.append(_statesEnumType, "		");
+    _builder.append(" state) = 0;");
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("private:");
+    _builder.newLine();
+    _builder.append("\t\t");
+    CharSequence _statesEnumDecl = this.statesEnumDecl(it);
+    _builder.append(_statesEnumDecl, "		");
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t\t");
+    CharSequence _statemachineTypeDecl = this.statemachineTypeDecl(it);
+    _builder.append(_statemachineTypeDecl, "		");
+    _builder.newLineIfNotEmpty();
+    _builder.append("}");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("#endif /* ");
+    String _module_3 = this.cNaming.module(it);
+    String _define_2 = this.cNaming.define(_module_3);
+    _builder.append(_define_2, "");
+    _builder.append("_H_ */");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+  
+  public String getInterfaceExtensions(final ExecutionFlow flow) {
+    String interfaces = "";
+    boolean _isTimed = this._navigation.isTimed(flow);
+    if (_isTimed) {
+      String _plus = (interfaces + "public ");
+      String _iTimedStatemachine = this.cNaming.iTimedStatemachine();
+      String _plus_1 = (_plus + _iTimedStatemachine);
+      String _plus_2 = (_plus_1 + ", ");
+      interfaces = _plus_2;
+    }
+    String _plus_3 = (interfaces + "public ");
+    String _iStatemachine = this.cNaming.iStatemachine();
+    String _plus_4 = (_plus_3 + _iStatemachine);
+    interfaces = _plus_4;
+    return interfaces;
+  }
+  
+  private CharSequence createScope(final Scope scope, final GeneratorEntry entry) {
+    CharSequence _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (scope instanceof InterfaceScope) {
+        final InterfaceScope _interfaceScope = (InterfaceScope)scope;
+        _matched=true;
+        CharSequence _createScope = this.createScope(_interfaceScope, entry);
+        _switchResult = _createScope;
+      }
+    }
+    if (!_matched) {
+      if (scope instanceof InternalScope) {
+        final InternalScope _internalScope = (InternalScope)scope;
+        _matched=true;
+        CharSequence _createScope = this.createScope(_internalScope);
+        _switchResult = _createScope;
+      }
+    }
+    return _switchResult;
+  }
+  
+  private CharSequence createScope(final InterfaceScope scope, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    CharSequence _createInterface = this.createInterface(scope, entry);
+    _builder.append(_createInterface, "");
+    _builder.newLineIfNotEmpty();
+    CharSequence _createOperationCallbackInterface = this.createOperationCallbackInterface(scope);
+    _builder.append(_createOperationCallbackInterface, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    String _interfaceName = this.cNaming.getInterfaceName(scope);
+    _builder.append(_interfaceName, "");
+    _builder.append("* get");
+    String _interfaceName_1 = this.cNaming.getInterfaceName(scope);
+    _builder.append(_interfaceName_1, "");
+    _builder.append("();");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    return _builder;
+  }
+  
+  private CharSequence createInterface(final InterfaceScope scope, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    _builder.append("//! Inner class for statechart ");
+    String _interfaceName = this.cNaming.getInterfaceName(scope);
+    _builder.append(_interfaceName, "");
+    _builder.append(" interface scope.");
+    _builder.newLineIfNotEmpty();
+    _builder.append("class ");
+    String _interfaceName_1 = this.cNaming.getInterfaceName(scope);
+    _builder.append(_interfaceName_1, "");
+    _builder.append(" {");
+    _builder.newLineIfNotEmpty();
+    _builder.append("\t");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("public:");
+    _builder.newLine();
+    {
+      EList<Declaration> _declarations = scope.getDeclarations();
+      for(final Declaration d : _declarations) {
+        _builder.append("\t\t");
+        CharSequence _functionPrototypes = this.functionPrototypes(d);
+        _builder.append(_functionPrototypes, "		");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    _builder.append("\t\t");
+    _builder.newLine();
+    _builder.append("\t");
+    _builder.append("private:");
+    _builder.newLine();
+    {
+      EList<Declaration> _declarations_1 = scope.getDeclarations();
+      for(final Declaration d_1 : _declarations_1) {
+        _builder.append("\t\t");
+        CharSequence _structDeclaration = this.structDeclaration(d_1);
+        _builder.append(_structDeclaration, "		");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    _builder.append("};");
+    _builder.newLine();
+    return _builder;
+  }
+  
+  private CharSequence createScope(final InternalScope scope) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      boolean _hasOperations = this._navigation.hasOperations(scope);
+      if (_hasOperations) {
+        _builder.append("class ");
+        String _internalOperationCallbackName = this.cNaming.getInternalOperationCallbackName();
+        _builder.append(_internalOperationCallbackName, "");
+        _builder.append(" {");
+        _builder.newLineIfNotEmpty();
+        {
+          Iterable<OperationDefinition> _operations = this._navigation.operations(scope);
+          for(final OperationDefinition operation : _operations) {
+            _builder.append("\t");
+            _builder.append("virtual ");
+            String _asFunction = this.cNaming.asFunction(operation);
+            _builder.append(_asFunction, "	");
+            _builder.append("() = 0;");
+            _builder.newLineIfNotEmpty();
+          }
+        }
+        _builder.append("}");
+        _builder.newLine();
+        _builder.newLine();
+        _builder.append("virtual void set");
+        String _internalOperationCallbackName_1 = this.cNaming.getInternalOperationCallbackName();
+        _builder.append(_internalOperationCallbackName_1, "");
+        _builder.append("(");
+        String _internalOperationCallbackName_2 = this.cNaming.getInternalOperationCallbackName();
+        _builder.append(_internalOperationCallbackName_2, "");
+        _builder.append("* operationCallback) = 0;");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    return _builder;
+  }
+  
+  public CharSequence createOperationCallbackInterface(final InterfaceScope scope) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      boolean _hasOperations = this._navigation.hasOperations(scope);
+      if (_hasOperations) {
+        _builder.newLine();
+        _builder.append("public interface ");
+        String _interfaceOperationCallbackName = this.cNaming.getInterfaceOperationCallbackName(scope);
+        _builder.append(_interfaceOperationCallbackName, "");
+        _builder.append(" {");
+        _builder.newLineIfNotEmpty();
+        {
+          Iterable<OperationDefinition> _operations = this._navigation.operations(scope);
+          for(final OperationDefinition operation : _operations) {
+            _builder.append("virtual ");
+            CharSequence _signature = this.signature(operation);
+            _builder.append(_signature, "");
+            _builder.append(" = 0;");
+            _builder.newLineIfNotEmpty();
+          }
+        }
+        _builder.append("}");
+        _builder.newLine();
+      }
+    }
+    return _builder;
+  }
+  
+  private CharSequence signature(final OperationDefinition it) {
+    StringConcatenation _builder = new StringConcatenation();
+    Type _type = it.getType();
+    String _targetLanguageName = this._iCodegenTypeSystemAccess.getTargetLanguageName(_type);
+    _builder.append(_targetLanguageName, "");
+    _builder.append(" ");
+    String _name = it.getName();
+    String _asEscapedIdentifier = this.cNaming.asEscapedIdentifier(_name);
+    _builder.append(_asEscapedIdentifier, "");
+    _builder.append("(");
+    {
+      EList<Parameter> _parameters = it.getParameters();
+      boolean _hasElements = false;
+      for(final Parameter parameter : _parameters) {
+        if (!_hasElements) {
+          _hasElements = true;
+        } else {
+          _builder.appendImmediate(", ", "");
+        }
+        Type _type_1 = parameter.getType();
+        String _targetLanguageName_1 = this._iCodegenTypeSystemAccess.getTargetLanguageName(_type_1);
+        _builder.append(_targetLanguageName_1, "");
+        _builder.append(" ");
+        String _identifier = this.identifier(parameter);
+        _builder.append(_identifier, "");
+      }
+    }
+    _builder.append(")");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+  
+  private String identifier(final Parameter parameter) {
+    String _xifexpression = null;
+    String _name = parameter.getName();
+    boolean _isCKeyword = this.cNaming.isCKeyword(_name);
+    if (_isCKeyword) {
+      String _name_1 = parameter.getName();
+      return (_name_1 + "Arg");
+    } else {
+      String _name_2 = parameter.getName();
+      _xifexpression = _name_2;
+    }
+    return _xifexpression;
+  }
+  
+  public CharSequence statemachineTypeDecl(final ExecutionFlow it) {
+    StringConcatenation _builder = new StringConcatenation();
+    _builder.append("//! the maximum number of orthogonal states defines the dimension of the state configuration vector.");
+    _builder.newLine();
+    _builder.append("#define ");
+    String _type = this.cNaming.type(it);
+    String _upperCase = _type.toUpperCase();
+    _builder.append(_upperCase, "");
+    _builder.append("_MAX_ORTHOGONAL_STATES ");
+    StateVector _stateVector = it.getStateVector();
+    int _size = _stateVector.getSize();
+    _builder.append(_size, "");
+    _builder.newLineIfNotEmpty();
+    {
+      boolean _hasHistory = this._navigation.hasHistory(it);
+      if (_hasHistory) {
+        _builder.append("//! dimension of the state configuration vector for history states");
+        _builder.newLine();
+        _builder.append("#define ");
+        String _type_1 = this.cNaming.type(it);
+        String _upperCase_1 = _type_1.toUpperCase();
+        _builder.append(_upperCase_1, "");
+        _builder.append("_MAX_HISTORY_STATES ");
+        StateVector _historyVector = it.getHistoryVector();
+        int _size_1 = _historyVector.getSize();
+        _builder.append(_size_1, "");
+      }
+    }
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    String _statesEnumType = this.cNaming.statesEnumType(it);
+    _builder.append(_statesEnumType, "");
+    _builder.append(" stateConfVector[");
+    String _type_2 = this.cNaming.type(it);
+    String _upperCase_2 = _type_2.toUpperCase();
+    _builder.append(_upperCase_2, "");
+    _builder.append("_MAX_ORTHOGONAL_STATES];");
+    _builder.newLineIfNotEmpty();
+    {
+      boolean _hasHistory_1 = this._navigation.hasHistory(it);
+      if (_hasHistory_1) {
+        String _statesEnumType_1 = this.cNaming.statesEnumType(it);
+        _builder.append(_statesEnumType_1, "");
+        _builder.append(" historyVector[");
+        String _type_3 = this.cNaming.type(it);
+        String _upperCase_3 = _type_3.toUpperCase();
+        _builder.append(_upperCase_3, "");
+        _builder.append("_MAX_HISTORY_STATES];");
+      }
+    }
+    _builder.newLineIfNotEmpty();
+    _builder.append("sc_ushort stateConfVectorPosition; ");
+    _builder.newLine();
+    return _builder;
+  }
+  
+  protected CharSequence _functionPrototypes(final EventDefinition it) {
+    StringConcatenation _builder = new StringConcatenation();
+    {
+      Direction _direction = it.getDirection();
+      boolean _equals = Objects.equal(_direction, Direction.IN);
+      if (_equals) {
+        _builder.append("/*! Raises the in event \'");
+        String _name = it.getName();
+        _builder.append(_name, "");
+        _builder.append("\' that is defined in the ");
+        Scope _scope = this._navigation.scope(it);
+        CharSequence _scopeDescription = this.cNaming.scopeDescription(_scope);
+        _builder.append(_scopeDescription, "");
+        _builder.append(". */ ");
+        _builder.newLineIfNotEmpty();
+        _builder.append("void ");
+        String _asRaiser = this.cNaming.asRaiser(it);
+        _builder.append(_asRaiser, "");
+        _builder.append("(");
+        String _valueParams = this.cNaming.valueParams(it);
+        _builder.append(_valueParams, "");
+        _builder.append(");");
+        _builder.newLineIfNotEmpty();
+        _builder.newLine();
+      } else {
+        _builder.append("/*! Checks if the out event \'");
+        String _name_1 = it.getName();
+        _builder.append(_name_1, "");
+        _builder.append("\' that is defined in the ");
+        Scope _scope_1 = this._navigation.scope(it);
+        CharSequence _scopeDescription_1 = this.cNaming.scopeDescription(_scope_1);
+        _builder.append(_scopeDescription_1, "");
+        _builder.append(" has been raised. */ ");
+        _builder.newLineIfNotEmpty();
+        _builder.append("sc_boolean ");
+        String _asRaised = this.cNaming.asRaised(it);
+        _builder.append(_asRaised, "");
+        _builder.append("();");
+        _builder.newLineIfNotEmpty();
+        _builder.newLine();
+        {
+          boolean _hasValue = this._navigation.hasValue(it);
+          if (_hasValue) {
+            _builder.append("/*! Gets the value of the out event \'");
+            String _name_2 = it.getName();
+            _builder.append(_name_2, "");
+            _builder.append("\' that is defined in the ");
+            Scope _scope_2 = this._navigation.scope(it);
+            CharSequence _scopeDescription_2 = this.cNaming.scopeDescription(_scope_2);
+            _builder.append(_scopeDescription_2, "");
+            _builder.append(". */ ");
+            _builder.newLineIfNotEmpty();
+            Type _type = it.getType();
+            String _targetLanguageName = this._iCodegenTypeSystemAccess.getTargetLanguageName(_type);
+            _builder.append(_targetLanguageName, "");
+            _builder.append(" ");
+            String _asGetter = this.cNaming.asGetter(it);
+            _builder.append(_asGetter, "");
+            _builder.append("();");
+            _builder.newLineIfNotEmpty();
+            _builder.newLine();
+          }
+        }
+      }
+    }
+    return _builder;
+  }
+  
+  protected CharSequence _functionPrototypes(final VariableDefinition it) {
+    StringConcatenation _builder = new StringConcatenation();
+    _builder.append("/*! Gets the value of the variable \'");
+    String _name = it.getName();
+    _builder.append(_name, "");
+    _builder.append("\' that is defined in the ");
+    Scope _scope = this._navigation.scope(it);
+    CharSequence _scopeDescription = this.cNaming.scopeDescription(_scope);
+    _builder.append(_scopeDescription, "");
+    _builder.append(". */ ");
+    _builder.newLineIfNotEmpty();
+    Type _type = it.getType();
+    String _targetLanguageName = this._iCodegenTypeSystemAccess.getTargetLanguageName(_type);
+    _builder.append(_targetLanguageName, "");
+    _builder.append(" ");
+    String _asGetter = this.cNaming.asGetter(it);
+    _builder.append(_asGetter, "");
+    _builder.append("();");
+    _builder.newLineIfNotEmpty();
+    {
+      boolean _isReadonly = it.isReadonly();
+      boolean _not = (!_isReadonly);
+      if (_not) {
+        _builder.append("/*! Sets the value of the variable \'");
+        String _name_1 = it.getName();
+        _builder.append(_name_1, "");
+        _builder.append("\' that is defined in the ");
+        Scope _scope_1 = this._navigation.scope(it);
+        CharSequence _scopeDescription_1 = this.cNaming.scopeDescription(_scope_1);
+        _builder.append(_scopeDescription_1, "");
+        _builder.append(". */ ");
+        _builder.newLineIfNotEmpty();
+        _builder.append("void ");
+        String _asSetter = this.cNaming.asSetter(it);
+        _builder.append(_asSetter, "");
+        _builder.append("(");
+        Type _type_1 = it.getType();
+        String _targetLanguageName_1 = this._iCodegenTypeSystemAccess.getTargetLanguageName(_type_1);
+        _builder.append(_targetLanguageName_1, "");
+        _builder.append(" value);");
+        _builder.newLineIfNotEmpty();
+      }
+    }
+    return _builder;
+  }
+  
+  public CharSequence functionPrototypes(final Declaration it) {
+    if (it instanceof EventDefinition) {
+      return _functionPrototypes((EventDefinition)it);
+    } else if (it instanceof VariableDefinition) {
+      return _functionPrototypes((VariableDefinition)it);
+    } else if (it != null) {
+      return _functionPrototypes(it);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(it).toString());
+    }
+  }
+}

+ 69 - 0
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/Types.java

@@ -0,0 +1,69 @@
+package org.yakindu.sct.generator.cpp;
+
+import com.google.inject.Inject;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.sct.generator.c.GenmodelEntries;
+import org.yakindu.sct.generator.cpp.Naming;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+@SuppressWarnings("all")
+public class Types {
+  @Inject
+  private Naming _naming;
+  
+  @Inject
+  private GenmodelEntries _genmodelEntries;
+  
+  public void generateTypesHpp(final ExecutionFlow flow, final Statechart sc, final IFileSystemAccess fsa, final GeneratorEntry entry) {
+    String _typesModule = this._naming.typesModule(flow);
+    String _hpp = this._naming.hpp(_typesModule);
+    CharSequence _typesHContent = this.typesHContent(flow, entry);
+    fsa.generateFile(_hpp, _typesHContent);
+  }
+  
+  public CharSequence typesHContent(final ExecutionFlow it, final GeneratorEntry entry) {
+    StringConcatenation _builder = new StringConcatenation();
+    String _licenseText = this._genmodelEntries.getLicenseText(entry);
+    _builder.append(_licenseText, "");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#ifndef ");
+    String _typesModule = this._naming.typesModule(it);
+    String _define = this._naming.define(_typesModule);
+    _builder.append(_define, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.append("#define ");
+    String _typesModule_1 = this._naming.typesModule(it);
+    String _define_1 = this._naming.define(_typesModule_1);
+    _builder.append(_define_1, "");
+    _builder.append("_H_");
+    _builder.newLineIfNotEmpty();
+    _builder.newLine();
+    _builder.append("#include <string>");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("typedef unsigned char\tsc_ushort;");
+    _builder.newLine();
+    _builder.append("typedef int\t\t\t\tsc_integer;  ");
+    _builder.newLine();
+    _builder.append("typedef double\t\t\tsc_real;");
+    _builder.newLine();
+    _builder.append("typedef string\t\t\tsc_string;");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("typedef void*\t\t\tsc_eventid;");
+    _builder.newLine();
+    _builder.newLine();
+    _builder.append("#endif /* ");
+    String _typesModule_2 = this._naming.typesModule(it);
+    String _define_2 = this._naming.define(_typesModule_2);
+    _builder.append(_define_2, "");
+    _builder.append("_H_ */");
+    _builder.newLineIfNotEmpty();
+    return _builder;
+  }
+}