Package ptolemy.actor

Class TypedIORelation

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    DistributedTypedIORelation, TestTypedIORelation

    public class TypedIORelation
    extends IORelation
    This class overrides some of the methods in IORelation to ensure that TypedIOPorts are only connected to TypedIOPorts. I.e., Instances of TypedIORelation can only be linked to instances of TypedIOPort. Derived classes may further constrain this to subclasses of TypedIOPort. Such derived classes should override the protected method _checkPort() to throw an exception.

    To link a TypedIOPort to a TypedIORelation, use the link() or liberalLink() method in the TypedIOPort class. To remove a link, use the unlink() method.

    The container for instances of this class can only be instances of TypedCompositeActor. Derived classes may wish to further constrain the container to subclasses of TypedComponentEntity. To do this, they should override the _checkContainer() method.

    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Yuhong Xiong
    Pt.AcceptedRating:
    Green (liuxj)
    Pt.ProposedRating:
    Green (yuhong)
    • Constructor Detail

      • TypedIORelation

        public TypedIORelation()
        Construct a relation in the default workspace with an empty string as its name. Add the relation to the directory of the workspace.
      • TypedIORelation

        public TypedIORelation​(Workspace workspace)
        Construct a relation in the specified workspace with 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. Add the relation to the workspace directory.
        Parameters:
        workspace - The workspace that will list the relation.
      • TypedIORelation

        public TypedIORelation​(CompositeEntity container,
                               java.lang.String name)
                        throws IllegalActionException,
                               NameDuplicationException
        Construct a relation with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This relation 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. This constructor write-synchronizes on the workspace.
        Parameters:
        container - The container.
        name - The name of the relation.
        Throws:
        IllegalActionException - If the container is incompatible with this relation.
        NameDuplicationException - If the name coincides with a relation already in the container.
    • Method Detail

      • _checkContainer

        protected void _checkContainer​(CompositeEntity container)
                                throws IllegalActionException
        Override the method in the super class to constrain the container to be an instance of TypedCompositeActor, or to be null.
        Overrides:
        _checkContainer in class ComponentRelation
        Parameters:
        container - The proposed container.
        Throws:
        IllegalActionException - If the container is not a TypedCompositeActor or null, or this relation and the container are not in the same workspace.
      • _checkPort

        protected void _checkPort​(Port port)
                           throws IllegalActionException
        Throw an exception if the specified port cannot be linked to this relation (is not of class TypedIOPort).
        Overrides:
        _checkPort in class IORelation
        Parameters:
        port - The candidate port to link to.
        Throws:
        IllegalActionException - If the port is not an TypedIOPort.
      • _checkRelation

        protected void _checkRelation​(Relation relation,
                                      boolean symmetric)
                               throws IllegalActionException
        Throw an exception if the specified relation is not an instance of TypedIORelation.
        Overrides:
        _checkRelation in class IORelation
        Parameters:
        relation - The relation to link to.
        symmetric - If true, the call _checkRelation on the specified relation with this as an argument.
        Throws:
        IllegalActionException - If this port has no container, or if this port is not an acceptable port for the specified relation.