|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.clackrouter.component.base.ClackPort
public class ClackPort
The ClackPort handles the actual transfer of packets between different components that have been connected.
The direction will be either "in" or "out". two ports can be connected only if their directions are opposite The type will be either "push" or "pull". two ports can be connected only if their types are the same.
The port classes do the actual work of transfering packets between two components. See methods pushOut(VNSPacket)
,
pullIn()
, acceptPushRequest(VNSPacket)
, and acceptPullRequest()
for details
Ports are connected using the static connectPorts(ClackPort, ClackPort)
method
Ports have a type, which is the Java Class
object that represents a type of VNSPacket
. A port can
accept packets of any class that is a sub-type of its specified type, thus VNSPacket
is the most general type and can accept any packet.
For push ports, many output ports can be connected to a single input port, but a single output port can only be connected to a single input port. For pull ports, each input port can only be connected to a single output port, but an output port can be connected to multiple input ports.
Field Summary | |
---|---|
static int |
DIR_IN
|
static int |
DIR_OUT
|
static int |
METHOD_PULL
|
static int |
METHOD_PUSH
|
Constructor Summary | |
---|---|
ClackPort(ClackComponent owner,
int port_num,
java.lang.String description,
int method,
int direction,
java.lang.Class type)
|
Method Summary | |
---|---|
VNSPacket |
acceptPullRequest()
Called by a connected port that is trying to pull a packet from this port. |
void |
acceptPushRequest(VNSPacket packet)
Called by a connected port that is pushing a packet to us. |
static java.lang.String |
connectPorts(ClackPort source,
ClackPort dest)
The preferred method for connecting two ports. |
static void |
disconnectPorts(ClackPort source,
ClackPort dest)
Disconnects two ports |
ClackPort |
getConnectedPort(int index)
|
int |
getDirection()
|
java.lang.String |
getDirString()
|
RouterWire |
getListeningWire()
Get RouterWire that is connected to this port (used for RouterWire highlighting). |
int |
getMethod()
|
java.lang.String |
getMethodString()
|
int |
getNumConnectedPorts()
|
ClackComponent |
getOwner()
|
int |
getPortNumber()
|
java.lang.String |
getTextDescription()
|
java.lang.Class |
getType()
|
boolean |
isConnectedTo(ClackPort p)
Determine if this port is already connected to another port. |
VNSPacket |
pullIn()
Called by the parent component when it wants to try and pull a packet in through this port. |
void |
pushOut(VNSPacket packet)
Called by the parent component when it wants to send (push) a packet out this port. |
void |
setListeningWire(RouterWire w)
Set RouterWire that is connected to this port (used for RouterWire highlighting). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int METHOD_PUSH
public static int METHOD_PULL
public static int DIR_IN
public static int DIR_OUT
Constructor Detail |
---|
public ClackPort(ClackComponent owner, int port_num, java.lang.String description, int method, int direction, java.lang.Class type)
Method Detail |
---|
public static java.lang.String connectPorts(ClackPort source, ClackPort dest)
The preferred method for connecting two ports.
Performs checks to assure that the connection is valid, returning an error String if it encounters a problem. We check both basic issues like method, direction and number of connections, and also call the more advanced type checking algorithm to assure that this connection does not allow any type failures Returning null denotes success
source
- the output port originating packets in this connectiondest
- the input port receiving packet in this connection
public static void disconnectPorts(ClackPort source, ClackPort dest)
public void pushOut(VNSPacket packet)
Called by the parent component when it wants to send (push) a packet out this port.
It simply calls the acceptPushRequest() method on the port it is connected to. Also performs run-time checks to make sure port semantics are not violated.
As a source port, we also take care of enforcing the router speed delay and highlighting the RouterWire
public void acceptPushRequest(VNSPacket packet)
public VNSPacket pullIn()
This method performs error checking and simply calls acceptPullRequest() on the port it is connected to only valid if this port is a pull port.
public VNSPacket acceptPullRequest()
This port asks its parent component if it has any packets to be pulled on this port, and then then sends a packet to our connected port if there is a packet.
As a source port, we also take care of enforcing the router speed delay and highlighting the RouterWire
public java.lang.Class getType()
public int getMethod()
public int getDirection()
public java.lang.String getTextDescription()
public java.lang.String getMethodString()
public java.lang.String getDirString()
public ClackComponent getOwner()
public ClackPort getConnectedPort(int index)
public int getNumConnectedPorts()
public int getPortNumber()
public boolean isConnectedTo(ClackPort p)
public void setListeningWire(RouterWire w)
public RouterWire getListeningWire()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |