1 /* $Id: Process.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.pn;
4 import java.util.StringTokenizer;
5 import java.util.Vector;
7 import dol.datamodel.architecture.Processor;
8 import dol.visitor.PNVisitor;
11 * This class represents a process.
13 public class Process extends Resource implements Schedulable {
16 * Constructor to create a Process with a name and an empty
19 public Process(String name) {
25 * @param x A Visitor Object.
27 public void accept(PNVisitor x) {
28 x.visitComponent(this);
34 * @return a new instance of the Process.
36 public Object clone() {
37 Process newObj = (Process) super.clone();
38 newObj.setRange(_range);
39 newObj.setProcessor(_processor);
44 * Get the range of this process.
48 public String getRange() {
53 * Get the iterator indices of this process.
57 public Vector<Integer> getIteratorIndices() {
58 Vector<Integer> indices = new Vector<Integer>();
59 StringTokenizer tokenizer =
60 new StringTokenizer(_name.replaceAll(_basename, ""), "_");
61 while (tokenizer.hasMoreTokens()) {
62 indices.add(Integer.valueOf(tokenizer.nextToken()));
68 * Set the range of this process.
70 * @param range new range value
72 public void setRange(String range) {
76 public boolean hasInPorts() {
77 for (Port port : getPortList()) {
84 public boolean hasOutPorts() {
85 for (Port port : getPortList()) {
93 * Get number of inport
95 public int getNumOfInports() {
97 for (Port port : getPortList())
104 * Get number of outport
106 public int getNumOfOutports() {
108 for (Port port : getPortList())
109 if (port.isOutPort())
115 * Set the processor this process runs on.
118 public void setProcessor(Processor processor)
120 _processor = processor;
124 * Get the processor this process runs on.
126 public Processor getProcessor()
132 * Return a description of the process.
134 * @return a description of the process.
136 public String toString() {
137 return "Process: " + getName();
141 * Range of the iterator when the instance belongs to an iterated
142 * series of processes.
144 protected String _range = "";
147 * Processor that executes this process.
149 protected Processor _processor = null;