ptolemy.actor.lib.hoc
Class MirrorComposite

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.kernel.CompositeEntity
                      extended by ptolemy.actor.CompositeActor
                          extended by ptolemy.actor.TypedCompositeActor
                              extended by ptolemy.actor.lib.hoc.MirrorComposite
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, HandlesInternalLinks
Direct Known Subclasses:
IterateOverArray, RealTimeComposite, ThreadedComposite

public class MirrorComposite
extends TypedCompositeActor
implements HandlesInternalLinks

This is a base class for actors that are simple composites that contain one actor and mirror the ports and parameters of that one actor.

Since:
Ptolemy II 6.1
Version:
$Id: MirrorComposite.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
static class MirrorComposite.MirrorCompositeContents
          This is a specialized composite actor for use in MirrorComposite.
 
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
private  boolean _inAddPort
          Flag indicating that we are executing _addPort().
private  boolean _inRemoveEntity
          Flag indicating that we are executing _removeEntity().
private  boolean _mirrorParameterPorts
          Flag indicating whether to mirror instances of ParameterPort.
 
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _initializables, _notifyingActorFiring, _publishedPorts, _publisherRelations, _stopRequested
 
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
MirrorComposite(CompositeEntity container, java.lang.String name)
          Create an actor with a name and a container.
MirrorComposite(CompositeEntity container, java.lang.String name, boolean mirrorParameterPorts)
          Create an actor with a name and a container that optionally mirrors the ports that are instances of ParameterPort.
MirrorComposite(Workspace workspace)
          Construct a MirrorComposite in the specified workspace with no container and an empty string as a name.
 
Method Summary
protected  void _addEntity(ComponentEntity entity)
          Override the base class to queue a change request to remove any previously contained entity and its mirrored ports, and to mirror the ports of the added entity.
protected  void _addPort(Port port)
          Add a port to this actor.
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Override the base class to describe contained entities, attributes, and ports, but not inside links or relations.
private  void _init(boolean mirrorParameterPorts)
          Initialize the class.
protected  void _removeEntity(ComponentEntity entity)
          Override the base class to remove the ports and inside relations of this actor.
protected  void _removePort(Port port)
          Override the base class to remove the associated port on the inside entity and the link to it, if there is one.
 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.
 
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addRelation, _checkTypesFromTo, _typeConstraintsFromTo, newRelation, resolveTypes, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _getPublishedPort, _setDirector, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, preinitialize, recordFiring, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, wrapup
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _deepOpaqueEntityList, _description, _recordDecoratedAttributes, _removeRelation, _validateSettables, allAtomicEntityList, allCompositeEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, 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, propagateValue, propagateValues, removeChangeListener, removeDebugListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

_inAddPort

private boolean _inAddPort
Flag indicating that we are executing _addPort().


_inRemoveEntity

private boolean _inRemoveEntity
Flag indicating that we are executing _removeEntity().


_mirrorParameterPorts

private boolean _mirrorParameterPorts
Flag indicating whether to mirror instances of ParameterPort.

Constructor Detail

MirrorComposite

public MirrorComposite(CompositeEntity container,
                       java.lang.String name)
                throws IllegalActionException,
                       NameDuplicationException
Create an actor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container actor.
name - The name of this actor.
Throws:
IllegalActionException - If the container is incompatible with this actor.
NameDuplicationException - If the name coincides with an actor already in the container.

MirrorComposite

public MirrorComposite(Workspace workspace)
Construct a MirrorComposite in the specified workspace with no container and 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. You should set the local director or executive director before attempting to send data to the actor or to execute it. Add the actor to the workspace directory. Increment the version number of the workspace.

Parameters:
workspace - The workspace that will list the actor.

MirrorComposite

public MirrorComposite(CompositeEntity container,
                       java.lang.String name,
                       boolean mirrorParameterPorts)
                throws IllegalActionException,
                       NameDuplicationException
Create an actor with a name and a container that optionally mirrors the ports that are instances of ParameterPort. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container actor.
name - The name of this actor.
mirrorParameterPorts - If false, then ports that are instances of ParameterPort are not mirrored.
Throws:
IllegalActionException - If the container is incompatible with this actor.
NameDuplicationException - If the name coincides with an actor 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 set up the associations in the mirror ports and to set a flag indicating that cloning is complete.

Overrides:
clone in class CompositeActor
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:
CompositeEntity.exportMoML(Writer, int, String)

newPort

public Port newPort(java.lang.String name)
             throws NameDuplicationException
Override the base class to return a specialized port.

Overrides:
newPort in class TypedCompositeActor
Parameters:
name - The name of the port to create.
Returns:
A new instance of IteratePort, an inner class.
Throws:
NameDuplicationException - If the container already has a port with this name.

_addEntity

protected void _addEntity(ComponentEntity entity)
                   throws IllegalActionException,
                          NameDuplicationException
Override the base class to queue a change request to remove any previously contained entity and its mirrored ports, and to mirror the ports of the added entity.

Overrides:
_addEntity in class TypedCompositeActor
Parameters:
entity - Entity to contain.
Throws:
IllegalActionException - If the entity has no name, or the action would result in a recursive containment structure, or the argument does not implement the TypedActor interface.
NameDuplicationException - If the name collides with a name already on the actor contents list, or if the added element is a class definition.

_addPort

protected void _addPort(Port port)
                 throws IllegalActionException,
                        NameDuplicationException
Add a port to this actor. This overrides the base class to mirror the new port in the contained actor, if there is one, and to establish a connection to a port on the contained actor.

Overrides:
_addPort in class TypedCompositeActor
Parameters:
port - The TypedIOPort to add to this actor.
Throws:
IllegalActionException - If the port is not an instance of IteratePort, or the port has no name.
NameDuplicationException - If the port name collides with a name already in the actor.

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Override the base class to describe contained entities, attributes, and ports, but not inside links or relations. The rest of the contents are generated automatically when a contained entity is inserted.

Overrides:
_exportMoMLContents in class CompositeEntity
Parameters:
output - The output to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj.exportMoML(Writer, int)

_removeEntity

protected void _removeEntity(ComponentEntity entity)
Override the base class to remove the ports and inside relations of this actor. This method assumes the caller has write access on the workspace.

Overrides:
_removeEntity in class CompositeEntity
Parameters:
entity - The entity being removed from this entity.

_removePort

protected void _removePort(Port port)
Override the base class to remove the associated port on the inside entity and the link to it, if there is one. This method assumes the caller has write access on the workspace.

Overrides:
_removePort in class Entity
Parameters:
port - The port being removed from this entity.

_init

private void _init(boolean mirrorParameterPorts)
Initialize the class.

Parameters:
mirrorParameterPorts - If true, then mirror instances of ParameterPort.