dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Channel.java
diff --git a/dol/src/dol/datamodel/pn/Channel.java b/dol/src/dol/datamodel/pn/Channel.java
new file mode 100644 (file)
index 0000000..2aa0706
--- /dev/null
@@ -0,0 +1,129 @@
+/* $Id: Channel.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.datamodel.pn;
+
+import dol.visitor.PNVisitor;
+
+/**
+ * This class is the basic channel in a process network.
+ * The channel has a name and a list of ports connected by this channel.
+ * In this model, a channel has only two ports: one input port and one
+ * output port.
+ */
+public class Channel extends Resource implements Schedulable {
+
+    /**
+     *  Constructor to create a channel with a name and an empty
+     *  portList.
+     */
+    public Channel(String name) {
+        super(name);
+    }
+
+    /**
+     * Accept a visitor.
+     * @param x visitor object
+     */
+    public void accept(PNVisitor x) {
+        x.visitComponent(this);
+    }
+
+    /**
+     * Clone this channel.
+     *
+     * @return new instance of the channel
+     */
+    public Object clone() {
+        Channel newObj = (Channel) super.clone();
+        return (newObj);
+    }
+
+    /**
+     * Get the size of this channel.
+     *
+     * @return size of the channel
+     */
+    public int getSize() {
+        return _size;
+    }
+
+    /**
+     * Set the size of this channel.
+     *
+     * @param size new size value
+     */
+    public void setSize(int size) {
+        _size = size;
+    }
+
+    /**
+     * Get the token  size of this channel.
+     *
+     * @return token size of the channel
+     */
+    public int getTokenSize() {
+        return _tokenSize;
+    }
+
+    /**
+     * Set the token size of this channel.
+     *
+     * @param size new token size
+     */
+    public void setTokenSize(int size) {
+        _tokenSize = size;
+    }
+
+    /**
+     * Return a string representation of the channel.
+     *
+     * @return string representation of the channel
+     */
+    public String toString() {
+        return "Channel: " + getName();
+    }
+
+    /**
+     * Get the process where this channel starts from.
+     *
+     * @return origin process
+     */
+    public Process getOrigin() {
+        return _origin;
+    }
+
+    /**
+     * Set the process where this channel starts from.
+     *
+     * @param origin origin process
+     */
+    public void setOrigin(Process origin) {
+        _origin = origin;
+    }
+
+    /**
+     * Get the process where this channel ends.
+     *
+     * @return target process
+     */
+    public Process getTarget() {
+        return _target;
+    }
+
+    /**
+     * Set the process where this channel ends.
+     *
+     * @param target target process
+     */
+    public void setTarget(Process target) {
+        _target = target;
+    }
+
+    protected Process _origin;
+    protected Process _target;
+
+    /** size of the channel */
+    protected int _size;
+
+    /** token size fo the channel */
+    protected int _tokenSize;
+}