Skip to content
Snippets Groups Projects
Commit c54d7e77 authored by Chrissi's avatar Chrissi
Browse files

Add Scala and Java documentation

parent 5e041061
Branches
No related tags found
No related merge requests found
Showing with 51 additions and 87 deletions
package ttc2019.metamodels.create;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import sync.tt.Cell;
import sync.tt.Port;
import sync.tt.Row;
import sync.tt.TruthTable;
import ttc2019.TTFactory;
public class CreateTTinJava {
private TruthTable truthttable = null;
private Map<EObject, Row> rows = new HashMap<EObject, Row>();
private Map<EObject, Port> ports = new HashMap<EObject, Port>();
private Map<EObject, Cell> cells = new HashMap<EObject, Cell>();
public void createTruthTable(String name, EObject id) {
truthttable = TTFactory.getTruthTable(name);
}
public void createInputPort(String name, EObject id) {
ports.put(id, TTFactory.getInputPort(name));
}
public void createOutputPort(String name, EObject id) {
ports.put(id, TTFactory.getOutputPort(name));
}
public void createRow(EObject id) {
rows.put(id, TTFactory.getRow());
}
public void createCell(Boolean value, EObject id) {
cells.put(id, TTFactory.getCell(value));
}
public void createTruthTableRowsRow(EObject tt, EObject row) {
Row r = rows.get(row);
truthttable.addRows(r);
r.setOwner(truthttable);
}
public void createTruthTablePortsPort(EObject tt, EObject port) {
Port p = ports.get(port);
truthttable.addPorts(p);
p.setOwner(truthttable);
}
public void createRowCellsCell(EObject row, EObject cell) {
Cell c = cells.get(cell);
Row r = rows.get(row);
c.setOwner(r);
r.addCells(c);
}
public void createCellPortPort(EObject cell, EObject port) {
Cell c = cells.get(cell);
Port p = ports.get(port);
c.setPort(p);
p.addCells(c);
}
}
...@@ -96,7 +96,7 @@ object CompleteTTCProcess extends App { ...@@ -96,7 +96,7 @@ object CompleteTTCProcess extends App {
} }
override def main(args: Array[String]): Unit = { override def main(args: Array[String]): Unit = {
val processConfig = TTCProcessConfiguration(ttFileName = "TT.ttmodel", bddFileName = "Generated.bddmodel", processMode = ProcessMode.BDD) val processConfig = TTCProcessConfiguration(ttFileName = "TT.ttmodel", bddFileName = "Generated.bddmodel", processMode = ProcessMode.BDTU)
executeEntireProcess(processConfig) executeEntireProcess(processConfig)
} }
......
...@@ -3,6 +3,11 @@ package ttc2019 ...@@ -3,6 +3,11 @@ package ttc2019
import sync.tt._ import sync.tt._
import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EObject
/**
* Create the instances of the truth table in Scala.
*
* @author Christopher Werner
*/
class CreateTruthTableDirectSync extends ICreateTruthTable { class CreateTruthTableDirectSync extends ICreateTruthTable {
var truthttable: TruthTable = null var truthttable: TruthTable = null
......
...@@ -3,6 +3,11 @@ package ttc2019 ...@@ -3,6 +3,11 @@ package ttc2019
import sync.tt._ import sync.tt._
import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EObject
/**
* Create the instances of the truth table in Scala.
*
* @author Christopher Werner
*/
class CreateTruthTableSync extends ICreateTruthTable { class CreateTruthTableSync extends ICreateTruthTable {
var mapping: Map[EObject, Object] = Map.empty var mapping: Map[EObject, Object] = Map.empty
......
...@@ -2,6 +2,9 @@ package ttc2019 ...@@ -2,6 +2,9 @@ package ttc2019
import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EObject
/**
* Interface for creating a truth Table.
*/
trait ICreateTruthTable { trait ICreateTruthTable {
def createTruthTable(name: String, id: EObject): Unit def createTruthTable(name: String, id: EObject): Unit
......
package ttc2019 package ttc2019
/**
* Interface to write out the target models.
*/
trait IWriteOutputModel { trait IWriteOutputModel {
def generateEverything(outputFile: String): Unit def generateEverything(outputFile: String): Unit
......
...@@ -3,6 +3,9 @@ package ttc2019 ...@@ -3,6 +3,9 @@ package ttc2019
import org.rosi_project.model_management.core.ModelElementLists import org.rosi_project.model_management.core.ModelElementLists
import ttc2019.benchmark.Metrics import ttc2019.benchmark.Metrics
/**
* Object to create the metric values from the created target models.
*/
object MetricMeasurement { object MetricMeasurement {
var printDirectly = false var printDirectly = false
......
...@@ -21,10 +21,10 @@ import ttc2019.metamodels.tt._ ...@@ -21,10 +21,10 @@ import ttc2019.metamodels.tt._
class TTCLoader { class TTCLoader {
/** /**
* Fetches an ecore model from XML. * Fetches an ecore model from XMI directly converted into a truth table.
* *
* @param path where to find the model * @param path where to find the (meta-)model
* @return the model described by the XML * @return the truth table instance from the model
*/ */
def javaOptimizedTTJavaEcore(pathMeta: String, pathInstance: String): TruthTable = { def javaOptimizedTTJavaEcore(pathMeta: String, pathInstance: String): TruthTable = {
require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty) require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty)
...@@ -32,18 +32,36 @@ class TTCLoader { ...@@ -32,18 +32,36 @@ class TTCLoader {
return loader.loadOptimizedTruthTable(pathMeta, pathInstance) return loader.loadOptimizedTruthTable(pathMeta, pathInstance)
} }
/**
* Fetches an ecore model from XMI as EObject.
*
* @param path where to find the (meta-)model
* @return the EObject instance from the model
*/
def loadOptimizedJavaEcore(pathMeta: String, pathInstance: String): EObject = { def loadOptimizedJavaEcore(pathMeta: String, pathInstance: String): EObject = {
require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty) require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty)
val loader = new LoadEObject val loader = new LoadEObject
return loader.loadOptimized(pathMeta, pathInstance) return loader.loadOptimized(pathMeta, pathInstance)
} }
/**
* Fetches an ecore model from XMI as EObject.
*
* @param path where to find the (meta-)model
* @return the EObject instance from the model
*/
def loadSimpleJavaEcore(pathMeta: String, pathInstance: String): EObject = { def loadSimpleJavaEcore(pathMeta: String, pathInstance: String): EObject = {
require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty) require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty)
val loader = new LoadEObject val loader = new LoadEObject
return loader.loadSimple(pathMeta, pathInstance) return loader.loadSimple(pathMeta, pathInstance)
} }
/**
* Fetches an ecore model from XMI as EObject.
*
* @param path where to find the (meta-)model
* @return the EObject instance from the model
*/
def loadScalaEcore(pathMeta: String, pathInstance: String): EObject = { def loadScalaEcore(pathMeta: String, pathInstance: String): EObject = {
require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty) require(null != pathMeta && pathMeta.nonEmpty && null != pathInstance && pathInstance.nonEmpty)
...@@ -63,6 +81,9 @@ class TTCLoader { ...@@ -63,6 +81,9 @@ class TTCLoader {
return ressourceModel.getContents().get(0) return ressourceModel.getContents().get(0)
} }
/**
* Create a new object from the incoming element.
*/
private def createObj(obj: EObject, ctts: ICreateTruthTable): Unit = { private def createObj(obj: EObject, ctts: ICreateTruthTable): Unit = {
var objName = obj.eClass.getName var objName = obj.eClass.getName
...@@ -77,6 +98,9 @@ class TTCLoader { ...@@ -77,6 +98,9 @@ class TTCLoader {
} }
} }
/**
* Create references between the created objects.
*/
private def createReferences(o1: EObject, ctts: ICreateTruthTable): Unit = { private def createReferences(o1: EObject, ctts: ICreateTruthTable): Unit = {
o1.eClass().getEAllReferences.forEach(sf => { o1.eClass().getEAllReferences.forEach(sf => {
if (sf.getName == "port" || sf.getName == "owner") { if (sf.getName == "port" || sf.getName == "owner") {
...@@ -111,8 +135,10 @@ class TTCLoader { ...@@ -111,8 +135,10 @@ class TTCLoader {
}) })
} }
def createTruthTableRSYNCInstance(tt: TruthTable, cttss: ICreateTruthTable): Unit = { /**
val ctts = new CreateTTinJava() * Create the input TruthTable instance from the *.ttmodel file.
*/
def createTruthTableRSYNCInstance(tt: TruthTable, ctts: ICreateTruthTable): Unit = {
ctts.createTruthTable(tt.getName, tt) ctts.createTruthTable(tt.getName, tt)
tt.getPorts.forEach(p => { tt.getPorts.forEach(p => {
......
package ttc2019
import sync.tt._
object TTFactory {
def getInputPort(name: String) = new InputPort(name, Set.empty, null, null)
def getTruthTable(name: String) = new TruthTable(name, Set.empty, Set.empty, null)
def getOutputPort(name: String) = new OutputPort(name, Set.empty, null, null)
def getRow() = new Row(Set.empty, null, null)
def getCell(value: Boolean) = new Cell(value, null, null, null)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment