Package ptolemy.actor.lib.hoc
Class MirrorPort
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.Port
-
- ptolemy.kernel.ComponentPort
-
- ptolemy.actor.IOPort
-
- ptolemy.actor.TypedIOPort
-
- ptolemy.actor.lib.hoc.MirrorPort
-
- All Implemented Interfaces:
java.lang.Cloneable
,HasTypeConstraints
,Typeable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
IterateOverArray.IteratePort
,MetroIIPtidesPlatform.PtidesMirrorPort
,MetroIIPtidesPort
,PtidesPlatform.PtidesMirrorPort
,PtidesPort
public class MirrorPort extends TypedIOPort
This port mirrors the properties of an associated port. That is, if either this port or the associated port is changed by setInput(), setOutput(), setMultiport(), or if it is removed by setContainer(null), or its name is changed by setName(), then the mirror port gets the same changes. The changes are also applied to derived ports (ports that mirror this one because of the class mechanism).Users of this class must override their clone(Workspace) method to re-establish appropriate port associations in the clone. Cloning this port results in a clone with no associations.
- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (neuendor)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.actor.TypedIOPort
TypedIOPort.RunTimeTypeCheckException
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.TypedIOPort
_resolvedType, TYPE
-
Fields inherited from class ptolemy.actor.IOPort
_constantLimit, _constantToken, _constantTokensSent, _hasPortEventListeners, _portEventListeners, CONFIGURATION, defaultValue, RECEIVERS, REMOTERECEIVERS
-
Fields inherited from class ptolemy.kernel.Port
_insideLinks, _relationsList
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description MirrorPort(ComponentEntity container, java.lang.String name)
Create a new instance of a port.MirrorPort(Workspace workspace)
Construct a port in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.MirrorPort
getAssociatedPort()
Return the associated port, or null if there is none.void
setAssociatedPort(MirrorPort port)
Specify an associated port.void
setContainer(Entity container)
Override the base class so that if the container is being set to null, then the associated port is also deleted (via a change request).void
setInput(boolean isInput)
Override the base class to also set the associated port, if there is one.void
setMultiport(boolean isMultiport)
Override the base class to also set the associated port, if there is one.void
setName(java.lang.String name)
Override the base class to also set the associated port, if there is one.void
setOutput(boolean isOutput)
Override the base class to also set the associated port, if there is one.-
Methods inherited from class ptolemy.actor.TypedIOPort
_checkContainer, _checkLiberalLink, _checkLink, _checkType, _checkTypedIOPortContainer, _description, addTypeListener, attributeChanged, broadcast, broadcast, convert, getAutomaticTypeConversion, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, send, send, sendInside, setAutomaticTypeConversion, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.IOPort
_checkLiberalLink, _exportMoMLContents, _getInsideWidth, _getOutsideWidth, _getReceiversLinkedToGroup, _newInsideReceiver, _newInsideReceiver, _newReceiver, _newReceiver, _notifyPortEventListeners, _removeReceivers, _setConstant, _wrapReceiver, addIOPortEventListener, broadcastClear, checkWidthConstraints, createReceivers, deepConnectedInPortList, deepConnectedInPorts, deepConnectedOutPortList, deepConnectedOutPorts, deepGetReceivers, get, get, getChannelForReceiver, getCommunicationAspects, getCurrentTime, getDefaultWidth, getInside, getInsideReceivers, getIOPortEventListeners, getModelTime, getModelTime, getReceivers, getReceivers, getReceivers, getRelationIndex, getRemoteReceivers, getRemoteReceivers, getWidth, getWidthFromConstraints, getWidthInside, hasNewToken, hasNewTokenInside, hasRoom, hasRoomInside, hasToken, hasToken, hasTokenInside, hasWidthConstraints, insertLink, insideSinkPortList, insideSourcePortList, invalidateCommunicationAspects, isInput, isInsideConnected, isKnown, isKnown, isKnownInside, isMultiport, isOutput, isOutsideConnected, liberalLink, link, numberOfSinks, numberOfSources, removeIOPortEventListener, reset, sendClear, sendClearInside, setDefaultWidth, setWidthEquals, setWidthEquals, sinkPortList, sourcePortList, transferInputs, transferOutputs, unlink, unlink, unlinkAll, unlinkAllInside, unlinkInside, unlinkInside
-
Methods inherited from class ptolemy.kernel.ComponentPort
_deepConnectedPortList, _deepConnectedPorts, _deepInsidePortList, _deepInsidePorts, _isInsideLinkable, deepConnectedPortList, deepConnectedPorts, deepInsidePortList, deepInsidePorts, insertInsideLink, insidePortList, insidePorts, insideRelationList, insideRelations, isDeeplyConnected, isInsideGroupLinked, isInsideLinked, isOpaque, numInsideLinks
-
Methods inherited from class ptolemy.kernel.Port
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isGroupLinked, isLinked, linkedRelationList, linkedRelations, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, numLinks
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
Constructor Detail
-
MirrorPort
public MirrorPort(Workspace workspace) throws IllegalActionException
Construct a port 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. The object is added to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the port.- Throws:
IllegalActionException
- If port parameters cannot be initialized.
-
MirrorPort
public MirrorPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new instance of a port.- Parameters:
container
- The container for the port.name
- The name of the port.- Throws:
IllegalActionException
- If the container does not implement TypedActor.NameDuplicationException
- If the name matches that of a port already in the container.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. This overrides the base class to unset the associated port. Users of this class are responsible for resetting it in their clone methods.- Overrides:
clone
in classTypedIOPort
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new NamedObj.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(java.io.Writer, int, String)
-
getAssociatedPort
public MirrorPort getAssociatedPort()
Return the associated port, or null if there is none.- Returns:
- The associated port, or null if there is none.
- See Also:
setAssociatedPort(MirrorPort)
-
setAssociatedPort
public void setAssociatedPort(MirrorPort port)
Specify an associated port. Once this is specified, then any changes made to this port (its name, whether it is an input or output, and whether it is a multiport) are mirrored in the associated port, and any changes made in the associated port are mirrored here.- Parameters:
port
- The associated port.- See Also:
getAssociatedPort()
-
setContainer
public void setContainer(Entity container) throws IllegalActionException, NameDuplicationException
Override the base class so that if the container is being set to null, then the associated port is also deleted (via a change request). Note that if the container of this port is changed to something other than null, there is no reasonable basis for changing the container of the associated port, so it is left unchanged.- Overrides:
setContainer
in classIOPort
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the proposed container is not a ComponentEntity, doesn't implement Actor, or has no name, or the port and container are not in the same workspace. Or it's not nullNameDuplicationException
- If the container already has a port with the name of this port.- See Also:
Port.getContainer()
,Port._checkContainer(Entity)
-
setInput
public void setInput(boolean isInput) throws IllegalActionException
Override the base class to also set the associated port, if there is one.- Overrides:
setInput
in classIOPort
- Parameters:
isInput
- True to make this an input port.- Throws:
IllegalActionException
- If changing the port status is not permitted.
-
setMultiport
public void setMultiport(boolean isMultiport) throws IllegalActionException
Override the base class to also set the associated port, if there is one.- Overrides:
setMultiport
in classIOPort
- Parameters:
isMultiport
- True to make this a multiport.- Throws:
IllegalActionException
- If changing the port status is not permitted.
-
setName
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
Override the base class to also set the associated port, if there is one.- Specified by:
setName
in interfaceNameable
- Overrides:
setName
in classPort
- Parameters:
name
- The new name.- Throws:
IllegalActionException
- If the name has a period.NameDuplicationException
- If there is already a port with the same name in the container.- See Also:
NamedObj.getName()
,NamedObj.getName(NamedObj)
-
setOutput
public void setOutput(boolean isOutput) throws IllegalActionException
Override the base class to also set the associated port, if there is one.- Overrides:
setOutput
in classIOPort
- Parameters:
isOutput
- True to make this an output port.- Throws:
IllegalActionException
- If changing the port status is not permitted.
-
-