ptolemy.actor
Class TypedAtomicActor

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.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
AbstractCalInterpreter, AbstractPlaceableActor, AddSubtract, ApplyFilterOverArray, ApplyFunction, ApplyFunctionOverSequence, ArrayContains, ArrayLevelCrossing, ArrayPeakSearch, ArrayPeakSearch, ArrayRemoveElement, ArrowKeySensor, AtomicActorMatcher, AtomicWirelessChannel, AudioWriteBuffer, Backtrack, Barrier, Barrier, BinarySwitch, BooleanMultiplexor, BooleanSelect, BooleanSelect, BooleanSwitch, BooleanSwitch, Buffer, BusAssembler, BusDisassembler, CartesianToComplex, CartesianToPolar, ClassWrapper, ClipPlayer, CollisionDetector, ColorFinder, Comparator, ComplexToCartesian, ComplexToPolar, ComputeHistogram, ComputeHistogram, ConfigurationSelect, ConfigurationSwitch, ContinuousIntegrator, Counter, Counter, Course, CryptographyActor, CSPActor, CTBaseIntegrator, DatabaseManager, DatagramReader, DatagramWriter, DCT2x2dc, DCT4x4dc, DCT8x8, DDEActor, DDESink, DDFBooleanSelect, DDFSelect, DEActor, Default, DelayStart, DotProduct, DoubleFork, EmbeddedCActor.EmbeddedActor, EmbeddedJavaActor.EmbeddedActor, EventSource, EventSource, Expression, Expression, FixTransformer, GetProperties, GRActor, IDCT4x4dc, IDCT8x8, InstantaneousDialogGenerator, IntArrayToString, InteractiveShell, JAIPolarToComplex, KeyStoreActor, LEDMatrix, LevelCrossingDetector, LevelCrossingDetector, LevinsonDurbin, LinkVisualizer, LiveSoundActor, Locator, MapWorker, MathFunction, Maximum, Merge, MicaLeds, Minimum, MobileFunction, ModelExecutor, ModelReference, ModelView, MultiplyDivide, NodeRandomizer, NondeterministicMerge.ChannelActor, NonStrictThreeBitAdder, Or, OrderedMerge, OrderedMerge, PlaySound, PlotterBase, PolarToCartesian, PolarToComplex, PSNR, Publisher, PythonScript, RecordAssembler, RecordDisassembler, RecordUpdater, ReduceWorker, ResourcePool, SDFTransformer, Sequence, Sequence, SequentialClock, SequentialClock, SerialComm, SetProperties, SetVariable, SignatureActor, SingleEvent, Sink, SoundActor, Source, StringCompare, StringIndexOf, StringMatches, StringSimpleReplace, StringToIntArray, StringToKeyValue, Subscriber, SumofAbsoluteDifferences, SystemCommand, TerrainProperty, TestActorPortDepth, TestExceptionHandler, ThresholdMonitor, Transformer, Triangulator, UnionDisassembler, Wire, WiredToWireless, WirelessToWired

public class TypedAtomicActor
extends AtomicActor
implements TypedActor

A TypedAtomicActor is an AtomicActor whose ports and parameters have types.

The typeConstraints() method returns the type constraints among the contained ports and parameters. This base class provides a default implementation of this method, which should be suitable for most of the derived classes.

Derived classes may constrain the container by overriding _checkContainer(). The Ports of TypedAtomicActors are constrained to be TypedIOPorts. Derived classes may further constrain the ports by overriding the public method newPort() to create a port of the appropriate subclass, and the protected method _addPort() to throw an exception if its argument is a port that is not of the appropriate subclass.

Since:
Ptolemy II 0.2
Version:
$Id: TypedAtomicActor.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Yuhong Xiong
See Also:
AtomicActor, TypedCompositeActor, TypedIOPort, Serialized Form
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (cxh)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
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
TypedAtomicActor()
          Construct an actor in the default workspace with an empty string as its name.
TypedAtomicActor(CompositeEntity container, java.lang.String name)
          Create a new actor in the specified container with the specified name.
TypedAtomicActor(Workspace workspace)
          Construct an actor in the specified workspace with an empty string as a name.
 
Method Summary
protected  void _addPort(Port port)
          Override the base class to throw an exception if the added port is not an instance of TypedIOPort.
protected  void _fireAt(double time)
          Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time.
