Package org.simplesim.core.messaging
Class AbstractPort
java.lang.Object
org.simplesim.core.messaging.AbstractPort
- All Implemented Interfaces:
Port
- Direct Known Subclasses:
MultiPort,SinglePort,SwitchPort
Ports are used to send messages within a model.
In the phase of model building, ports are connected with each others via the
connectTo method. The sending entity puts a Message on its
outport. The message is then routed along the established connections. A port
that has no further connection is always an end-point (destination of
delivery). Thus, connections are always directed from source outport
to destination inport.
Each port must also implement its own copyMessages strategy to
support message forwarding during the simulation run.
- See Also:
-
SinglePortMultiPortSwitchPortRoutingPort
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidClears message queue of this port.final intCounts messages in queue of this port.final booleanfinal ModelEntityfinal booleanChecks if the port has messages.final <M extends AbstractMessage<?>>
Mpoll()Returns and removes the last element in the message queue.final <M extends AbstractMessage<?>>
Collection<M>readAll()Returns the message queue.final voidwrite(AbstractMessage<?> message) Puts a message to be forwarded on this port.final voidwriteAll(Collection<AbstractMessage<?>> m) Puts several messages to be forwarded on this port.Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.simplesim.core.messaging.Port
connect, disconnect, forwardMessages, isConnectedTo, isEndPoint
-
Constructor Details
-
AbstractPort
-
-
Method Details
-
clearMessages
public final void clearMessages()Description copied from interface:PortClears message queue of this port.- Specified by:
clearMessagesin interfacePort
-
countMessages
public final int countMessages()Description copied from interface:PortCounts messages in queue of this port.- Specified by:
countMessagesin interfacePort- Returns:
- number of messages, can be zero
-
hasMessages
public final boolean hasMessages()Description copied from interface:PortChecks if the port has messages.- Specified by:
hasMessagesin interfacePort- Returns:
- true if there are messages
-
poll
Description copied from interface:PortReturns and removes the last element in the message queue. -
readAll
Description copied from interface:PortReturns the message queue.Elements must be removed manually by calling the
Port.clearMessages()method -
write
Description copied from interface:PortPuts a message to be forwarded on this port. -
writeAll
Description copied from interface:PortPuts several messages to be forwarded on this port. -
getParent
-
equals
-