X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fdatamodel%2Fpn%2FProcess.java;fp=dol%2Fsrc%2Fdol%2Fdatamodel%2Fpn%2FProcess.java;h=1b825b439abad7869e8b4f8c638deb1753d678cb;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/datamodel/pn/Process.java b/dol/src/dol/datamodel/pn/Process.java new file mode 100644 index 0000000..1b825b4 --- /dev/null +++ b/dol/src/dol/datamodel/pn/Process.java @@ -0,0 +1,150 @@ +/* $Id: Process.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.datamodel.pn; + +import java.util.StringTokenizer; +import java.util.Vector; + +import dol.datamodel.architecture.Processor; +import dol.visitor.PNVisitor; + +/** + * This class represents a process. + */ +public class Process extends Resource implements Schedulable { + + /** + * Constructor to create a Process with a name and an empty + * portList. + */ + public Process(String name) { + super(name); + } + + /** + * Accept a Visitor + * @param x A Visitor Object. + */ + public void accept(PNVisitor x) { + x.visitComponent(this); + } + + /** + * Clone this Process + * + * @return a new instance of the Process. + */ + public Object clone() { + Process newObj = (Process) super.clone(); + newObj.setRange(_range); + newObj.setProcessor(_processor); + return (newObj); + } + + /** + * Get the range of this process. + * + * @return range + */ + public String getRange() { + return _range; + } + + /** + * Get the iterator indices of this process. + * + * @return range + */ + public Vector getIteratorIndices() { + Vector indices = new Vector(); + StringTokenizer tokenizer = + new StringTokenizer(_name.replaceAll(_basename, ""), "_"); + while (tokenizer.hasMoreTokens()) { + indices.add(Integer.valueOf(tokenizer.nextToken())); + } + return indices; + } + + /** + * Set the range of this process. + * + * @param range new range value + */ + public void setRange(String range) { + _range= range; + } + + public boolean hasInPorts() { + for (Port port : getPortList()) { + if (port.isInPort()) + return true; + } + return false; + } + + public boolean hasOutPorts() { + for (Port port : getPortList()) { + if (port.isOutPort()) + return true; + } + return false; + } + + /** + * Get number of inport + */ + public int getNumOfInports() { + int i = 0; + for (Port port : getPortList()) + if (port.isInPort()) + i++; + return i; + } + + /** + * Get number of outport + */ + public int getNumOfOutports() { + int i = 0; + for (Port port : getPortList()) + if (port.isOutPort()) + i++; + return i; + } + + /** + * Set the processor this process runs on. + * @param processor + */ + public void setProcessor(Processor processor) + { + _processor = processor; + } + + /** + * Get the processor this process runs on. + */ + public Processor getProcessor() + { + return _processor; + } + + /** + * Return a description of the process. + * + * @return a description of the process. + */ + public String toString() { + return "Process: " + getName(); + } + + /** + * Range of the iterator when the instance belongs to an iterated + * series of processes. + */ + protected String _range = ""; + + /** + * Processor that executes this process. + */ + protected Processor _processor = null; +}