Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Moved template Strings to freemarker syntax

parent e2a51a1f
......@@ -15,11 +15,11 @@ public class CPPImpl implements GeneratorImpl {
private String generationTargetPath;
private String cmakeTemplate =
"cmake_minimum_required(VERSION 3.5)\n" +
"project(<name> LANGUAGES CXX)\n" +
"add_library(<name> <name>.h)\n" +
"target_include_directories(<name> PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"set_target_properties(<name> PROPERTIES LINKER_LANGUAGE CXX)\n" +
"export(TARGETS <name> FILE <name>.cmake)";
"project(${compName} LANGUAGES CXX)\n" +
"add_library(${compName} ${compName}.h)\n" +
"target_include_directories(${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"set_target_properties(${compName} PROPERTIES LINKER_LANGUAGE CXX)\n" +
"export(TARGETS ${compName} FILE ${compName}.cmake)";
//TODO: make GeneratorCpp implement GeneratorImpl directly!
@Override
......@@ -44,7 +44,7 @@ public class CPPImpl implements GeneratorImpl {
FileContent cmake = new FileContent();
cmake.setFileName("CMakeLists.txt");
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
cmake.setFileContent(cmakeTemplate.replace("<name>", name));
cmake.setFileContent(cmakeTemplate.replace("${compName}", name));
return cmake;
}
}
......@@ -25,16 +25,16 @@ public class DummyMiddlewareGenerator implements GeneratorImpl {
private String dummyWrapperTemplate = "#pragma once\n" +
"#include \"<name>.h\"\n" +
"#include \"${compName}.h\"\n" +
"#include <thread>\n" +
"#include <chrono>\n" +
"#include \"IAdapter.h\"\n" +
"\n" +
"class <name>_DummyWrapper: public IAdapter{\n" +
"\t<name>* component;\n" +
"class ${compName}_DummyWrapper: public IAdapter{\n" +
"\t${compName}* component;\n" +
"\n" +
"public:\n" +
"\t<name>_DummyWrapper(){\n" +
"\t${compName}_DummyWrapper(){\n" +
"\n" +
"\t}\n" +
"\n" +
......@@ -42,7 +42,7 @@ public class DummyMiddlewareGenerator implements GeneratorImpl {
"\t\tcout << \"Dummy publish data: component.out1 = \"<< component->out1 << endl;\n" +
"\t}\n" +
"\t\n" +
"\tvoid init(<name>* comp){\n" +
"\tvoid init(${compName}* comp){\n" +
"\t\tthis->component = comp;\n" +
"\t\twhile(1){\n" +
" \t\t std::this_thread::sleep_for(std::chrono::seconds(1));\n" +
......@@ -56,7 +56,7 @@ public class DummyMiddlewareGenerator implements GeneratorImpl {
private FileContent generateWrapper(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = dummyWrapperTemplate
.replace("<name>", name);
.replace("${compName}", name);
FileContent res = new FileContent();
res.setFileName(name + "_DummyWrapper.h");
......@@ -72,19 +72,19 @@ public class DummyMiddlewareGenerator implements GeneratorImpl {
private String cmakeTemplate =
"cmake_minimum_required(VERSION 3.5)\n" +
"project (<name>_DummyWrapper)\n" +
"project (${compName}_DummyWrapper)\n" +
"\n" +
"add_library(<name>_DummyWrapper <name>_DummyWrapper.h)\n" +
"set_target_properties(<name>_DummyWrapper PROPERTIES LINKER_LANGUAGE CXX)\n" +
"target_link_libraries(<name>_DummyWrapper <name>)\n" +
"target_include_directories(<name>_DummyWrapper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"export(TARGETS <name>_DummyWrapper FILE <name>_DummyWrapper.cmake)";
"add_library(${compName}_DummyWrapper ${compName}_DummyWrapper.h)\n" +
"set_target_properties(${compName}_DummyWrapper PROPERTIES LINKER_LANGUAGE CXX)\n" +
"target_link_libraries(${compName}_DummyWrapper ${compName})\n" +
"target_include_directories(${compName}_DummyWrapper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"export(TARGETS ${compName}_DummyWrapper FILE ${compName}_DummyWrapper.cmake)";
private FileContent generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = cmakeTemplate
.replace("<name>", name);
.replace("${compName}", name);
res.setFileName("CMakeLists.txt");
res.setFileContent(content);
......
......@@ -32,16 +32,16 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
res.setFileName("IAdapter.h");
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String iAdapterTemplate = "#pragma once\n" +
"#include \"<name>.h\"\n" +
"#include \"${compName}.h\"\n" +
"\n" +
"class IAdapter{\n" +
"\tpublic:\n" +
"\t\tvirtual ~IAdapter(){}\n" +
"\t\tvirtual void init(<name>* comp) = 0;\n" +
"\t\tvirtual void init(${compName}* comp) = 0;\n" +
"\t\tvirtual void tick() = 0;\n" +
"};";
res.setFileContent(iAdapterTemplate.replace("<name>", name));
res.setFileContent(iAdapterTemplate.replace("${compName}", name));
return res;
}
......@@ -55,12 +55,12 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
"#include <list>\n" +
"#include \"IAdapter.h\"\n" +
"\n" +
"<includes>" +
"${includes}" +
"\n" +
"using namespace std;\n" +
"using namespace chrono;\n" +
"\n" +
"void startMiddleware(IAdapter& adapter,<name>& comp,atomic<bool>& done){\n" +
"void startMiddleware(IAdapter& adapter,${compName}& comp,atomic<bool>& done){\n" +
" adapter.init(&comp);\n" +
" done = true;\n" +
"}\n" +
......@@ -68,11 +68,11 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
"int main() \n" +
"{\n" +
" atomic<bool> done(false);\n" +
" <name> comp;\n" +
" ${compName} comp;\n" +
" comp.init();\n" +
"\n" +
" list<IAdapter*> adapters;\n" +
"<addAdapters>" +
"${addAdapters}" +
"\n" +
" list<thread*> threads;\n" +
" for(auto a : adapters){\n" +
......@@ -128,9 +128,9 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
.collect(Collectors.joining("\n"));
String content = coordinatorTemplate
.replace("<name>", name)
.replace("<includes>", includes)
.replace("<addAdapters>", addAdapters);
.replace("${compName}", name)
.replace("${includes}", includes)
.replace("${addAdapters}", addAdapters);
FileContent res = new FileContent();
......@@ -142,16 +142,16 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
private String cmakeListsTemplate =
"cmake_minimum_required(VERSION 3.5)\n" +
"project (Coordinator_<name> CXX)\n" +
"project (Coordinator_${compName} CXX)\n" +
"\n" +
"set (CMAKE_CXX_STANDARD 11)\n" +
"\n" +
"add_executable(Coordinator_<name> Coordinator_<name>.cpp)\n" +
"set_target_properties(Coordinator_<name> PROPERTIES LINKER_LANGUAGE CXX)\n" +
"target_link_libraries(Coordinator_<name> <targets>)\n" +
"target_include_directories(Coordinator_<name> PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"add_executable(Coordinator_${compName} Coordinator_${compName}.cpp)\n" +
"set_target_properties(Coordinator_${compName} PROPERTIES LINKER_LANGUAGE CXX)\n" +
"target_link_libraries(Coordinator_${compName} ${targets})\n" +
"target_include_directories(Coordinator_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" +
"\n" +
"export(TARGETS Coordinator_<name> FILE Coordinator_<name>.cmake)";
"export(TARGETS Coordinator_${compName} FILE Coordinator_${compName}.cmake)";
private FileContent generateCMakeList(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<File> files) {
FileContent res = new FileContent();
......@@ -165,8 +165,8 @@ public class MiddlewareMasterGenerator extends CMakeMasterGenerator {
.collect(Collectors.joining(" "));
String content = cmakeListsTemplate
.replace("<targets>", targets)
.replace("<name>", name);
.replace("${targets}", targets)
.replace("${compName}", name);
res.setFileName("CMakeLists.txt");
res.setFileContent(content);
return res;
......
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