Package ptolemy.actor

Class TypedCompositeActor

    • Constructor Detail

      • TypedCompositeActor

        public TypedCompositeActor()
        Construct a TypedCompositeActor in the default workspace with no container and an empty string as its name. Add the actor to the workspace directory. You should set the local director or executive director before attempting to send data to the actor or to execute it. Increment the version number of the workspace.
      • TypedCompositeActor

        public TypedCompositeActor​(Workspace workspace)
        Construct a TypedCompositeActor in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. You should set the local director or executive director before attempting to send data to the actor or to execute it. Add the actor to the workspace directory. Increment the version number of the workspace.
        Parameters:
        workspace - The workspace that will list the actor.
      • TypedCompositeActor

        public TypedCompositeActor​(CompositeEntity container,
                                   java.lang.String name)
                            throws IllegalActionException,
                                   NameDuplicationException
        Construct a TypedCompositeActor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This actor will have no local director initially, and its executive director will be simply the director of the container.
        Parameters:
        container - The container.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        React to a change in an attribute. If the name of the attribute is "enableBackwardTypeInference" then invalidate resolved types.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - Not thrown in this base class. Derived classes can throw this exception if type change is not allowed.
      • attributeTypeChanged

        public void attributeTypeChanged​(Attribute attribute)
                                  throws IllegalActionException
        React to a change in the type of an attribute. This method is called by a contained attribute when its type changes. In this base class, the method informs the director to invalidate type resolution, if the director is not null. Thus, by default, attribute type changes cause type resolution to be redone at the next opportunity. If an actor does not allow attribute types to change, then it should override this method.
        Overrides:
        attributeTypeChanged in class NamedObj
        Parameters:
        attribute - The attribute whose type changed.
        Throws:
        IllegalActionException - Not thrown in this base class. Derived classes can throw this exception if type change is not allowed.
      • isBackwardTypeInferenceEnabled

        public boolean isBackwardTypeInferenceEnabled()
        Return true if backward type inference is enabled. If this composite actor is opaque, then it looks for an attribute named "enableBackwardTypeInference" inside of it, and if it exists, returns its boolean value. If it does not exist, it looks up the hierarchy until the top-level for such an attribute, and if it exists, again given that the container is opaque, returns its boolean value. If it does not exist, then return false. For backward compatibility, if it does not exist, then look for a parameter named "disableBackwardTypeInference" at the top level and return its value, if it exists.
        Specified by:
        isBackwardTypeInferenceEnabled in interface TypedActor
        Returns:
        True if backward type inference is enabled.
      • newPort

        public Port newPort​(java.lang.String name)
                     throws NameDuplicationException
        Create a new TypedIOPort with the specified name. The container of the port is set to this actor. This method is write-synchronized on the workspace.
        Overrides:
        newPort in class CompositeActor
        Parameters:
        name - The name for the new port.
        Returns:
        A new TypedIOPort.
        Throws:
        NameDuplicationException - If this actor already has a port with the specified name.
      • newRelation

        public ComponentRelation newRelation​(java.lang.String name)
                                      throws NameDuplicationException
        Create a new TypedIORelation with the specified name, add it to the relation list, and return it. Derived classes can override this to create domain-specific subclasses of TypedIORelation. This method is write-synchronized on the workspace.
        Overrides:
        newRelation in class CompositeActor
        Parameters:
        name - The name for the new TypedIORelation.
        Returns:
        A new TypedIORelation.
        Throws:
        NameDuplicationException - If name collides with a name already on the container's contents list.
      • resolveTypes

        public static void resolveTypes​(TypedCompositeActor topLevel)
                                 throws TypeConflictException
        Do type checking and type resolution on the specified composite actor. The specified actor must be the top level container of the model.
        Parameters:
        topLevel - The top level TypedCompositeActor.
        Throws:
        java.lang.IllegalArgumentException - If the specified actor is not the top level container. That is, its container is not null.
        TypeConflictException - If a type conflict is detected.
      • typeConstraints

        public java.util.Set<Inequality> typeConstraints()
                                                  throws IllegalActionException
        Return the type constraints of this typed composite actor. The constraints have the form of a set of inequalities. The constraints come from three sources, the contained actors, the contained Typeables, and (for opaque actors) the topology of connections between actors. To generate the constraints based on the topology, this method scans all the connections within this composite between opaque TypedIOPorts. If the type of the ports on one or both ends of a connection is not declared, a type constraint is formed that requires the type of the port at the source end of the connection to be less than or equal to the type at the destination port. To collect the type constraints from the contained actors, This method recursively calls the typeConstraints() method of the contained actors and combine all the constraints together. The type constraints from contained Typeables (ports and parameters) are collected by calling the typeConstraints() method of all the contained Typeables.

        This method is read-synchronized on the workspace.

        Specified by:
        typeConstraints in interface TypedActor
        Returns:
        a list of instances of Inequality.
        Throws:
        IllegalActionException - If the typeConstraints of one of the deeply contained objects throws it.
        See Also:
        Inequality
      • typeConstraintList

        @Deprecated
        public java.util.List typeConstraintList()
                                          throws IllegalActionException
        Deprecated.
        Use typeConstraints().
        Return the type constraints of this variable. The constraints include the ones explicitly set to this variable, plus the constraint that the type of this variable must be no less than its current type, if it has one. The constraints are a list of inequalities.
        Returns:
        a list of Inequality objects.
        Throws:
        IllegalActionException - If thrown while constructing the set of type constraints.
        See Also:
        Inequality
      • _addEntity

        protected void _addEntity​(ComponentEntity entity)
                           throws IllegalActionException,
                                  NameDuplicationException
        Add an actor to this container with minimal error checking. This overrides the base-class method to make sure the argument implements the TypedActor interface. This method does not alter the actor in any way. It is not synchronized on the workspace, so the caller should be.
        Overrides:
        _addEntity in class CompositeActor
        Parameters:
        entity - TypedActor to contain.
        Throws:
        IllegalActionException - If the actor has no name, or the action would result in a recursive containment structure, or the argument does not implement the TypedActor interface.
        NameDuplicationException - If the name collides with a name already on the actor contents list.
      • _addPort

        protected void _addPort​(Port port)
                         throws IllegalActionException,
                                NameDuplicationException
        Add a port to this actor. This overrides the base class to throw an exception if the proposed port is not an instance of TypedIOPort. This method should not be used directly. Call the setContainer() method of the port instead. This method does not set the container of the port to point to this actor. It assumes that the port is in the same workspace as this actor, but does not check. The caller should check. This method is not synchronized on the workspace, so the caller should be.
        Overrides:
        _addPort in class CompositeActor
        Parameters:
        port - The TypedIOPort to add to this actor.
        Throws:
        IllegalActionException - If the port class is not acceptable to this actor, or the port has no name.
        NameDuplicationException - If the port name collides with a name already in the actor.
      • _addRelation

        protected void _addRelation​(ComponentRelation relation)
                             throws IllegalActionException,
                                    NameDuplicationException
        Add a relation to this container. This overrides the base class to throw an exception if the proposed relation is not an instance of TypedIORelation. This method should not be used directly. Call the setContainer() method of the relation instead. This method does not set the container of the relation to refer to this container. This method is not synchronized on the workspace, so the caller should be.
        Overrides:
        _addRelation in class CompositeActor
        Parameters:
        relation - The TypedIORelation to contain.
        Throws:
        IllegalActionException - If the relation has no name, or is not an instance of TypedIORelation.
        NameDuplicationException - If the name collides with a name already on the contained relations list.
      • _checkTypesFromTo

        protected java.util.List<Inequality> _checkTypesFromTo​(TypedIOPort sourcePort,
                                                               java.util.List<TypedIOPort> destinationPortList)
        Check types from a source port to a group of destination ports, assuming the source port is connected to all the ports in the group of destination ports. Return a list of instances of Inequality that have type conflicts.
        Parameters:
        sourcePort - The source port.
        destinationPortList - A list of destination ports.
        Returns:
        A list of instances of Inequality indicating the type constraints that are not satisfied.
      • _destinationTypeConstraints

        protected java.util.List<Inequality> _destinationTypeConstraints​(TypedIOPort source)
        Return the type constraints on all connections starting from the specified source port to all the ports in a group of destination ports.
        Parameters:
        source - The source port.
        Returns:
        A list of instances of Inequality.