| /** |
| * 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.ChannelSend; |
| import org.eclipse.app4mc.slg.commons.m2t.generators.TranslationUnit; |
| import org.eclipse.app4mc.transformation.util.OutputBuffer; |
| |
| public class RosChannelSendTranslationUnit extends TranslationUnit { |
| private RosChannelSendUtilsTranslationUnit tuIpUtils; |
| |
| private ChannelSend cs; |
| private OutputBuffer outputBuffer; |
| |
| public RosChannelSendTranslationUnit(final OutputBuffer outputBuffer, |
| final RosChannelSendUtilsTranslationUnit tuIpUtils, final ChannelSend cs) { |
| super(); |
| this.cs = cs; |
| this.tuIpUtils = tuIpUtils; |
| this.outputBuffer = outputBuffer; |
| } |
| |
| public String getBasePath() { |
| return tuIpUtils.getBasePath(); |
| } |
| |
| public String getModuleName() { |
| return tuIpUtils.getModuleName(); |
| } |
| |
| public String getIncFile() { |
| return getModuleName() + ".h"; |
| } |
| |
| @Override |
| public String getCall() { |
| return tuIpUtils.getExecCall(cs.getData().getName()); |
| } |
| |
| public String getModulePath() { |
| return getBasePath() + "/" + getModuleName(); |
| } |
| |
| @Override |
| public String getSrcFile() { |
| return getModuleName() + ".cpp"; |
| } |
| |
| public String getIncPath() { |
| return getModulePath() + "/_inc/" + this.getIncFile(); |
| } |
| |
| public String getSrcPath() { |
| return getModulePath() + "/_src/" + this.getSrcFile(); |
| } |
| |
| public boolean isIncFileEmpty() { |
| return !outputBuffer.bufferExists("INC", getModulePath() + "/_inc/" + getModuleName()); |
| } |
| |
| public boolean isSrcFileEmpty() { |
| return !outputBuffer.bufferExists("SRC", getModulePath() + "/_src/" + getModuleName()); |
| } |
| |
| public boolean incAppend(final String str) { |
| return outputBuffer.appendTo("INC", this.getModulePath() + "/_inc/" + getModuleName(), str); |
| } |
| |
| public boolean srcAppend(final String str) { |
| return outputBuffer.appendTo("SRC", getModulePath() + "/_src/" + getModuleName(), str); |
| } |
| |
| } |