ptolemy.actor.lib.hoc
Class ApplyFunction
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.hoc.ApplyFunction
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class ApplyFunction
- extends TypedAtomicActor
This actor applies a function to its inputs and outputs the
results. But rather than has the function specified statically,
this actor allows dynamic change to the function, which means the
computation of this actor can be changed during executing. Its
second input accept a function token for the new function's
definition. The function token can be given by actors in the local
model or remote actors.
- Since:
- Ptolemy II 4.1
- Version:
- $Id: ApplyFunction.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Steve Neuendorffer, Yang Zhao
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
ApplyFunction(CompositeEntity container,
java.lang.String name)
Construct a ApplyFunction with a name and a container. |
ApplyFunction(Workspace workspace)
Construct a ApplyFunction in the specified workspace with
no container and an empty string as a name. |
Method Summary |
void |
fire()
If the function is not specified, then perform identity function;
otherwise, apply the specified function to its input and output
the result. |
boolean |
prefire()
Return true if the actor either of its input port has token. |
void |
preinitialize()
Preinitialize the actor. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, 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.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 |
function
public PortParameter function
- The input port for function definition. The type of this port is
undeclared, but to have this actor work, the designer has to provide
a matched function token for it.
Note: The reason that we don't declare the type for it is because
currently there is not cast supported in the FunctionType class.
we'll fix this later.
output
public TypedIOPort output
- The output port.
ApplyFunction
public ApplyFunction(Workspace workspace)
throws IllegalActionException,
NameDuplicationException
- Construct a ApplyFunction 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.
- Parameters:
workspace
- The workspace that will list the actor.
- Throws:
IllegalActionException
- If the entity cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.
ApplyFunction
public ApplyFunction(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct a ApplyFunction with a name and a container.
The container argument must not be null, or a
NullPointerException will be thrown.
- Parameters:
container
- The container.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.
fire
public void fire()
throws IllegalActionException
- If the function is not specified, then perform identity function;
otherwise, apply the specified function to its input and output
the result.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- If there is no director, or if
the director's fire() method throws it, or if the actor is not
opaque.
prefire
public boolean prefire()
throws IllegalActionException
- Return true if the actor either of its input port has token.
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class AtomicActor
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException
- Not thrown in this base class.
preinitialize
public void preinitialize()
throws IllegalActionException
- Preinitialize the actor. Set the type of the ports based on
the type of the function parameter.
- Specified by:
preinitialize
in interface Initializable
- Overrides:
preinitialize
in class AtomicActor
- Throws:
IllegalActionException
- Not thrown in this base class.