public class IntermediateReceiver extends AbstractReceiver
put(Token)
(and its variants), for which it delegates to a
communication aspect. The delegated receiver and the communication aspect are
specified as constructor arguments.
This can be used, for example, when multiple communication links share resources. The communication aspect can, for example, delay the delivery of tokens to the delegated receiver to take into account resource availability. It could also be used to make a centralized record of various communications.
Subclasses of this receiver may also intervene on method calls other than put().
Red (derler) |
Yellow (derler) |
Modifier and Type | Field and Description |
---|---|
protected IOPort |
_port
The port.
|
Receiver |
_receiver
Target receiver that is wrapped by this intermediate receiver.
|
CommunicationAspect |
communicationAspect
communication aspect that receives tokens from this receiver.
|
Actor |
source
The source actor that sent a token to this receiver.
|
Constructor and Description |
---|
IntermediateReceiver(CommunicationAspect aspect,
Receiver receiver)
Construct an intermediate receiver with no container that wraps the
specified receiver using the specified communication aspect.
|
IntermediateReceiver(CommunicationAspect aspect,
Receiver receiver,
IOPort port)
Construct an intermediate receiver with no container that wraps the
specified receiver using the specified communication aspect.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Reset the communication aspect and the receiver that we delegate to.
|
java.util.List<Token> |
elementList()
Delegate to the internal receiver and return whatever it returns.
|
Token |
get()
Delegate to the internal receiver and return whatever it returns.
|
IOPort |
getContainer()
Delegate to the internal receiver and return whatever it returns.
|
boolean |
hasRoom()
Delegate to the internal receiver and return whatever it returns.
|
boolean |
hasRoom(int numberOfTokens)
Delegate to the internal receiver and return whatever it returns.
|
boolean |
hasToken()
Delegate to the internal receiver and return whatever it returns.
|
boolean |
hasToken(int numberOfTokens)
Delegate to the internal receiver and return whatever it returns.
|
boolean |
isKnown()
Delegate to the internal receiver and return whatever it returns.
|
void |
put(Token token)
Forward the specified token to communication aspect specified in
the constructor.
|
void |
reset()
Reset this receiver to its initial state, which in this base
class is the same as calling clear().
|
void |
setContainer(IOPort port)
Set the container of the internal receiver.
|
getArray, getCurrentTime, getModelTime, putArray, putArrayToAll, putToAll, toString
public CommunicationAspect communicationAspect
public Actor source
public Receiver _receiver
protected IOPort _port
public IntermediateReceiver(CommunicationAspect aspect, Receiver receiver)
aspect
- The communication aspect that receives tokens received by this receiver.receiver
- The receiver wrapped by this intermediate receiver.public IntermediateReceiver(CommunicationAspect aspect, Receiver receiver, IOPort port)
aspect
- The communication aspect that receives tokens received by this receiver.receiver
- The receiver wrapped by this intermediate receiver.port
- The port wrapped by this intermediate receiverpublic void clear() throws IllegalActionException
clear
in interface Receiver
clear
in class AbstractReceiver
IllegalActionException
- Always thrown.public java.util.List<Token> elementList() throws IllegalActionException
elementList
in interface Receiver
elementList
in class AbstractReceiver
IllegalActionException
- Always thrown in this base class.public Token get() throws NoTokenException
get
in interface Receiver
get
in class AbstractReceiver
NoTokenException
- If the delegated receiver throws it.public IOPort getContainer()
getContainer
in interface Receiver
getContainer
in class AbstractReceiver
setContainer(IOPort)
public boolean hasRoom()
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int numberOfTokens)
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
numberOfTokens
- The number of tokens to put into this receiver.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int numberOfTokens)
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
numberOfTokens
- The number of tokens desired.public boolean isKnown()
isKnown
in interface Receiver
isKnown
in class AbstractReceiver
public void put(Token token) throws NoRoomException, IllegalActionException
put
in interface Receiver
put
in class AbstractReceiver
token
- The token to put into the receiver, or null to
put no token.NoRoomException
- If there is no room in the receiver.IllegalActionException
- If the put fails
(e.g. because of incompatible types).public void reset() throws IllegalActionException
reset
in interface Receiver
reset
in class AbstractReceiver
IllegalActionException
- If reset() is not supported by
the domain.public void setContainer(IOPort port) throws IllegalActionException
setContainer
in interface Receiver
setContainer
in class AbstractReceiver
port
- The container.IllegalActionException
- If the container is not of
an appropriate subclass of IOPort. Not thrown in this base class,
but may be thrown in derived classes.getContainer()