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 Edward A. Lee, Xiaojun Liu @version $Id: ComponentPort.java,v 1.105 2006/09/21 15:40:03 cxh Exp $ @since Ptolemy II 0.2 @Pt.ProposedRating Green (eal) @Pt.AcceptedRating Green (bart)
|
|