public class IterateOverArray extends MirrorComposite
Each input port expects an array. When this actor fires, an array is read on each input port that has one, and its contents are provided sequentially to the contained actor or model. This actor then iterates the contained actor or model until either there are no more input data for the actor or the prefire() method of the actor or model returns false. If postfire() of the actor returns false, then postfire() of this actor will return false, requesting a halt to execution of the model. The outputs from the contained actor are collected into arrays that are produced on the outputs of this actor.
A special variable named "iterationCount" can be used in any expression setting the value of a parameter of this actor or its contents. This variable has an integer value that starts at 1 during the first iteration of the contained actor(s) and is incremented by 1 on each firing. If the inside actors consume one token on each firing, then its final value will be the size of the input array(s).
This actor is properly viewed as a "higher-order component" in that its contained actor is a parameter that specifies how to operate on input arrays. It is inspired by the higher-order functions of functional languages, but unlike those, the contained actor need not be functional. That is, it can have state.
Note that you cannot place class definitions inside this actor. There should be no need to because class instances inside it can be instances of classes defined outside of it.
This actor (and many of the other higher-order components) has its intellectual roots in the higher-order functions of functional languages, which have been in use since the 1970s. Similar actors were implemented in Ptolemy Classic, and are described in Lee & Parks, "Dataflow Process Networks," Proceedings of the IEEE, 1995. Those were inspired by [2]. Alternative approaches are found dataflow visual programming since the beginning (Sutherland in the 1960s, Prograph and Labview in the 1980s), and in time-based visual languages (Simulink in the 1990s).
There are a number of known bugs or limitations in this implementation:
Red (neuendor) |
Yellow (eal) |
Modifier and Type | Class and Description |
---|---|
static class |
IterateOverArray.IterateComposite
This is a specialized composite actor for use in IterateOverArray.
|
static class |
IterateOverArray.IteratePort
This is a specialized port for IterateOverArray.
|
MirrorComposite.MirrorCompositeContents
ReflectComposite.ReflectCompositeContents
CompositeEntity.ContainedObjectsIterator
_inAddPort, _inRemoveEntity, _mirrorParameterPorts
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
_levelCrossingLinks
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
IterateOverArray(CompositeEntity container,
java.lang.String name)
Create an actor with a name and a container.
|
IterateOverArray(Workspace workspace)
Construct an IterateOverArray in the specified workspace with
no container and an empty string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.List |
_checkTypesFromTo(TypedIOPort sourcePort,
java.util.List destinationPortList)
Check types from a source port to a group of destination ports,
assuming the source port is connected to all the ports in the
group of destination ports.
|
protected java.util.List |
_destinationTypeConstraints(TypedIOPort sourcePort)
Return the type constraints on all connections starting from the
specified source port to all the ports in a group of destination
ports.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
Port |
newPort(java.lang.String name)
Override the base class to return a specialized port.
|
java.util.Set<Inequality> |
typeConstraints()
Override the base class to ensure that the input ports of this
actor all have array types.
|
_addPort
_addEntity, _exportMoMLContents, _removeEntity, _removePort, newParameterPort
_addRelation, attributeChanged, attributeTypeChanged, isBackwardTypeInferenceEnabled, newRelation, resolveTypes, typeConstraintList
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, preinitialize, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort, wrapup
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, initialize, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public IterateOverArray(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of this actor.IllegalActionException
- If the container is incompatible
with this actor.NameDuplicationException
- If the name coincides with
an actor already in the container.public IterateOverArray(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace that will list the actor.IllegalActionException
- If the container is incompatible
with this actor.NameDuplicationException
- If the name coincides with
an actor already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class ReflectComposite
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If any of the attributes
cannot be cloned.CompositeEntity.exportMoML(Writer, int, String)
public Port newPort(java.lang.String name) throws NameDuplicationException
newPort
in class ReflectComposite
name
- The name of the port to create.NameDuplicationException
- If the container already has a port
with this name.public java.util.Set<Inequality> typeConstraints() throws IllegalActionException
typeConstraints
in interface TypedActor
typeConstraints
in class TypedCompositeActor
IllegalActionException
- If the typeConstraints
of one of the deeply contained objects throws it.Inequality
protected java.util.List _checkTypesFromTo(TypedIOPort sourcePort, java.util.List destinationPortList)
_checkTypesFromTo
in class TypedCompositeActor
sourcePort
- The source port.destinationPortList
- A list of destination ports.protected java.util.List _destinationTypeConstraints(TypedIOPort sourcePort)
_destinationTypeConstraints
in class TypedCompositeActor
sourcePort
- The source port.