Class UnionDisassembler

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class UnionDisassembler
    extends TypedAtomicActor
    On each firing, read one UnionToken from the input port and send out the value to the output port that matches the label name of the input token. This actor is polymorphic. The labels for the UnionToken must match the names of the output ports. This is achieved using three type constraints:
    • input ≥ {|x = typeOf(outputPortX), y = typeOf(outputPortY), ..|}, which requires the types of the fields in the input union to be compatible with the corresponding output ports. This constraint is set in the constructor of this class.
    • each output ≥ the type of the corresponding field inside the input union, which is similar to the usual default constraints, however this constraint establishes a dependency between fields inside the input union and the outputs, instead of just between inputs and outputs.
    Note that the constraint input ≥ {|x = GENERAL, y = GENERAL, ..|} , which is used in RecordDisassembler to force the input to contain a corresponding field for each output port, is useless for UnionDisassembler. This is due to the inverse width subtyping of UnionToken.
    Since:
    Ptolemy II 5.2
    Version:
    $Id$
    Author:
    Yang Zhao, Marten Lohstroh
    See Also:
    RecordDisassembler, UnionType
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (marten)
    • Method Detail

      • notifyOfNameChange

        public void notifyOfNameChange​(NamedObj object)
        React to a name change of contained ports. Update the internal mapping from names and aliases to port objects, and invalidate the resolved types.
        Overrides:
        notifyOfNameChange in class NamedObj
        Parameters:
        object - The object that changed.
      • _customTypeConstraints

        protected java.util.Set<Inequality> _customTypeConstraints()
        Set up and returns two type constraints.
        • input ≥ {|x = typeOf(outputPortX), y = typeOf(outputPortY) , ..|}, which requires the types of the fields in the input union to be compatible with the types of the corresponding output ports.
        • each output ≥ the type of the corresponding field inside the input union, which is similar to the usual default constraints, however this constraint establishes a dependency between fields inside the input union and the outputs of this actor, instead of just between its inputs and outputs.

        Note that the constraint input ≤ {|x = GENERAL, y = GENERAL, ..|} , which is used in RecordDisassembler to force the input to contain a corresponding field for each output port, is useless for UnionDisassembler. This is due to the inverse width subtyping of UnionToken.

        Overrides:
        _customTypeConstraints in class TypedAtomicActor
        Returns:
        A set of Inequality instances
        See Also:
        ConstructAssociativeType, ExtractFieldType