Class RecordDisassembler

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

    public class RecordDisassembler
    extends TypedAtomicActor
    On each firing, read one RecordToken from the input port and send out the fields of the RecordToken to multiple output ports. The labels for the RecordToken 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 record to be compatible with the types of the corresponding output ports.
    • input ≤ {x = GENERAL, y = GENERAL, ..}, which requires the input record to contain a corresponding field for each output port.
    • each output ≥ the type of the corresponding field inside the input record, which is similar to the usual default constraints, however this constraint establishes a dependency between fields inside the input record and the outputs of this actor, instead of just between its inputs and outputs.

    If the received Token contains more fields than the output ports, the extra fields are ignored.

    To use this class, instantiate it, and then add output ports (instances of TypedIOPort). This actor is polymorphic. The type constraint is that the type of each output port is no less than the type of the corresponding record field.

    Note that if the display name of a port is set, display name is used in the type constraints instead of name. This is useful in case fields to extract from the record contain a period, because periods are not allowed in port names.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Yuhong Xiong, Steve Neuendorffer, Edward A. Lee, Marten Lohstroh
    See Also:
    RecordAssembler
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (yuhong)
    • 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 return three type constraints.
        • input ≥ {x = typeOf(outputPortX), y = typeOf(outputPortY), ..} , which requires the types of the fields in the input record to be compatible with the types of the corresponding output ports.
        • input ≤ {x = GENERAL, y = GENERAL, ..}, which requires the input record to contain a corresponding field for each output port.
        • each output ≥ the type of the corresponding field inside the input record, which is similar to the usual default constraints, however this constraint establishes a dependency between fields inside the input record and the outputs of this actor, instead of just between its inputs and outputs.
        Overrides:
        _customTypeConstraints in class TypedAtomicActor
        Returns:
        A set of Inequality instances
        See Also:
        ConstructAssociativeType, ExtractFieldType