ptolemy.actor
Class DoNothingDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.DoNothingDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class DoNothingDirector
extends Director

A director that does nothing, for use in models that have no useful execution.

This director is added to models for code generation purposes when the model has no useful execution but the code generator runs CompositeActor.preinitialize().

If this director is used in a model, then adding a _hide attribute to the director will make the director invisible to the user.

Since:
Ptolemy II 8.0
Version:
$Id: DoNothingDirector.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution
 
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
DoNothingDirector(CompositeEntity container, java.lang.String name)
          Construct a director with the given container and name.
 
Method Summary
 void addInitializable(Initializable initializable)
          Add the specified object to the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object.
 void fire()
          Iterate all the deeply contained actors of the container of this director exactly once.
 void initialize()
          Initialize the model controlled by this director.
 boolean postfire()
          Return true if the director wishes to be scheduled for another iteration.
 boolean prefire()
          Return true if the director is ready to fire.
 void preinitialize()
          Validate the attributes and then invoke the preinitialize() methods of all its deeply contained actors.
 boolean transferInputs(IOPort port)
          Transfer data from an input port of the container to the ports it is connected to on the inside.
 boolean transferOutputs(IOPort port)
          Transfer data from an output port of the container to the ports it is connected to on the outside.
 void wrapup()
          Invoke the wrapup() method of all the actors contained in the director's container.
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, attributeChanged, createSchedule, defaultDependency, finish, fireAt, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, invalidateSchedule, isFireFunctional, isStopRequested, isStrict, iterate, newReceiver, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, terminate
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoNothingDirector

public DoNothingDirector(CompositeEntity container,
                         java.lang.String name)
                  throws NameDuplicationException,
                         IllegalActionException
Construct a director with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
IllegalActionException - If the entity cannot be contained by the proposed container.
NameDuplicationException - If the container already has an actor with this name.
Method Detail

addInitializable

public void addInitializable(Initializable initializable)
Description copied from class: Director
Add the specified object to the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object.

Specified by:
addInitializable in interface Initializable
Overrides:
addInitializable in class Director
Parameters:
initializable - The object whose methods should be invoked.
See Also:
Director.removeInitializable(Initializable), CompositeActor.addPiggyback(Executable)

fire

public void fire()
Description copied from class: Director
Iterate all the deeply contained actors of the container of this director exactly once. This method is not functional, since an iteration of the deeply contained actors may change state in their postfire() method. The actors are iterated in the order that they appear on the list returned by deepEntityList(), which is normally the order in which they were created.

This method is not synchronized on the workspace, so the caller should be.

In this base class, an attempt is made to fire each actor exactly once, in the order they were created. Prefire is called once, and if prefire returns true, then fire is called once, followed by postfire. The return value from postfire is ignored. If the container is not an instance of CompositeActor, however, then this method does nothing.

Specified by:
fire in interface Executable
Overrides:
fire in class Director

initialize

public void initialize()
Description copied from class: Director
Initialize the model controlled by this director. Set the current time to the start time or the current time of the executive director, and then invoke the initialize() method of this director on each actor that is controlled by this director. If the container is not an instance of CompositeActor, do nothing. This method should typically be invoked once per execution, after the preinitialization phase, but before any iteration. It may be invoked in the middle of an execution, if reinitialization is desired. Since type resolution has been completed and the current time is set, the initialize() method of a contained actor may produce output or schedule events. If stop() is called during this methods execution, then stop initializing actors immediately. This method is not synchronized on the workspace, so the caller should be.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class Director

postfire

public boolean postfire()
Description copied from class: Director
Return true if the director wishes to be scheduled for another iteration. This method is called by the container of this director to see whether the director wishes to execute anymore. It should not, in general, call postfire() on the contained actors.

In this base class, return the false if stop() has been called since preinitialize(), and true otherwise. Derived classes that override this method need to respect this semantics. The protected variable _stopRequested indicates whether stop() has been called.

Specified by:
postfire in interface Executable
Overrides:
postfire in class Director
Returns:
True to continue execution, and false otherwise.

prefire

public boolean prefire()
Description copied from class: Director
Return true if the director is ready to fire. This method is called by the container of this director to determine whether the director is ready to execute. It does not call prefire() on the contained actors. If this director is not at the top level of the hierarchy, and the current time of the enclosing model is greater than the current time of this director, then this base class updates current time to match that of the enclosing model.

In this base class, assume that the director is always ready to be fired, and so return true. Domain directors should probably override this method to provide domain-specific behavior. However, they should call super.prefire() if they wish to propagate time as done here.

Specified by:
prefire in interface Executable
Overrides:
prefire in class Director
Returns:
True.

preinitialize

public void preinitialize()
Description copied from class: Director
Validate the attributes and then invoke the preinitialize() methods of all its deeply contained actors. This method is invoked once per execution, before any iteration, and before the initialize() method. Time is not set during this stage. So preinitialize() method of actors should not make use of time. They should wait until the initialize phase of the execution.

This method also resets the protected variable _stopRequested to false, so if a derived class overrides this method, then it should also do that.

This method is not synchronized on the workspace, so the caller should be.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class Director

transferInputs

public boolean transferInputs(IOPort port)
Description copied from class: Director
Transfer data from an input port of the container to the ports it is connected to on the inside. The implementation in this base class transfers at most one token. Derived classes may override this method to transfer a domain-specific number of tokens.

Overrides:
transferInputs in class Director
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one data token is transferred.

transferOutputs

public boolean transferOutputs(IOPort port)
Description copied from class: Director
Transfer data from an output port of the container to the ports it is connected to on the outside. The implementation in this base class transfers at most one token, but derived classes may transfer more than one token.

Overrides:
transferOutputs in class Director
Parameters:
port - The port to transfer tokens from.
Returns:
True if at least one data token is transferred.

wrapup

public void wrapup()
Description copied from class: Director
Invoke the wrapup() method of all the actors contained in the director's container. In this base class wrapup() is called on the associated actors in the order of their creation. If the container is not an instance of CompositeActor, then this method does nothing.

This method should be invoked once per execution. None of the other action methods should be invoked after it in the execution. This method is not synchronized on the workspace, so the caller should be.

Specified by:
wrapup in interface Initializable
Overrides:
wrapup in class Director