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:
-
SinglePort
MultiPort
SwitchPort
RoutingPort
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Clears message queue of this port.final int
Counts messages in queue of this port.final boolean
final ModelEntity
final boolean
Checks 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 void
write
(AbstractMessage<?> message) Puts a message to be forwarded on this port.final void
writeAll
(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, wait
Methods 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:Port
Clears message queue of this port.- Specified by:
clearMessages
in interfacePort
-
countMessages
public final int countMessages()Description copied from interface:Port
Counts messages in queue of this port.- Specified by:
countMessages
in interfacePort
- Returns:
- number of messages, can be zero
-
hasMessages
public final boolean hasMessages()Description copied from interface:Port
Checks if the port has messages.- Specified by:
hasMessages
in interfacePort
- Returns:
- true if there are messages
-
poll
Description copied from interface:Port
Returns and removes the last element in the message queue. -
readAll
Description copied from interface:Port
Returns the message queue.Elements must be removed manually by calling the
Port.clearMessages()
method -
write
Description copied from interface:Port
Puts a message to be forwarded on this port. -
writeAll
Description copied from interface:Port
Puts several messages to be forwarded on this port. -
getParent
-
equals
-