dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Channel.java
1 /* $Id: Channel.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.pn;
3
4 import dol.visitor.PNVisitor;
5
6 /**
7  * This class is the basic channel in a process network.
8  * The channel has a name and a list of ports connected by this channel.
9  * In this model, a channel has only two ports: one input port and one
10  * output port.
11  */
12 public class Channel extends Resource implements Schedulable {
13
14     /**
15      *  Constructor to create a channel with a name and an empty
16      *  portList.
17      */
18     public Channel(String name) {
19         super(name);
20     }
21
22     /**
23      * Accept a visitor.
24      * @param x visitor object
25      */
26     public void accept(PNVisitor x) {
27         x.visitComponent(this);
28     }
29
30     /**
31      * Clone this channel.
32      *
33      * @return new instance of the channel
34      */
35     public Object clone() {
36         Channel newObj = (Channel) super.clone();
37         return (newObj);
38     }
39
40     /**
41      * Get the size of this channel.
42      *
43      * @return size of the channel
44      */
45     public int getSize() {
46         return _size;
47     }
48
49     /**
50      * Set the size of this channel.
51      *
52      * @param size new size value
53      */
54     public void setSize(int size) {
55         _size = size;
56     }
57
58     /**
59      * Get the token  size of this channel.
60      *
61      * @return token size of the channel
62      */
63     public int getTokenSize() {
64         return _tokenSize;
65     }
66
67     /**
68      * Set the token size of this channel.
69      *
70      * @param size new token size
71      */
72     public void setTokenSize(int size) {
73         _tokenSize = size;
74     }
75
76     /**
77      * Return a string representation of the channel.
78      *
79      * @return string representation of the channel
80      */
81     public String toString() {
82         return "Channel: " + getName();
83     }
84
85     /**
86      * Get the process where this channel starts from.
87      *
88      * @return origin process
89      */
90     public Process getOrigin() {
91         return _origin;
92     }
93
94     /**
95      * Set the process where this channel starts from.
96      *
97      * @param origin origin process
98      */
99     public void setOrigin(Process origin) {
100         _origin = origin;
101     }
102
103     /**
104      * Get the process where this channel ends.
105      *
106      * @return target process
107      */
108     public Process getTarget() {
109         return _target;
110     }
111
112     /**
113      * Set the process where this channel ends.
114      *
115      * @param target target process
116      */
117     public void setTarget(Process target) {
118         _target = target;
119     }
120
121     protected Process _origin;
122     protected Process _target;
123
124     /** size of the channel */
125     protected int _size;
126
127     /** token size fo the channel */
128     protected int _tokenSize;
129 }