blob: 3f75c23790341d30e5c5a70da8c726c59b8e013d [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.linux.generators;
import org.eclipse.app4mc.slg.commons.m2t.generators.TranslationUnit;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
public abstract class LinuxBaseTranslationUnit extends TranslationUnit {
private static final String SRC_FOLDER = "/_src/";
private static final String INC_FOLDER = "/_inc/";
private OutputBuffer outputBuffer;
public LinuxBaseTranslationUnit(final OutputBuffer outputBuffer) {
super("MODULE_PATH", "CALL", "MODULE.H", "MODULE.C"); // dummy values for unused data
this.outputBuffer = outputBuffer;
}
public abstract String getBasePath();
public abstract String getModuleName();
public String getModulePath() {
return getBasePath() + "/" + getModuleName();
}
@Override
public String getIncFile() {
return (this.getModuleName() + ".h");
}
@Override
public String getSrcFile() {
return (this.getModuleName() + ".c");
}
public String getIncPath() {
return this.getModulePath() + INC_FOLDER + this.getIncFile();
}
public String getSrcPath() {
return this.getModulePath() + SRC_FOLDER + this.getSrcFile();
}
public boolean isIncFileEmpty() {
return !outputBuffer.bufferExists("H", getModulePath() + INC_FOLDER + getModuleName());
}
public boolean isSrcFileEmpty() {
return !outputBuffer.bufferExists("C", getModulePath() + SRC_FOLDER + getModuleName());
}
public boolean incAppend(String str) {
return outputBuffer.appendTo("H", getModulePath() + INC_FOLDER + getModuleName(), str);
}
public boolean srcAppend(String str) {
return outputBuffer.appendTo("C", getModulePath() + SRC_FOLDER + getModuleName(), str);
}
}