X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fdatamodel%2Fmapping%2FMapping.java;fp=dol%2Fsrc%2Fdol%2Fdatamodel%2Fmapping%2FMapping.java;h=c0123a59f85f4a77eb9c067c0bc6b92a865dcfc0;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/datamodel/mapping/Mapping.java b/dol/src/dol/datamodel/mapping/Mapping.java new file mode 100644 index 0000000..c0123a5 --- /dev/null +++ b/dol/src/dol/datamodel/mapping/Mapping.java @@ -0,0 +1,274 @@ +package dol.datamodel.mapping; + +import java.util.Iterator; +import java.util.Vector; + +import dol.datamodel.architecture.Architecture; +import dol.datamodel.architecture.Processor; +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.visitor.MapVisitor; + + +/** + * This class defines a mapping. + */ +public class Mapping extends MapResource +{ + public Mapping(String name) + { + super(name); + _compBindList = new Vector(); + _commBindList = new Vector(); + _scheduleList = new Vector(); + _variableList = new Vector(); + /** + * For some code generation back end, traversing via architecture + * model rather than mapping model is more convenient, since the + * mapping model is a flattened view of the binding where one can + * not access all the binded processes from a processor. Therefore + * we annotate the binding information back to processor. + */ + _processList = new Vector(); + _processorList = new Vector(); + } + + /** + * Accept a visitor + * + * @param x visitor object + */ + public void accept(MapVisitor x) { + x.visitComponent(this); + } + + + /** + * Clone this Mapping. + * + * @return new instance of the Mapping + */ + @SuppressWarnings("unchecked") + public Object clone() { + Mapping newObj = (Mapping) super.clone(); + newObj.setCompBindList((Vector)_compBindList.clone()); + newObj.setCommBindList((Vector)_commBindList.clone()); + newObj.setScheduleList((Vector)_scheduleList.clone()); + newObj.setVarList((Vector)_variableList.clone()); + newObj.setProcessorList((Vector)_processorList.clone()); + newObj.setProcessList((Vector)_processList.clone()); + return (newObj); + } + + /** Get the process network. */ + public ProcessNetwork getPN() { return _pn; } + + /** Store a reference to the process network. */ + public void setPN(ProcessNetwork pn) { _pn = pn; } + + /** Get the architecture */ + public Architecture getArch() { return _arch; } + + /** Store a reference to the architecture. */ + public void setArch(Architecture arch) { _arch = arch; } + + /** + * Get a list of computation bindings in this Mapping. + * + * @return the binding list + */ + public Vector getCompBindList() { + return _compBindList; + } + + /** + * Get a list of processes in this Mapping. + * + * @return the process list + */ + public Vector getProcessList() { + return _processList; + } + + /** + * Return a process which has a specific name. Return null if + * process cannot be found. + * + * @param name the name of the process to search for. + * @return the process with the specific name or null if not found. + */ + public Process getProcess(String name) + { + for (Process process : _processList) { + if (process.getName().equals(name)) { + return process; + } + } + return null; + } + /** + * Set the computation binding list of this mapping. + * + * @param compBindList The new list + */ + public void setCompBindList( Vector compBindList ) { + _compBindList = compBindList; + } + + /** + * Get a list of communication bindings in this Mapping. + * + * @return the binding list + */ + public Vector getCommBindList() { + return _commBindList; + } + + /** + * Set the communication binding list of this mapping. + * + * @param commBindList The new list + */ + public void setCommBindList( Vector commBindList ) { + _commBindList = commBindList; + } + + /** + * Set the process list of this mapping. + * + * @param processList The new list + */ + public void setProcessList( Vector processList ) { + _processList = processList; + } + + /** + * Get the a list of processors in this Mapping. + * + * @return the processor list + */ + public Vector getProcessorList() { + return _processorList; + } + + /** + * Set the processor list of this mapping. + * + * @param processorList The new list + */ + public void setProcessorList( Vector processorList ) { + _processorList = processorList; + } + + /** + * Return a processor which has a specific name. Return null if + * processor cannot be found. + * + * @param name the name of the processor to search for. + * @return the processor with the specific name or null if not found. + */ + public Processor getProcessor(String name) + { + Iterator i; + i = _processorList.iterator(); + while (i.hasNext()) { + Processor processor = i.next(); + if (processor.getName().equals(name)) { + return processor; + } + } + return null; + } + + /** + * Get the a list of schedules in this Mapping. + * + * @return the schedule list + */ + public Vector getScheduleList() { + return _scheduleList; + } + + /** + * Set the schedule list of this mapping. + * + * @param scheduleList The new list + */ + public void setScheduleList( Vector scheduleList ) { + _scheduleList = scheduleList; + } + + /** + * Return the schedule for a resource that has a specific name. + * Return null if schedule cannot be found. + * + * @param name the name of the resource for which we are looking for the schedule. + * @return the schedule for the resource with the specified name. + */ + public Schedule getScheduleByResource(String name) { + for(Schedule schedule : _scheduleList) { + if (schedule.getResource().getName().equals(name)) { + return schedule; + } + } + return null; + } + + /** + * Return the communication binding for a channel that has a specific name. + * Return null if binding cannot be found. + * + * @param name the name of the channel for which we are looking for the binding. + * @return the binding for the channel with the specified name. + */ + public CommunicationBinding getCommBindingByChannel(String name) { + for(CommunicationBinding b : _commBindList) { + if (b.getChannel().getName().equals(name)) { + return b; + } + } + return null; + } + + /** + * Get the variable list of a Mapping. + * + * @return the variable list + */ + public Vector getVarList() { + return _variableList; + } + + /** + * Set the variable list of a mapping. + * + * @param variableList The new list + */ + public void setVarList( Vector variableList ) { + _variableList = variableList; + } + + /** ProcessNetwork Reference **/ + protected ProcessNetwork _pn = null; + + /** Architecture Reference **/ + protected Architecture _arch = null; + + /** List of processes in the mapping **/ + protected Vector _processList = null; + + /** List of processors actually used in the mapping **/ + protected Vector _processorList = null; + + /** List of computations bindings in the mapping **/ + protected Vector _compBindList = null; + + /** List of communication bindings in the mapping **/ + protected Vector _commBindList = null; + + /** List of schedules in the mapping **/ + protected Vector _scheduleList = null; + + /** List of variables in the mapping **/ + protected Vector _variableList = null; +}