Package ptolemy.actor
Class PubSubPort
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Initializable
,HasTypeConstraints
,Typeable
,Changeable
,Debuggable
,DebugListener
,Derivable
,HierarchyListener
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
PublisherPort
,SubscriberPort
public abstract class PubSubPort extends TypedIOPort implements HierarchyListener, Initializable
An abstract base class for publisher and subscriber ports.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- 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 Modifier and Type Field Description protected java.lang.String
_channel
Cached channel name, for publish and subscribe.protected boolean
_global
Cached variable indicating whether publishing or subscribing is global.StringParameter
channel
If set, then this port is used to communicate over a named publish and subscribe channel, rather than over manually established connections.Parameter
global
Specification of whether the published data is global.Parameter
initialTokens
The values that will be made available in the initialize method.-
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 PubSubPort(ComponentEntity container, java.lang.String name)
Construct a subscriber port with a containing actor and a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInitializable(Initializable initializable)
Throw an exception.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
hierarchyChanged()
Notify this object that the containment hierarchy above it has changed.void
hierarchyWillChange()
Notify this object that the containment hierarchy above it will be changed, which results in this port being removed from the set of initializables of the container.void
initialize()
Do nothing.void
preinitialize()
Do nothing.void
removeInitializable(Initializable initializable)
Do nothing.void
setContainer(Entity container)
Override the base class to register as anInitializable
so that preinitialize() is invoked, and as aHierarchyListener
, so that we are notified of changes in the hierarchy above.void
wrapup()
Do nothing.-
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, setInput, setMultiport, setOutput, 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, setName
-
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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
channel
public StringParameter channel
If set, then this port is used to communicate over a named publish and subscribe channel, rather than over manually established connections.
-
global
public Parameter global
Specification of whether the published data is global. This is ignored ifchannel
is empty. If this is set to true, then a subscriber anywhere in the model that references the same channel by name will see values published by this port. If this is set to false (the default), then only those subscribers that are controlled by the same director will see values published on this channel.
-
initialTokens
public Parameter initialTokens
The values that will be made available in the initialize method. By default, this is empty, indicating that no initial tokens are available. If you wish for this port to have initial tokens, then give this parameter an array value specifying the sequence of initial values. If this is an output port, these initial values will be sent in the initialize() phase. If this is an input port, then these initial values will be available for reading after the initialize() phase. Changes to this parameter after initialize() has been invoked are ignored until the next execution of the model.
-
_channel
protected java.lang.String _channel
Cached channel name, for publish and subscribe.
-
_global
protected boolean _global
Cached variable indicating whether publishing or subscribing is global.
-
-
Constructor Detail
-
PubSubPort
public PubSubPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a subscriber port with a containing actor and a name. This is always an input port.- Parameters:
container
- The container actor.name
- The name of the port.- Throws:
IllegalActionException
- If the port is not of an acceptable class for the container, or if the container does not implement the Actor interface.NameDuplicationException
- If the name coincides with a port already in the container.
-
-
Method Detail
-
addInitializable
public void addInitializable(Initializable initializable)
Throw an exception. Adding initializables to the container is not supported.- Specified by:
addInitializable
in interfaceInitializable
- Parameters:
initializable
- The object whose methods should be invoked.- See Also:
Initializable.removeInitializable(Initializable)
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then resets the type constraints.- Overrides:
clone
in classTypedIOPort
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
hierarchyChanged
public void hierarchyChanged() throws IllegalActionException
Notify this object that the containment hierarchy above it has changed. This method does nothing because instead we usepreinitialize()
to handle re-establishing the connections.- Specified by:
hierarchyChanged
in interfaceHierarchyListener
- Throws:
IllegalActionException
- If the change is not acceptable.
-
hierarchyWillChange
public void hierarchyWillChange() throws IllegalActionException
Notify this object that the containment hierarchy above it will be changed, which results in this port being removed from the set of initializables of the container.- Specified by:
hierarchyWillChange
in interfaceHierarchyListener
- Throws:
IllegalActionException
- If unlinking to a published port fails.
-
initialize
public void initialize() throws IllegalActionException
Do nothing.- Specified by:
initialize
in interfaceInitializable
- Throws:
IllegalActionException
- If execution is not permitted.
-
preinitialize
public void preinitialize() throws IllegalActionException
Do nothing. Subclasses should check to see if the port is in the top level and throw an exception that suggests using a Publisher or Subscriber.- Specified by:
preinitialize
in interfaceInitializable
- Throws:
IllegalActionException
- If initializing is not permitted.
-
removeInitializable
public void removeInitializable(Initializable initializable)
Do nothing.- Specified by:
removeInitializable
in interfaceInitializable
- Parameters:
initializable
- The object whose methods should no longer be invoked.- See Also:
Initializable.addInitializable(Initializable)
-
setContainer
public void setContainer(Entity container) throws IllegalActionException, NameDuplicationException
Override the base class to register as anInitializable
so that preinitialize() is invoked, and as aHierarchyListener
, so that we are notified of changes in the hierarchy above.- Overrides:
setContainer
in classIOPort
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the action would result in a recursive containment structure, or if this entity and container are not in the same workspace.NameDuplicationException
- If the container already has an entity with the name of this entity.- See Also:
Port.getContainer()
,Port._checkContainer(Entity)
-
wrapup
public void wrapup() throws IllegalActionException
Do nothing.- Specified by:
wrapup
in interfaceInitializable
- Throws:
IllegalActionException
- If wrapup is not permitted.
-
-