blob: becce253473d15295a6b149b585aaad75ee4f24e [file] [log] [blame]
/**
* Copyright (c) 2020-2021 Robert Bosch GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
*/
package org.eclipse.app4mc.slg.ros2.generators;
import org.eclipse.app4mc.amalthea.model.Label;
import org.eclipse.app4mc.slg.commons.m2t.generators.LabelTranslationUnit;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
public class RosLabelTranslationUnit extends LabelTranslationUnit {
public RosLabelTranslationUnit(final OutputBuffer outputBuffer, final Label label) {
super(outputBuffer, label);
}
// static helper functions (cannot be put to base class)
public static String getModulePathStatic() {
return "synthetic_gen" + "/" + getModuleNameStatic();
}
public static String getMakeFilePathStatic() {
return getModulePathStatic() + "/" + "CMakeLists.txt";
}
// translation unit specific settings
public static String getModuleNameStatic() {
return "labels";
}
public static String getLibName() {
return "LABELS_LIB";
}
@Override
public String getModuleName() {
return getModuleNameStatic();
}
@Override
public String getIncFile() {
return getModuleName() + ".h";
}
@Override
public void genFiles() {
if (isSrcFileEmpty()) {
srcAppend("#include \"" + getIncFile() + "\"\n\n");
srcAppend("#include <stdlib.h>\n");
}
String readCall = readCall("int labelAccessStatistics");
String writeCall = writeCall("int labelAccessStatistics");
incAppend(RosLabelGenerator.toH(getName(), readCall, writeCall));
srcAppend(RosLabelGenerator.toCpp(getName(), "" + getSize(), readCall, writeCall));
}
}