Added support for Parameters to Coordinator + tests

parent 3ffe489a
......@@ -2,6 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
......@@ -59,10 +60,15 @@ public class MiddlewareGenerator extends CMakeGenerator {
.map(fn -> " adapters.push_back(new " + fn + "());")
.collect(Collectors.joining("\n"));
String initParams = componentInstanceSymbol.getArguments().stream()
.map(ComponentConverter::getExpressionParameterConversion)
.collect(Collectors.joining(","));
String content = TemplateHelper.getCoordinatorTemplate()
.replace("${compName}", name)
.replace("${includes}", includes)
.replace("${addAdapters}", addAdapters);
.replace("${addAdapters}", addAdapters)
.replace("${initParams}",initParams);
FileContent res = new FileContent();
......
......@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
atomic<bool> done(false);
${compName} comp;
comp.init();
comp.init(${initParams});
list<IAdapter_${compName}*> adapters;
${addAdapters}
......
......@@ -189,6 +189,20 @@ public class GenerationTest extends AbstractSymtabTest {
}
}
@Test
public void testParameterInit() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.dist.parameterInit", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath("./target/generated-sources-cmake/paramInit/src/");
distributedTargetGenerator.add(new CPPGenImpl(),"cpp");
distributedTargetGenerator.generate(componentInstanceSymbol,taggingResolver);
}
@Ignore
@Test
public void testsStreamTest() throws IOException {
......
package tests.dist;
component ParameterInit{
component NoParamComp{
}
component ParamComp(Q param){
}
component ParamCompMulti(Q param1, Q param2, Q param3){
}
instance NoParamComp noParamComp;
instance ParamComp(1.0) paramComp1;
instance ParamComp(2.0) paramComp2;
instance ParamCompMulti(1,2,3) paramComp3;
instance ParamCompMulti(4,5,6) paramComp4;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment