ptolemy.actor.lib.hoc
Class MirrorPort

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.Port
          extended by ptolemy.kernel.ComponentPort
              extended by ptolemy.actor.IOPort
                  extended by ptolemy.actor.TypedIOPort
                      extended by ptolemy.actor.lib.hoc.MirrorPort
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
IterateOverArray.IteratePort

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: MirrorPort.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (neuendor)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  MirrorPort _associatedPort
          The associated port, if there is one.
private  boolean _settingAssociatedPort
          Flag indicating that we are setting the associated port.
 
Fields inherited from class ptolemy.actor.TypedIOPort
TYPE
 
Fields inherited from class ptolemy.actor.IOPort
_hasPortEventListeners, _portEventListeners, CONFIGURATION, RECEIVERS, REMOTERECEIVERS
 
Fields inherited from class ptolemy.kernel.Port
_insideLinks, _relationsList
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
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
 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, _description, addTypeListener, attributeChanged, broadcast, broadcast, convert, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, send, send, sendInside, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.IOPort
_checkLiberalLink, _exportMoMLContents, _getInsideWidth, _getOutsideWidth, _getReceiversLinkedToGroup, _newInsideReceiver, _newReceiver, _notifyPortEventListeners, _removeReceivers, addIOPortEventListener, broadcastClear, checkWidthConstraints, createReceivers, deepConnectedInPortList, deepConnectedInPorts, deepConnectedOutPortList, deepConnectedOutPorts, deepGetReceivers, get, get, getChannelForReceiver, getCurrentTime, getDefaultWidth, getInside, getInsideReceivers, getModelTime, getReceivers, getReceivers, getReceivers, getRelationIndex, getRemoteReceivers, getRemoteReceivers, getWidth, getWidthFromConstraints, getWidthInside, hasRoom, hasRoomInside, hasToken, hasToken, hasTokenInside, hasWidthConstraints, insertLink, insideSinkPortList, insideSourcePortList, isInput, isInsideConnected, isKnown, isKnown, isKnownInside, isMultiport, isOutput, isOutsideConnected, liberalLink, link, numberOfSinks, numberOfSources, removeIOPortEventListener, 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, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_associatedPort

private MirrorPort _associatedPort
The associated port, if there is one.


_settingAssociatedPort

private boolean _settingAssociatedPort
Flag indicating that we are setting the associated port.

Constructor Detail

MirrorPort

public MirrorPort(Workspace workspace)
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.

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 class TypedIOPort
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(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 class IOPort
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 null
NameDuplicationException - 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 class IOPort
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 class IOPort
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 interface Nameable
Overrides:
setName in class Port
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 class IOPort
Parameters:
isOutput - True to make this an output port.
Throws:
IllegalActionException - If changing the port status is not permitted.