Class GLBFunction

  • All Implemented Interfaces:
    InequalityTerm

    public class GLBFunction
    extends MonotonicFunction
    This class implements a monotonic function that returns the greatest lower bound (GLB) of its arguments. These arguments are the port type variables of the destination ports of the TypedIOPort passed to the constructor. This function is used to define a type constraint asserting that the type of the output of this port is greater than or equal to the GLB of its destinations.

    NOTE: It may seem counterintuitive that the constraint is "greater than or equal to" rather than "less than or equal to". But the latter constraint is already implied by the connections, since the output port type is required to be less than or equal to each destination port type. The combination of these constraints has the effect of setting the type of the output equal to the GLB of the types of the destination ports. This resolved type is, in fact, the most specific type that satisfies the constraints of all the downstream ports.

    Since:
    Ptolemy II 10.0
    Version:
    $Id: GLBFunction.java$
    Author:
    Edward A. Lee, Marten Lohstroh
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (eal)
    • Constructor Summary

      Constructors 
      Constructor Description
      GLBFunction​(TypedIOPort sourcePort)
      Construct a GLBFunction that finds the greatest lower bound of the type variable of the destination ports connected to the TypedIOPort that is given as an argument.
    • Field Detail

      • _cachedTypes

        protected java.util.Set<Type> _cachedTypes
        The constant types found in destination ports.
      • _cachedTerms

        protected InequalityTerm[] _cachedTerms
        The types terms found in destination ports.
      • _previousWorkspaceVersion

        protected long _previousWorkspaceVersion
        The workspace version number at time of last update of arguments.
      • _sourcePort

        protected TypedIOPort _sourcePort
        The source port.
    • Constructor Detail

      • GLBFunction

        public GLBFunction​(TypedIOPort sourcePort)
        Construct a GLBFunction that finds the greatest lower bound of the type variable of the destination ports connected to the TypedIOPort that is given as an argument. If the boolean argument inside is true then the port is required to be an input port and the arguments for this GLBFunction will be the inside destination ports. Otherwise, the port is required to be an output port and the arguments for this GLBFunction will be the outside destination ports.
        Parameters:
        sourcePort - The port connected to the ports of which their type variables are used to calculate the greatest lower bound.
    • Method Detail

      • getConstants

        public Type[] getConstants()
        Return the type constants for this function, which are the type constant types for all the destination ports.
        Returns:
        An array of Types.
      • _updateArguments

        protected void _updateArguments()
        Update the arguments used in getValue(), which are the InequalityTerms and Types of the destination ports. The arguments are only updated if the workspace version has changed.
      • toString

        public java.lang.String toString()
        Provide a more descriptive string representation.
        Overrides:
        toString in class MonotonicFunction
        Returns:
        A description of this term.