Package ptolemy.actor.util
Class GLBFunction
- java.lang.Object
-
- ptolemy.data.type.MonotonicFunction
-
- ptolemy.actor.util.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)
-
-
Field Summary
Fields Modifier and Type Field Description protected InequalityTerm[]
_cachedTerms
The types terms found in destination ports.protected java.util.Set<Type>
_cachedTypes
The constant types found in destination ports.protected long
_previousWorkspaceVersion
The workspace version number at time of last update of arguments.protected TypedIOPort
_sourcePort
The source port.
-
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_updateArguments()
Update the arguments used ingetValue()
, which are the InequalityTerms and Types of the destination ports.Type[]
getConstants()
Return the type constants for this function, which are the type constant types for all the destination ports.java.lang.Object
getValue()
Return the current value of this monotonic function.InequalityTerm[]
getVariables()
Return the type variables for this function, which are the type variables for all the destination ports.java.lang.String
toString()
Provide a more descriptive string representation.-
Methods inherited from class ptolemy.data.type.MonotonicFunction
getAssociatedObject, getVerboseString, initialize, isSettable, isValueAcceptable, setValue
-
-
-
-
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 thisGLBFunction
will be the inside destination ports. Otherwise, the port is required to be an output port and the arguments for thisGLBFunction
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
-
getValue
public java.lang.Object getValue() throws IllegalActionException
Return the current value of this monotonic function.- Specified by:
getValue
in interfaceInequalityTerm
- Specified by:
getValue
in classMonotonicFunction
- Returns:
- A Type.
- Throws:
IllegalActionException
- If thrown while getting the value of the cached terms.- See Also:
MonotonicFunction.setValue(Object)
-
getVariables
public InequalityTerm[] getVariables()
Return the type variables for this function, which are the type variables for all the destination ports.- Specified by:
getVariables
in interfaceInequalityTerm
- Specified by:
getVariables
in classMonotonicFunction
- Returns:
- An array of InequalityTerms.
-
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 ingetValue()
, 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 classMonotonicFunction
- Returns:
- A description of this term.
-
-