public abstract class ModularCodeGenLazyTypedCompositeActor extends LazyTypedCompositeActor
The lazy contents of this composite are specified via the configure() method, which is called by the MoML parser and passed MoML code. The MoML is evaluated lazily; i.e. it is not actually evaluated until there is a request for its contents, via a call to getEntity(), numEntities(), entityList(), relationList(), or any related method. You can also force evaluation of the MoML by calling populate(). Accessing the attributes or ports of this composite does not trigger a populate() call, so a visual editor can interact with the actor from the outside in the usual way, enabling connections to its ports, editing of its parameters, and rendering of its custom icon, if any.
The configure method can be passed a URL or MoML text or both. If it is given MoML text, that text will normally be wrapped in a processing instruction, as follows:
<?moml <group> ... MoML elements giving library contents ... </group> ?>The processing instruction, which is enclosed in "<?" and "?>" prevents premature evaluation of the MoML. The processing instruction has a target, "moml", which specifies that it contains MoML code. The keyword "moml" in the processing instruction must be exactly as above, or the entire processing instruction will be ignored. The populate() method strips off the processing instruction and evaluates the MoML elements. The group element allows the library contents to be given as a set of elements (the MoML parser requires that there always be a single top-level element, which in this case will be the group element).
One subtlety in using this class arises because of a problem typical of lazy evaluation. A number of exceptions may be thrown because of errors in the MoML code when the MoML code is evaluated. However, since that code is evaluated lazily, it is evaluated in a context where these exceptions are not expected. There is no completely clean solution to this problem; our solution is to translate all exceptions to runtime exceptions in the populate() method. This method, therefore, violates the condition for using runtime exceptions in that the condition that causes these exceptions to be thrown is not a testable precondition.
A second subtlety involves cloning. When this class is cloned, if the configure MoML text has not yet been evaluated, then the clone is created with the same (unevaluated) MoML text, rather than being populated with the contents specified by that text. If the object is cloned after being populated, the clone will also be populated. Cloning is used in actor-oriented classes to create subclasses or instances of a class. When a LazyTypedCompositeActor contained by a subclass or an instance is populated, it delegates to the instance in the class definition. When that instance is populated, all of the derived instances in subclasses and instances of the class will also be populated as a side effect.
A third subtlety is that parameters of this actor cannot refer to contained entities or relations, nor to attributes contained by those. This is a rather esoteric use of expressions, so this limitation may not be onerous. You probably didn't know you could do that anyway. An attempt to make such references will simply result in the expression failing to evaluate.
Red (rodiers) |
Red (rodiers) |
LazyTypedCompositeActor.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_addedSubscribersFromProfile
True if subscribers were added from the profile.
|
protected int |
_creatingPubSub
True if we Publishers or Subscribers are being created.
|
protected java.lang.reflect.Method |
_fireMethod
The fire() method.
|
protected boolean |
_generatingCode
True if code is being generated.
|
protected java.lang.Object |
_objectWrapper
The object wrapper.
|
protected Profile |
_profile
The profile.
|
protected java.util.Map<java.lang.String,IOPort> |
_subscriberPorts
Map of Subscriber ports.
|
Parameter |
recompileHierarchy
A boolean parameter to enforce recompilation of this ModularCodeGenTypedCompositeActor
and all contained ModularCodeGenTypedCompositeActors.
|
Parameter |
recompileThisLevel
A boolean parameter to enforce recompilation of this ModularCodeGenTypedCompositeActor.
|
_configureDone, _populating
_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 |
---|
ModularCodeGenLazyTypedCompositeActor()
Construct a library in the default workspace with no
container and an empty string as its name.
|
ModularCodeGenLazyTypedCompositeActor(CompositeEntity container,
java.lang.String name)
Construct a library with the given container and name.
|
ModularCodeGenLazyTypedCompositeActor(Workspace workspace)
Construct a library in the specified workspace with
no container and an empty string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addEntity(ComponentEntity entity)
Add an entity or class definition to this container.
|
protected void |
_addRelation(ComponentRelation relation)
Add a relation to this container.
|
protected void |
_fire(java.util.List<java.lang.Object> argList)
Fire the actor.
|
protected abstract boolean |
_isPublishedPort(IOPort port)
Return true if the port is a is connected to a publisher.
|
protected boolean |
_isSubscribedPort(IOPort port)
Return true if the port is a is connected to a subscriber.
|
protected abstract java.lang.String |
_pubSubChannelName(IOPort port,
boolean publisher,
boolean subscriber)
Return the name of a Publisher or Subscriber channel name.
|
protected void |
_removeEntity(ComponentEntity entity)
Remove the specified entity.
|
protected void |
_removeRelation(ComponentRelation relation)
Remove the specified relation.
|
protected void |
_setRecompileFlag()
If configure is done, populating is not occurring,
code is not being generated and Pub/Subs are not being
created, then set the recompileThisLevel parameter
to true.
|
protected static void |
_transferOutputs(TypedCompositeActor compositeActor,
IOPort port,
java.lang.Object outputTokens)
Transfer the outputs.
|
static java.lang.String |
classToActorName(java.lang.String className)
Generate actor name from its class name.
|
Profile.Port |
convertProfilePort(TypedIOPort port)
Convert this Ptolemy port to a port that will be saved in the profile.
|
ComponentRelation |
newRelation(java.lang.String name)
Create a new relation with the specified name, add it to the
relation list, and return it.
|
_exportMoMLContents, classDefinitionList, clone, configure, deepContains, deepEntityList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportMoML, getConfigureSource, getConfigureText, getEntity, getRelation, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyClassDefinitionList, lazyContainedObjectsIterator, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, populate, relationList, setClassDefinition, uniqueName
_addPort, _checkTypesFromTo, _destinationTypeConstraints, attributeChanged, attributeTypeChanged, isBackwardTypeInferenceEnabled, newPort, resolveTypes, typeConstraintList, typeConstraints
_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, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepGetEntities, deepNamedObjList, exportLinks, getAttribute, getEntities, getPort, getRelations, isAtomic, lazyAllCompositeTransparentAndOpaqueEntityList, numEntities, numRelations, removeAllEntities, removeAllRelations, statistics
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_removePort, 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, 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, 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 Parameter recompileHierarchy
public Parameter recompileThisLevel
protected boolean _addedSubscribersFromProfile
protected int _creatingPubSub
protected boolean _generatingCode
protected transient java.lang.reflect.Method _fireMethod
protected java.lang.Object _objectWrapper
protected Profile _profile
protected java.util.Map<java.lang.String,IOPort> _subscriberPorts
public ModularCodeGenLazyTypedCompositeActor() throws IllegalActionException, NameDuplicationException
IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public ModularCodeGenLazyTypedCompositeActor(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace that will list the actor.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public ModularCodeGenLazyTypedCompositeActor(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this library.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public static java.lang.String classToActorName(java.lang.String className)
className
- The class name of the actorpublic Profile.Port convertProfilePort(TypedIOPort port) throws IllegalActionException
port
- The Ptolemy port.IllegalActionException
- When the width can't be retrieved.public ComponentRelation newRelation(java.lang.String name) throws NameDuplicationException
newRelation
in class LazyTypedCompositeActor
name
- The name of the new relation.NameDuplicationException
- If name collides with a name
already in the container.protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException
_addEntity
in class LazyTypedCompositeActor
entity
- Entity to contain.IllegalActionException
- If the entity has no name, or the
action would result in a recursive containment structure.NameDuplicationException
- If the name collides with a name
already in the entity.protected void _addRelation(ComponentRelation relation) throws IllegalActionException, NameDuplicationException
_addRelation
in class LazyTypedCompositeActor
relation
- Relation to contain.IllegalActionException
- If the relation has no name.NameDuplicationException
- If the name collides with a name
already on the contained relations list.protected void _fire(java.util.List<java.lang.Object> argList) throws java.lang.Throwable
argList
- The arguments, true if there are outputs.java.lang.Throwable
- If things go horrible wrong and the
time/space continuum is broken.protected abstract boolean _isPublishedPort(IOPort port)
port
- The port to look up.protected boolean _isSubscribedPort(IOPort port)
port
- The port to look up.protected abstract java.lang.String _pubSubChannelName(IOPort port, boolean publisher, boolean subscriber)
port
- The port.publisher
- True if the corresponding Publisher should
be returned.subscriber
- True if the corresponding Subscriber should
be returned.protected void _removeEntity(ComponentEntity entity)
_removeEntity
in class LazyTypedCompositeActor
entity
- The entity to remove.protected void _removeRelation(ComponentRelation relation)
_removeRelation
in class LazyTypedCompositeActor
relation
- The relation to remove.protected void _setRecompileFlag() throws IllegalActionException
IllegalActionException
- If thrown while setting token.protected static void _transferOutputs(TypedCompositeActor compositeActor, IOPort port, java.lang.Object outputTokens) throws IllegalActionException
compositeActor
- The composite actor transferring the
outputs.port
- The port on which the output is to be transferredoutputTokens
- The tokens to be transferred.IllegalActionException
- If there are problems
getting the class or otherwise transferring the tokens.