protected  void _fireAt(Time time)
          Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time.
 void attributeTypeChanged(Attribute attribute)
          React to a change in the type of an attribute.
 java.lang.Object clone()
          clone() is not supported, call clone(Workspace workspace) instead.
 Port newPort(java.lang.String name)
          Create a new TypedIOPort with the specified name.
 java.util.List typeConstraintList()
          Deprecated. Use typeConstraints().
 java.util.Set<Inequality> typeConstraints()
          Return the type constraints of this actor.
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, 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, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, 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, requestChange, 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
 

Constructor Detail

TypedAtomicActor

public TypedAtomicActor()
Construct an actor in the default workspace with an empty string as its name. The object is added to the workspace directory. Increment the version number of the workspace.


TypedAtomicActor

public TypedAtomicActor(Workspace workspace)
Construct an actor in the specified workspace with 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. The object is added to the workspace directory. Increment the version number of the workspace.

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

TypedAtomicActor

public TypedAtomicActor(CompositeEntity container,
                        java.lang.String name)
                 throws IllegalActionException,
                        NameDuplicationException
Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.

Parameters:
container - The container.
name - The name of this actor within the container.
Throws:
IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
NameDuplicationException - If the name coincides with an entity already in the container.
Method Detail

attributeTypeChanged

public void attributeTypeChanged(Attribute attribute)
                          throws IllegalActionException
React to a change in the type of an attribute. This method is called by a contained attribute when its type changes. In this base class, the method informs the director to invalidate type resolution, if the director is not null. Thus, by default, attribute type changes cause type resolution to be redone at the next opportunity. If an actor does not allow attribute types to change, then it should override this method.

Overrides:
attributeTypeChanged in class NamedObj
Parameters:
attribute - The attribute whose type changed.
Throws:
IllegalActionException - Not thrown in this base class. Derived classes can throw this exception if type change is not allowed.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clone() is not supported, call clone(Workspace workspace) instead. Usually it is a mistake for an actor to have a clone() method and call super.clone(), instead the actor should have a clone(Workspace workspace) method and call super.clone(workspace).

Overrides:
clone in class NamedObj
Returns:
A new NamedObj.
Throws:
java.lang.CloneNotSupportedException - Always thrown.

newPort

public Port newPort(java.lang.String name)
             throws NameDuplicationException
Create a new TypedIOPort with the specified name. The container of the port is set to this actor. This method is write-synchronized on the workspace.

Overrides:
newPort in class AtomicActor
Parameters:
name - The name for the new port.
Returns:
The new port.
Throws:
NameDuplicationException - If the actor already has a port with the specified name.
See Also:
Workspace.getWriteAccess()

typeConstraints

public java.util.Set<Inequality> typeConstraints()
Return the type constraints of this actor. The constraints have the form of a list of inequalities. In this base class, if an input port and an output port do not have their types declared, and they do not have any constraints stored in them, a constraint is set up that requires the type of the input to be less than or equal to the type of the output. In addition, this method also collects type constraints from the contained Typeables (ports, variables, and parameters). This method is read-synchronized on the workspace.

Specified by:
typeConstraints in interface TypedActor
Returns:
A list of instances of Inequality.
See Also:
Inequality

typeConstraintList

public java.util.List typeConstraintList()
Deprecated. Use typeConstraints().

Return the type constraints of this variable. The constraints include the ones explicitly set to this variable, plus the constraint that the type of this variable must be no less than its current type, if it has one. The constraints are a list of inequalities.

Returns:
a list of Inequality objects.
See Also:
Inequality

_addPort

protected void _addPort(Port port)
                 throws IllegalActionException,
                        NameDuplicationException
Override the base class to throw an exception if the added port is not an instance of TypedIOPort. This method should not be used directly. Call the setContainer() method of the port instead. This method does not set the container of the port to point to this entity. It assumes that the port is in the same workspace as this actor. Derived classes may override this method to further constrain the port to be a subclass of TypedIOPort. This method is not synchronized on the workspace, so the caller should be.

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

_fireAt

protected void _fireAt(Time time)
                throws IllegalActionException
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time. This is a convenience method provided because many actors need it.

Parameters:
time - The requested time.
Throws:
IllegalActionException - If the director does not agree to fire the actor at the specified time, or if there is no director.

_fireAt

protected void _fireAt(double time)
                throws IllegalActionException
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time. This is a convenience method provided because many actors need it.

Parameters:
time - The requested time, as a double.
Throws:
IllegalActionException - If the director does not agree to fire the actor at the specified time, or if there is no director.