ptolemy.actor.lib
Class TypeTest

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
                          extended by ptolemy.actor.lib.Sink
                              extended by ptolemy.actor.lib.Discard
                                  extended by ptolemy.actor.lib.TypeTest
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Configurable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class TypeTest
extends Discard

An actor that can be used for regression test of the type resolution system. During the initialize phase, after type resolution has been performed, this actor compares resolved types in the model with types stored in several parameters. If the types are the same, then the actor does nothing. However, if the types are different, then the actor throws an exception. Hence, as with the Test actor, this actor can be easily used to build automatically executed tests of the type system from within Vergil.

The types expected by this actor are stored in two parameters, each parameter contains a record of record of strings. The outer record contains labels corresponding to the names of actors in the same level of hierarchy as this actor. The inner record contains labels corresponding to the names of typeable objects in the appropriate actor. The strings in the record correspond to string representations of the types of the typeable objects. For the portTypes parameter, the typeable objects are assumed to be ports, and for the parameterTypes parameter, the objects are assumed to be parameters.

Note that this actor only tests type resolution at one level of opaque hierarchy. Hierarchical models should include multiple instances of this actor. Since filling in the types manually is difficult, this actor includes a training mode, similar to the NonStrictTest actor. This mode automatically fills in the type parameters. Also note that it is not necessary to specify the types of all typeable objects. Any objects for which no type is specified are not checked.

During runtime, this actor consumes and ignores any input tokens. This makes it very easy to add this actor to an existing model without changing the behavior of the model.

Since:
Ptolemy II 3.0
Version:
$Id: TypeTest.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Steve Neuendorffer
See Also:
Test, Serialized Form
Accepted Rating:
Red (ssachs)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 Parameter parameterTypes
          A record of record of strings representing the types of parameters of actors in the model.
 Parameter portTypes
          A record of record of strings representing the types of ports of actors in the model.
 Parameter trainingMode
          If true, then do not check inputs, but rather collect them into the portTypes and parameterTypes arrays.
 
Fields inherited from class ptolemy.actor.lib.Sink
input
 
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
TypeTest(CompositeEntity container, java.lang.String name)
          Construct an actor with an input multiport.
 
Method Summary
 void initialize()
          Initialize this actor.
 
Methods inherited from class ptolemy.actor.lib.Discard
configure, fire, getConfigureSource, getConfigureText
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, 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
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, 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

parameterTypes

public Parameter parameterTypes
A record of record of strings representing the types of parameters of actors in the model.


portTypes

public Parameter portTypes
A record of record of strings representing the types of ports of actors in the model.


trainingMode

public Parameter trainingMode
If true, then do not check inputs, but rather collect them into the portTypes and parameterTypes arrays. This parameter is a boolean, and it defaults to false.

Constructor Detail

TypeTest

public TypeTest(CompositeEntity container,
                java.lang.String name)
         throws NameDuplicationException,
                IllegalActionException
Construct an actor with an input multiport.

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

initialize

public void initialize()
                throws IllegalActionException
Initialize this actor. If the types stored in the type parameters do not correspond to the types of corresponding typeable objects in the model, then throw an exception indicating a failed regression test.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AtomicActor
Throws:
IllegalActionException - If the test fails.