Package org.simplesim.core.messaging
Class SwitchPort
java.lang.Object
org.simplesim.core.messaging.AbstractPort
org.simplesim.core.messaging.SwitchPort
- All Implemented Interfaces:
Port
Port to send a message to one of several inports.
Messages are sent from this port implementation to a connected inport. The inport is indexed by the
message destination, so there can be only one SwitchPort
along the way of message.
Note: Only use as outport.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Connects this port to another one.void
disconnect
(Port port) Disconnects this port from another one.Implements a message forwarding strategy specific for the port class.boolean
isConnectedTo
(Port port) Tests if the port is connected to another one.boolean
Tests if the port is the end point of a connection.Methods inherited from class org.simplesim.core.messaging.AbstractPort
clearMessages, countMessages, equals, getParent, hasMessages, poll, readAll, write, writeAll
-
Constructor Details
-
SwitchPort
-
-
Method Details
-
connect
Description copied from interface:Port
Connects this port to another one.Note that connections are directed.
- Parameters:
port
- the other part of the connection
-
disconnect
Description copied from interface:Port
Disconnects this port from another one.- Parameters:
port
- the port to be removed
-
isEndPoint
public boolean isEndPoint()Description copied from interface:Port
Tests if the port is the end point of a connection.- Returns:
- true if it is end point (destination port)
-
forwardMessages
Description copied from interface:Port
Implements a message forwarding strategy specific for the port class.Port must be connected to other ports, please check if it is an end point beforehand!
Note: Only to be used by an implementation of
MessageForwardingStrategy
- Returns:
- list of destination ports that need further forwarding
-
isConnectedTo
Description copied from interface:Port
Tests if the port is connected to another one.- Parameters:
port
- the port to test- Returns:
- true if this port is connected to the other port
-