blob: 05675787725b9566f41a861f34408c406fbf263e [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2019-2020 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.amlt2systemc.m2t.transformers;
import org.eclipse.app4mc.amalthea.model.Amalthea;
import org.eclipse.app4mc.amlt2systemc.m2t.module.BaseTransformer;
import org.eclipse.app4mc.amlt2systemc.m2t.module.PropertyKeys;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
public class AmaltheaModel2TextTransformer extends BaseTransformer {
private static final Logger LOG = LoggerFactory.getLogger(AmaltheaModel2TextTransformer.class);
@Inject private OutputBuffer outputBuffer;
@Inject private AmaltheaTransformer amaltheaTransformer;
@Inject private CMakeTopGenerator cmakeTopGenerator;
public void m2tTransformation(final ResourceSet inputResourceSet) {
for (final Resource resource : inputResourceSet.getResources()) {
for (final EObject model : resource.getContents()) {
LOG.info(("Processing file : " + resource.getURI()));
if ((model instanceof Amalthea)) {
this.outputBuffer.initialize(this.getProperty(PropertyKeys.M2T_OUTPUT_FOLDER));
this.outputBuffer.configureFiletype("SRC", ".cpp", "// This code was generated for simulation with app4mc.sim\n\n", null);
this.outputBuffer.configureFiletype("INC", ".h", "// This code was generated for simulation with app4mc.sim\n\n#pragma once\n\n", null);
this.outputBuffer.configureFiletype("OTHER", "", "", "");
this.amaltheaTransformer.transform(((Amalthea) model));
this.cmakeTopGenerator.transform();
this.outputBuffer.finish();
LOG.info("Script file generated at : {}", this.outputBuffer.getOutputFolder());
}
}
}
}
}