blob: d9657b4cf93d2f1ca75f0a5b373ce5b48f26bba0 [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2018-2021 Robert Bosch GmbH and others.
*
* 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 app4mc.example.transform.m2m.transformers.hw;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.app4mc.amalthea.model.Cache;
import org.eclipse.app4mc.amalthea.model.HwAccessElement;
import org.eclipse.app4mc.amalthea.model.ProcessingUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import app4mc.example.transform.samplemodel.Model;
@Singleton
public class ExampleProcessingUnitTransformer {
private static final Logger LOG = LoggerFactory.getLogger(ExampleProcessingUnitTransformer.class);
@Inject
private ExampleCacheTransformer cacheTransformer;
public void transfrom(final ProcessingUnit pu, final Model outputModel) {
for (Cache puSpecificCache : pu.getCaches()) {
final app4mc.example.transform.samplemodel.Cache outputCache = cacheTransformer.transfrom(puSpecificCache);
outputModel.getCaches().add(outputCache);
}
for (HwAccessElement hwAccessElement : pu.getAccessElements()) {
if (hwAccessElement != null && hwAccessElement.getAccessPath() != null) {
List<Cache> referredCaches = hwAccessElement.getAccessPath().getPathElements()
.stream()
.filter(it -> it instanceof Cache)
.map(it -> (Cache) it)
.collect(Collectors.toList());
for (Cache referredCache : referredCaches) {
final app4mc.example.transform.samplemodel.Cache outputCache = cacheTransformer.transfrom(referredCache);
LOG.info("Cache referred in path elements is : {}", outputCache);
}
}
}
}
}