
ComponentPort |
ptolemy.kernel.ComponentPort |
A port supporting hierarchy. A component port can have "inside"
links as well as the usual "outside" links supported by the base
class. That is, while the basic port has only links to relations
that are on the exterior of its containing entity, this port can have
links to relations on the interior.
An inside link is a link to a relation that is contained by the
container of the port.
A ComponentPort may be transparent or opaque. If it is transparent,
then "deep" accesses of the topology see through the port.
Methods that read the topology come in two versions, shallow and deep.
The deep versions pass through transparent ports. This is
done with a simple rule. If a transparent port is encountered from
inside, then the traversal continues with its outside links. If it
is encountered from outside, then the traversal continues with its
inside links. A ComponentPort is opaque if its container is opaque.
(its isOpaque() method returns true). Derived classes may use other
strategies to specify whether a port is opaque.
Normally, links to a transparent port from the outside are to
relations contained by the container of the container of the port.
Links from the inside are to relations contained by the container
of the port. That is, levels of the hierarchy are not crossed.
For a few applications, links that cross levels of the hierarchy
are needed. The links in these connections are created
using the liberalLink() method. The link() method
prohibits such links, throwing an exception if they are attempted
(most applications will prohibit level-crossing connections by using
only the link() method).
A ComponentPort can link to any instance of ComponentRelation.
An attempt to link to an instance of Relation will trigger an exception.
Derived classes may wish to further constrain links to a subclass
of ComponentRelation. To do this, subclasses should override the
protected methods _checkLink() and _checkLiberalLink() to throw an exception
if their arguments are relations that are not of the appropriate
subclass. Similarly, a ComponentPort can only be contained by a
ComponentEntity, and an attempt to set the container to an instance
of Entity will trigger an exception. If a subclass wishes to
constrain the containers of the port to be of a subclass of
ComponentEntity, they should override _checkContainer().
Author(s): Edward A. Lee, Xiaojun Liu
Version:$Id: ComponentPort.java,v 1.102 2005/10/24 19:09:11 cxh Exp $
Pt.Proposed Rating:Green (eal)
Pt.Accepted Rating:Green (bart)