Class RecordAssembler

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

    public class RecordAssembler
    extends TypedAtomicActor
    On each firing, read one token from each connected input port and assemble them into a RecordToken. Disconnected input ports are ignored. The labels for the RecordToken much match the names of the input ports. This is achieved using two type constraints:
    • output ≥ {x = typeOf(inputPortX), y = typeOf(inputPortY), ..} , which requires the types of the input ports to be compatible with the corresponding types in the output record.
    • each input ≥ the type of the corresponding field inside the output record, which together with the first constraint forces the input types to be exactly equal to the types of the corresponding fields in the output record. This constraint is intended to back- propagate type information upstream, not to assure type compatibility. Therefore, this constraint is only set up for input ports that do not already have a type declared.
    Note that the output record is not required to contain a corresponding field for every input, as downstream actors might require fewer fields in the record they accept for input.

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

    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 add to the record contain a period, because periods are not allowed in port names.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Yuhong Xiong, Marten Lohstroh
    See Also:
    RecordDisassembler
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (yuhong)
    • Field Detail

      • _portMap

        protected java.util.Map<java.lang.String,​TypedIOPort> _portMap
        Keeps track of which name or alias is associated with which port.
    • 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 two type constraints.
        • output ≥ {x = typeOf(inputPortX), y = typeOf(inputPortY), ..} , which requires the types of the input ports to be compatible with the corresponding types in the output record.
        • each input ≥ the type of the corresponding field inside the output record, which together with the first constraint forces the input types to be exactly equal to the types of the corresponding fields in the output record. This constraint is intended to back- propagate type information upstream, not to assure type compatibility. Therefore, this constraint is only set up for input ports that do not already have a type declared.
        Note that the output record is not required to contain a corresponding field for every input, as downstream actors might require fewer fields in the record they accept for input.
        Overrides:
        _customTypeConstraints in class TypedAtomicActor
        Returns:
        A set of type constraints
        See Also:
        ConstructAssociativeType, ExtractFieldType
      • _newPortMap

        protected java.util.Map<java.lang.String,​TypedIOPort> _newPortMap()
        Return a new _portMap, which is a map between port names and strings. Derived classes like OrderedRecordAssembler would return a map with a different ordering.
        Returns:
        a Map from port names to TypedIOPorts.
      • _mapPorts

        protected void _mapPorts()
        Map port names or aliases to port objects. If the mapping has changed, then invalidate the resolved types, which forces new type constraints with appropriate field names to be generated.