Package ptolemy.actor

Class IntermediateReceiver

  • All Implemented Interfaces:
    Receiver

    public class IntermediateReceiver
    extends AbstractReceiver
    A receiver that delegates to another receiver all method calls except 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().

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Patricia Derler, Edward A. Lee
    Pt.AcceptedRating:
    Red (derler)
    Pt.ProposedRating:
    Yellow (derler)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • communicationAspect

        public CommunicationAspect communicationAspect
        communication aspect that receives tokens from this receiver.
      • source

        public Actor source
        The source actor that sent a token to this receiver.
      • _receiver

        public Receiver _receiver
        Target receiver that is wrapped by this intermediate receiver.
      • _port

        protected IOPort _port
        The port.
    • Constructor Detail

      • IntermediateReceiver

        public IntermediateReceiver​(CommunicationAspect aspect,
                                    Receiver receiver)
        Construct an intermediate receiver with no container that wraps the specified receiver using the specified communication aspect.
        Parameters:
        aspect - The communication aspect that receives tokens received by this receiver.
        receiver - The receiver wrapped by this intermediate receiver.
      • IntermediateReceiver

        public IntermediateReceiver​(CommunicationAspect aspect,
                                    Receiver receiver,
                                    IOPort port)
        Construct an intermediate receiver with no container that wraps the specified receiver using the specified communication aspect.
        Parameters:
        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 receiver