|
@@ -11,11 +11,14 @@
|
|
package org.yakindu.sct.generator.cpp
|
|
package org.yakindu.sct.generator.cpp
|
|
|
|
|
|
import com.google.inject.Inject
|
|
import com.google.inject.Inject
|
|
|
|
+import com.google.inject.name.Named
|
|
import org.eclipse.xtext.generator.IFileSystemAccess
|
|
import org.eclipse.xtext.generator.IFileSystemAccess
|
|
|
|
+import org.yakindu.sct.generator.c.GenArtifactConfigurations.GenArtifactConfiguration
|
|
|
|
+import org.yakindu.sct.generator.c.IGenArtifactConfigurations
|
|
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
|
|
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
|
|
|
|
+import org.yakindu.sct.generator.core.library.IOutletFeatureHelper
|
|
import org.yakindu.sct.model.sexec.ExecutionFlow
|
|
import org.yakindu.sct.model.sexec.ExecutionFlow
|
|
import org.yakindu.sct.model.sgen.GeneratorEntry
|
|
import org.yakindu.sct.model.sgen.GeneratorEntry
|
|
-import org.yakindu.sct.model.sgraph.Statechart
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* This is the CPP code generators main class.
|
|
* This is the CPP code generators main class.
|
|
@@ -24,27 +27,60 @@ import org.yakindu.sct.model.sgraph.Statechart
|
|
*/
|
|
*/
|
|
class CppGenerator implements IExecutionFlowGenerator {
|
|
class CppGenerator implements IExecutionFlowGenerator {
|
|
|
|
|
|
- @Inject extension Types
|
|
|
|
- @Inject extension TimedStatemachineInterface
|
|
|
|
- @Inject extension TimerInterface
|
|
|
|
- @Inject extension StatemachineInterface
|
|
|
|
- @Inject extension StatemachineHeader
|
|
|
|
- @Inject extension StatemachineImplementation
|
|
|
|
-
|
|
|
|
|
|
+ @Inject extension Types typesContent
|
|
|
|
+ @Inject extension TimedStatemachineInterface timedStatemachineInterfaceContent
|
|
|
|
+ @Inject extension TimerInterface timerInterfaceContent
|
|
|
|
+ @Inject extension StatemachineInterface statemachineInterfaceContent
|
|
|
|
+ @Inject extension StatemachineHeader statemachineHeaderContent
|
|
|
|
+ @Inject extension StatemachineImplementation statemachineSourceContent
|
|
@Inject extension Navigation
|
|
@Inject extension Navigation
|
|
|
|
+ @Inject extension Naming
|
|
|
|
+
|
|
|
|
+ @Inject IOutletFeatureHelper outletFeatureHelper
|
|
|
|
|
|
|
|
+ @Inject @Named(IGenArtifactConfigurations.DEFAULT)
|
|
|
|
+ IGenArtifactConfigurations defaultConfigs
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Deprecated use {@link #generate(ExecutionFlow, GeneratorEntry, IFileSystemAccess, ArtifactLocationProvider)} instead
|
|
|
|
+ */
|
|
|
|
+ @Deprecated
|
|
override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
|
|
override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
|
|
-
|
|
|
|
- flow.generateTypesHpp(flow.sourceElement as Statechart, fsa, entry)
|
|
|
|
|
|
+ generate(flow, entry, fsa, defaultConfigs)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ def generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa, IGenArtifactConfigurations locations) {
|
|
|
|
+ initGenerationArtifacts(flow, entry, locations)
|
|
|
|
+ generateArtifacts(flow, entry, fsa, locations);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ def generateArtifacts(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa, IGenArtifactConfigurations locations) {
|
|
|
|
+ for (GenArtifactConfiguration a : locations.configurations) {
|
|
|
|
+ fsa.generateFile(a.getName, a.getOutputName, a.getContentTemplate.content(flow, entry, locations))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ def initGenerationArtifacts(ExecutionFlow flow, GeneratorEntry entry, IGenArtifactConfigurations locations) {
|
|
|
|
+ if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
|
|
|
|
+ locations.configure(flow.typesModule.h, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, typesContent)
|
|
|
|
+ } else {
|
|
|
|
+ locations.configure(flow.typesModule.h, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, typesContent)
|
|
|
|
+ }
|
|
|
|
|
|
- flow.generateIStatemachine(entry, fsa);
|
|
|
|
|
|
+ locations.configure(statemachineInterface.h, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, statemachineInterfaceContent)
|
|
|
|
|
|
if (flow.timed) {
|
|
if (flow.timed) {
|
|
- flow.generateITimedStatemachine(entry, fsa);
|
|
|
|
- flow.generateITimerService(entry, fsa);
|
|
|
|
|
|
+ if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
|
|
|
|
+ locations.configure(timedStatemachineInterface.h, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, timedStatemachineInterfaceContent)
|
|
|
|
+ locations.configure(timerInterface.h, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, timerInterfaceContent)
|
|
|
|
+ } else {
|
|
|
|
+ locations.configure(timedStatemachineInterface.h, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, timedStatemachineInterfaceContent)
|
|
|
|
+ locations.configure(timerInterface.h, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, timerInterfaceContent)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- flow.generateStatemachineHeader(flow.sourceElement as Statechart, fsa, entry)
|
|
|
|
- flow.generateStatemachineImplemenation(flow.sourceElement as Statechart, fsa, entry)
|
|
|
|
|
|
+ locations.configure(flow.module.h, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, statemachineHeaderContent)
|
|
|
|
+ locations.configure(flow.module.cpp, IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT, statemachineSourceContent)
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|