blob: 941606f52aaded9b38d41e0a6d1346233a443979 [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.transformers.sw;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.app4mc.amalthea.model.InterProcessTrigger;
import org.eclipse.app4mc.slg.commons.m2t.SLGBaseTransformer;
import org.eclipse.app4mc.slg.commons.m2t.generators.TranslationUnit;
import org.eclipse.app4mc.slg.ros2.generators.RosInterProcessTriggerUtilsTranslationUnit;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@Singleton
public class RosInterProcessTriggerUtilsTransformer extends SLGBaseTransformer {
@Inject private OutputBuffer outputBuffer;
private final HashMap<ArrayList<?>, RosInterProcessTriggerUtilsTranslationUnit> cache = CollectionLiterals
.newHashMap();
public RosInterProcessTriggerUtilsTranslationUnit generate(final InterProcessTrigger ip) {
return this.generateIntern(ip); // hash according to class not instance
}
public RosInterProcessTriggerUtilsTranslationUnit generateIntern(final InterProcessTrigger ip) {
final ArrayList<?> key = CollectionLiterals.newArrayList(ip);
final RosInterProcessTriggerUtilsTranslationUnit _result;
synchronized (cache) {
if (cache.containsKey(key)) {
return cache.get(key);
}
RosInterProcessTriggerUtilsTranslationUnit tu = new RosInterProcessTriggerUtilsTranslationUnit(
this.outputBuffer, ip);
_result = tu;
cache.put(key, _result);
}
_init_generateIntern(_result, ip);
return _result;
}
private void _init_generateIntern(final RosInterProcessTriggerUtilsTranslationUnit it,
final InterProcessTrigger ip) {
}
@Override
public Map<ArrayList<?>, ? extends TranslationUnit> getCache() {
return this.cache;
}
}