public class SubscriberPort extends PubSubPort
PublisherPort
that names the same channel.
If PubSubPort.global
is false (the default), then this subscriber
will only see instances of PublisherPort that are under the
control of the same director. That is, it can
be at a different level of the hierarchy, or in an entirely different
composite actor, as long as the relevant composite actors are
transparent (have no director). If PubSubPort.global
is true,
then the publisher may be anywhere in the model, as long as its
global parameter is also true.
Any number of instances of SubscriberPort can subscribe to the same channel.
This actor actually has a hidden input port that is connected to the publisher via hidden "liberal links" (links that are allowed to cross levels of the hierarchy). Consequently, any data dependencies that the director might assume on a regular "wired" connection will also be assumed across Publisher-Subscriber pairs. Similarly, type constraints will propagate across Publisher-Subscriber pairs. That is, the type of the Subscriber output will match the type of the Publisher input.
TypedIOPort.RunTimeTypeCheckException
NamedObj.ContainedObjectsIterator
_channel, _global, channel, global, initialTokens
_resolvedType, TYPE
_constantLimit, _constantToken, _constantTokensSent, _hasPortEventListeners, _portEventListeners, CONFIGURATION, defaultValue, RECEIVERS, REMOTERECEIVERS
_insideLinks, _relationsList
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
SubscriberPort(ComponentEntity container,
java.lang.String name)
Construct a subscriber port with a containing actor and a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_updateLinks()
Update the connection to the publisher, if there is one.
|
protected void |
_updatePublisherPorts(Entity root)
Traverse the model, starting at the specified object
and examining objects below it in the hierarchy, to find
all instances of PublisherPort and make sure that they have
registered their port.
|
void |
attributeChanged(Attribute attribute)
If a publish and subscribe channel is set, then set up the connections.
|
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 the channel being unlinked from the publisher.
|
void |
initialize()
If
PubSubPort.initialTokens has been set, then make available the
inputs specified by its array value. |
void |
preinitialize()
Override the base class to ensure that there is a publisher.
|
void |
setInput(boolean isInput)
Override the base class to only accept setting to be an input.
|
void |
setOutput(boolean isOutput)
Override the base class to refuse to make the port an output.
|
addInitializable, clone, removeInitializable, setContainer, wrapup
_checkContainer, _checkLiberalLink, _checkLink, _checkType, _checkTypedIOPortContainer, _description, addTypeListener, broadcast, broadcast, convert, getAutomaticTypeConversion, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, send, send, sendInside, setAutomaticTypeConversion, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList, typeConstraints
_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, setMultiport, setWidthEquals, setWidthEquals, sinkPortList, sourcePortList, transferInputs, transferOutputs, unlink, unlink, unlinkAll, unlinkAllInside, unlinkInside, unlinkInside
_deepConnectedPortList, _deepConnectedPorts, _deepInsidePortList, _deepInsidePorts, _isInsideLinkable, deepConnectedPortList, deepConnectedPorts, deepInsidePortList, deepInsidePorts, insertInsideLink, insidePortList, insidePorts, insideRelationList, insideRelations, isDeeplyConnected, isInsideGroupLinked, isInsideLinked, isOpaque, numInsideLinks
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isGroupLinked, isLinked, linkedRelationList, linkedRelations, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, numLinks, setName
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public SubscriberPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of the port.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.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class TypedIOPort
attribute
- The attribute that changed.IllegalActionException
- Thrown if the new color attribute cannot
be created.public void hierarchyChanged() throws IllegalActionException
hierarchyChanged
in interface HierarchyListener
hierarchyChanged
in class PubSubPort
IllegalActionException
- If the change is not
acceptable.public void hierarchyWillChange() throws IllegalActionException
hierarchyWillChange
in interface HierarchyListener
hierarchyWillChange
in class PubSubPort
IllegalActionException
- If unlinking to a published port fails.public void initialize() throws IllegalActionException
PubSubPort.initialTokens
has been set, then make available the
inputs specified by its array value.initialize
in interface Initializable
initialize
in class PubSubPort
IllegalActionException
- If execution is not permitted.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class PubSubPort
IllegalActionException
- If there is no matching
publisher, if the channel is not specified or if the port
is in the top level.public void setInput(boolean isInput) throws IllegalActionException
setInput
in class IOPort
isInput
- True to make the port an input.IllegalActionException
- If the argument is false.public void setOutput(boolean isOutput) throws IllegalActionException
setOutput
in class IOPort
isOutput
- Required to be false.IllegalActionException
- If the argument is true.protected void _updateLinks() throws IllegalActionException
IllegalActionException
- If creating the link
triggers an exception.protected void _updatePublisherPorts(Entity root) throws IllegalActionException
root
- The root of the tree to search.IllegalActionException
- If the port rejects its channel.