| /** |
| ******************************************************************************** |
| * 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.transformers.sw; |
| |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| |
| import org.eclipse.app4mc.amalthea.model.Label; |
| import org.eclipse.app4mc.slg.commons.m2t.generators.LabelTranslationUnit; |
| import org.eclipse.app4mc.slg.commons.m2t.transformers.sw.LabelTransformer; |
| import org.eclipse.app4mc.slg.ros2.generators.RosLabelGenerator; |
| import org.eclipse.app4mc.slg.ros2.generators.RosLabelTranslationUnit; |
| import org.eclipse.app4mc.transformation.util.OutputBuffer; |
| import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| |
| import com.google.inject.Inject; |
| |
| public class RosLabelTransformer extends LabelTransformer { |
| @Inject |
| private OutputBuffer outputBuffer; |
| |
| private static final String LIB_NAME = "LABELS_LIB"; |
| |
| @Override |
| public LabelTranslationUnit transform(final Label label) { |
| final ArrayList<?> key = CollectionLiterals.newArrayList(label); |
| final RosLabelTranslationUnit _result; |
| synchronized (_createCache_transform) { |
| if (_createCache_transform.containsKey(key)) { |
| return _createCache_transform.get(key); |
| } |
| RosLabelTranslationUnit tu = new RosLabelTranslationUnit(this.outputBuffer, label); |
| _result = tu; |
| _createCache_transform.put(key, _result); |
| } |
| _init_transform(_result, label); |
| return _result; |
| } |
| |
| private final HashMap<ArrayList<?>, LabelTranslationUnit> _createCache_transform = CollectionLiterals.newHashMap(); |
| |
| private void _init_transform(final RosLabelTranslationUnit it, final Label label) { |
| } |
| |
| @Override |
| public HashMap<ArrayList<?>, LabelTranslationUnit> getCache() { |
| return this._createCache_transform; |
| } |
| |
| @Override |
| public boolean createCMake() { |
| return outputBuffer.appendTo( |
| "OTHER", |
| RosLabelTranslationUnit.MAKEFILE_PATH, |
| RosLabelGenerator.toCMake(LIB_NAME, getSrcFiles())); |
| } |
| |
| } |