
TypedIOPort |
ptolemy.actor.TypedIOPort |
An IOPort with a type. This class implements the Typeable interface.
The type is represented by an instance of Type in data.type package.
It can be declared by calling setTypeEquals(). If this method is not
called, or called with a BaseType.UNKNOWN argument, the type of this port
will be set by type resolution using the type constraints. The type
constraints on this port can be specified using the methods defined in
the Typeable interface.
This class keeps a list of TypeListeners. Whenever the type
changes, this class will generate an instance of TypeEvent and pass it
to the listeners by calling their typeChanged() method. A TypeListener
register its interest in the type change event of this port by calling
addTypeListener(), and can be removed from the listener list by calling
the removeTypeListener().
A TypedIOPort can only link to instances of TypedIORelation. Derived
classes may further constrain links to a subclass of TypedIORelation.
To do this, they should override the protected methods _link() and
_linkInside() to throw an exception if their arguments are not of the
appropriate type. Similarly, an TypeIOPort can only be contained by a
class derived from ComponentEntity and implementing the TypedActor
interface. Subclasses may further constrain the containers by overriding
_checkContainer().
Note that actors that call some of the setTypeXXX methods
may also need to have a clone() method. Although the base classes
neatly handle most aspects of the clone operation, there are
subtleties involved with cloning type constraints. Absolute type
constraints on ports and parameters are carried automatically into the
clone, so clone() methods should never call setTypeEquals(). However,
relative type constraints of the other setTypeXXX() methods are
not cloned automatically because of the difficulty of ensuring that
the other object being referred to in a relative constraint is the
intended one.
For example the Ramp actor constructor calls:
output.setTypeAtLeast(init);
so the clone() method of the Ramp actor calls:
newObject.output.setTypeAtLeast(newObject.init);
Author(s): Yuhong Xiong, Lukito Muliadi
Version:$Id: TypedIOPort.java,v 1.163 2006/03/28 23:56:54 cxh Exp $
Pt.Proposed Rating:Green (yuhong)
Pt.Accepted Rating:Yellow (neuendor)