Package ptolemy.domains.algebraic.kernel
Class AlgebraicLoopReceiver
- java.lang.Object
-
- ptolemy.actor.AbstractReceiver
-
- ptolemy.domains.algebraic.kernel.AlgebraicLoopReceiver
-
- All Implemented Interfaces:
Receiver
public class AlgebraicLoopReceiver extends AbstractReceiver
The receiver for use with AlgebraicLoopDirector or any of its subclasses. This receiver can be either present or absent. If it is present, then it has a token, which provides a value. This receiver has capacity 1, honors the defaultValue parameter, and its value can be overwritten or cleared at any time (made absent).At first, an instance of this class has status absent, unless it has a defaultValue parameter. The clear() method makes the status absent. The put() method makes the status present, and provides a value. The reset() method reverts the status to absent or to the default value if there is one.
The isKnown() method and hasRoom() methods always return true.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Constructor Summary
Constructors Constructor Description AlgebraicLoopReceiver()
Construct an AlgebraicLoopReceiver with unknown status.AlgebraicLoopReceiver(AlgebraicLoopDirector director)
Construct an AlgebraicLoopReceiver with unknown status.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Token
_getUpdatedValue()
If this receiver is a break variable, then return the stored updated value.protected void
_setInitialValue(Token initialValue)
Indicate to this receiver that it is a break variable and set its initial value.void
clear()
Set the status of this receiver to be absent.Token
get()
Return the contained Token.boolean
hasRoom()
Return true.boolean
hasRoom(int numberOfTokens)
Return true.boolean
hasToken()
Return true if the status is present.boolean
hasToken(int numberOfTokens)
Return true if the argument is 1 and this mailbox is not empty, and otherwise return false.void
put(Token token)
If the specified token is non-null, then set the status of this receiver to present, and to contain the specified token.void
reset()
Clear stored tokens.-
Methods inherited from class ptolemy.actor.AbstractReceiver
elementList, getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, setContainer, toString
-
-
-
-
Constructor Detail
-
AlgebraicLoopReceiver
public AlgebraicLoopReceiver()
Construct an AlgebraicLoopReceiver with unknown status. This constructor does not need a director.
-
AlgebraicLoopReceiver
public AlgebraicLoopReceiver(AlgebraicLoopDirector director)
Construct an AlgebraicLoopReceiver with unknown status.- Parameters:
director
- The director of this receiver.
-
-
Method Detail
-
clear
public void clear() throws IllegalActionException
Set the status of this receiver to be absent.- Specified by:
clear
in interfaceReceiver
- Overrides:
clear
in classAbstractReceiver
- Throws:
IllegalActionException
- Always thrown.
-
get
public Token get() throws NoTokenException
Return the contained Token. If there is none, throw an exception.- Specified by:
get
in interfaceReceiver
- Specified by:
get
in classAbstractReceiver
- Returns:
- The token contained by this receiver.
- Throws:
NoTokenException
- If this receiver is absent.
-
hasRoom
public boolean hasRoom()
Return true.- Specified by:
hasRoom
in interfaceReceiver
- Specified by:
hasRoom
in classAbstractReceiver
- Returns:
- true.
-
hasRoom
public boolean hasRoom(int numberOfTokens)
Return true.- Specified by:
hasRoom
in interfaceReceiver
- Specified by:
hasRoom
in classAbstractReceiver
- Parameters:
numberOfTokens
- Ignored in this base class.- Returns:
- true.
-
hasToken
public boolean hasToken()
Return true if the status is present.- Specified by:
hasToken
in interfaceReceiver
- Specified by:
hasToken
in classAbstractReceiver
- Returns:
- True if the receiver has a token.
-
hasToken
public boolean hasToken(int numberOfTokens) throws java.lang.IllegalArgumentException
Return true if the argument is 1 and this mailbox is not empty, and otherwise return false.- Specified by:
hasToken
in interfaceReceiver
- Specified by:
hasToken
in classAbstractReceiver
- Parameters:
numberOfTokens
- The number of tokens to get from the receiver.- Returns:
- True if the argument is 1 and this mailbox is not empty.
- Throws:
java.lang.IllegalArgumentException
- If the argument is not positive. This is a runtime exception, so it does not need to be declared explicitly.
-
put
public void put(Token token) throws IllegalActionException
If the specified token is non-null, then set the status of this receiver to present, and to contain the specified token. If the specified token is null, then set the status to absent.- Specified by:
put
in interfaceReceiver
- Specified by:
put
in classAbstractReceiver
- Parameters:
token
- The token to be put into this receiver.- Throws:
java.lang.IllegalArgumentException
- If the argument is null.IllegalActionException
- If a token is present and cannot be compared to the specified token.
-
reset
public void reset()
Clear stored tokens.- Specified by:
reset
in interfaceReceiver
- Overrides:
reset
in classAbstractReceiver
-
_getUpdatedValue
protected Token _getUpdatedValue()
If this receiver is a break variable, then return the stored updated value. Otherwise, return the current value.- Returns:
- The token stored by
-
_setInitialValue
protected void _setInitialValue(Token initialValue)
Indicate to this receiver that it is a break variable and set its initial value. If this receiver is a break variable, then put() does not update the value of the receiver. Instead, the value provided to put() is stored to be retrieved by _getUpdatedValue().- Parameters:
initialValue
- The initial value.
-
-