Interface PortCodeGenerator

  • All Known Implementing Classes:
    IOPort, IOPort, MultiCompositePort, RefinementPort

    public interface PortCodeGenerator
    An interface for Port Adapters to generate port specific code. All cg port adapter implementations should implement this interface.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Man-kit Leung, Bert Rodiers
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String generateGetAndFree​(java.lang.String channel, java.lang.String offset)
      Generate the code to get a token from a port and then free it.
      java.lang.String generateGetCode​(java.lang.String channel, java.lang.String offset)
      Generate the code to get a token from a port.
      java.lang.String generateGetCodeWithoutType​(java.lang.String channel, java.lang.String offset)
      Generate the code to get a token from a port, but don't include the type, for example payload.Int.
      java.lang.String generateHasTokenCode​(java.lang.String channel, java.lang.String offset)
      Generates code to check the receiver has a token.
      java.lang.String generatePutCode​(java.lang.String channel, java.lang.String offset, java.lang.String dataToken)
      Generate the code to put a token to a port.
      java.lang.String generatePutLocalInsideCode​(java.lang.String channel, java.lang.String offset, java.lang.String dataToken)
      Generate the code to put a token to a port's local inside receivers.
    • Method Detail

      • generateGetCode

        java.lang.String generateGetCode​(java.lang.String channel,
                                         java.lang.String offset)
                                  throws IllegalActionException
        Generate the code to get a token from a port.
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generateGetCodeWithoutType

        java.lang.String generateGetCodeWithoutType​(java.lang.String channel,
                                                    java.lang.String offset)
                                             throws IllegalActionException
        Generate the code to get a token from a port, but don't include the type, for example payload.Int.
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generateGetAndFree

        java.lang.String generateGetAndFree​(java.lang.String channel,
                                            java.lang.String offset)
                                     throws IllegalActionException
        Generate the code to get a token from a port and then free it.
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generatePutCode

        java.lang.String generatePutCode​(java.lang.String channel,
                                         java.lang.String offset,
                                         java.lang.String dataToken)
                                  throws IllegalActionException
        Generate the code to put a token to a port.
        Parameters:
        channel - The channel for which the send code is generated.
        offset - The offset in the array representation of the port.
        dataToken - The token to be sent
        Returns:
        The code that sends the dataToken on the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generatePutLocalInsideCode

        java.lang.String generatePutLocalInsideCode​(java.lang.String channel,
                                                    java.lang.String offset,
                                                    java.lang.String dataToken)
                                             throws IllegalActionException
        Generate the code to put a token to a port's local inside receivers.
        Parameters:
        channel - The channel for which the send code is generated.
        offset - The offset in the array representation of the port.
        dataToken - The token to be sent
        Returns:
        The code that sends the dataToken on the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generateHasTokenCode

        java.lang.String generateHasTokenCode​(java.lang.String channel,
                                              java.lang.String offset)
                                       throws IllegalActionException
        Generates code to check the receiver has a token.
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that generates has token from the channel. FIXME: potentially, we could also pass in a boolean that indicates whether the port the channel resides is a multiport, if it is, then only a static variable is needed instead of an array of length 1.
        Throws:
        IllegalActionException - If code can't be generated.