Class 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 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

      • hasRoom

        public boolean hasRoom​(int numberOfTokens)
        Return true.
        Specified by:
        hasRoom in interface Receiver
        Specified by:
        hasRoom in class AbstractReceiver
        Parameters:
        numberOfTokens - Ignored in this base class.
        Returns:
        true.
      • hasToken

        public boolean hasToken()
        Return true if the status is present.
        Specified by:
        hasToken in interface Receiver
        Specified by:
        hasToken in class AbstractReceiver
        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 interface Receiver
        Specified by:
        hasToken in class AbstractReceiver
        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 interface Receiver
        Specified by:
        put in class AbstractReceiver
        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.
      • _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.