cffc781e781a69ca1b1b5a2a4045c226d575b92a
[jump.git] / dol / src / dol / datamodel / architecture / Processor.java
1 /* $Id: Processor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.architecture;
3
4 import java.util.Vector;
5
6 import dol.datamodel.pn.Process;
7 import dol.visitor.ArchiVisitor;
8
9 /**
10  * This class represents a processor element in the architecture.
11  */
12 public class Processor extends ArchiResource {
13
14     /**
15      * Constructor to create a Processor with a name and an empty
16      * nodeList.
17      */
18     public Processor(String name) {
19         super(name);
20         _processList = new Vector<Process>();
21     }
22
23     /**
24      * Accept a Visitor
25      * @param x A Visitor Object.
26      */
27     public void accept(ArchiVisitor x) {
28         x.visitComponent(this);
29     }
30
31     /**
32      * Clone this Processor
33      *
34      * @return a new instance of the Processor.
35      */
36     @SuppressWarnings("unchecked")
37     public Object clone() {
38         Processor newObj = (Processor) super.clone();
39         newObj.setProcessList((Vector<Process>)_processList.clone());
40         return (newObj);
41     }
42
43     /**
44      * Get the range of this processor.
45      *
46      * @return range
47      */
48     public String getRange() {
49         return _range;
50     }
51
52     /**
53      * Set the range of this process.
54      *
55      * @param range new range value
56      */
57     public void setRange(String range) {
58         _range= range;
59     }
60
61     /**
62      * Get the type of this processor.
63      *
64      * @return type
65      */
66     public String getType() {
67         return _type;
68     }
69
70     /**
71      * Set the type of this processor.
72      *
73      * @param type new range value
74      */
75     public void setType(String type) {
76         _type= type;
77     }
78
79
80
81     /**
82      * Set the list of processes bound to this processor.
83      * @param processList the new process list
84      */
85     public void setProcessList(Vector<Process> processList)
86     {
87         _processList = processList;
88     }
89
90     /**
91      * Get the list of processes bound to this processor.
92      */
93     public Vector<Process> getProcessList()
94     {
95         return _processList;
96     }
97
98     /**
99      * Indicates if a process with a specific name is bound
100      * to this processor.
101      * @param name the name of the process to search for
102      * @return true if a process with the specifed name is bound to this
103      * processor
104      */
105     public boolean hasProcess(String name)
106     {
107         for (Process iter : _processList) {
108             if (iter.getName().equals(name))
109                 return true;
110         }
111
112         return false;
113     }
114
115     /**
116      * Return a description of the processor.
117      *
118      * @return a description of the processor.
119      */
120     public String toString() {
121         return "Processor: " + getName() ;
122     }
123
124     /**
125      * Range of the iterator when the instance belongs to an iterated
126      * series of processors.
127      */
128     protected String _range;
129     protected String _type;
130
131     /**
132      * List of processes bound to this processor.
133      */
134     protected Vector<Process> _processList;
135 }