Package ptolemy.component
Class AtomicComponent
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.component.AtomicComponent
-
- All Implemented Interfaces:
java.lang.Cloneable
,Component
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class AtomicComponent extends ComponentEntity implements Component
A component with functionality given in Java. The functionality can be given in therun()
method or by theMethodCallPort.call(TupleToken)
method of contained ports that are providers.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Yang Zhao
- Pt.AcceptedRating:
- red (cxh)
- Pt.ProposedRating:
- yellow (ellen_zh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description AtomicComponent(CompositeEntity container, java.lang.String name)
Construct an entity with the given name contained by the specified entity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addPort(Port port)
Add a port to this entity.void
initialize()
Initialize the component, which in this base class means doing nothing and returning immediately.Port
newPort(java.lang.String name)
Create a new port with the specified name.void
preinitialize()
Preinitialize the component, which in this base class means doing nothing and returning immediately.void
run()
Execute the component, which in this base class means doing nothing and returning immediately.void
wrapup()
Wrap up an execution, which in this base class means doing nothing and returning immediately.-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setContainer, setName
-
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, 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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getDisplayName, getFullName, getName, getName
-
-
-
-
Constructor Detail
-
AtomicComponent
public AtomicComponent(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an entity with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This entity 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. This constructor write-synchronizes on the workspace.- Parameters:
container
- The container entity.name
- The name of the entity.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the name coincides with an entity already in the container.
-
-
Method Detail
-
initialize
public void initialize() throws IllegalActionException
Initialize the component, which in this base class means doing nothing and returning immediately. This is invoked once after preinitialize() and again whenever the component needs to be reinitialized.- Specified by:
initialize
in interfaceComponent
- Throws:
IllegalActionException
- If initialization cannot be completed (not thrown in this base class).
-
newPort
public Port newPort(java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new port with the specified name. The container of the port is set to this entity. This overrides the base class to create an instance of MethodCallPort. Derived classes may override this to further constrain the ports. This method is write-synchronized on the workspace and increments its version number.- Overrides:
newPort
in classComponentEntity
- Parameters:
name
- The new port name.- Returns:
- The new port
- Throws:
IllegalActionException
- If the argument is null.NameDuplicationException
- If this entity already has a port with the specified name.
-
preinitialize
public void preinitialize() throws IllegalActionException
Preinitialize the component, which in this base class means doing nothing and returning immediately. This is invoked exactly once per execution of a model, before any other methods in this interface are invoked.- Specified by:
preinitialize
in interfaceComponent
- Throws:
IllegalActionException
- If preinitialization cannot be completed (not thrown in this base class).
-
run
public void run() throws IllegalActionException
Execute the component, which in this base class means doing nothing and returning immediately. This is invoked after preinitialize() and initialize(), and may be invoked repeatedly.- Specified by:
run
in interfaceComponent
- Throws:
IllegalActionException
- If the run cannot be completed (not thrown in this base class).
-
wrapup
public void wrapup() throws IllegalActionException
Wrap up an execution, which in this base class means doing nothing and returning immediately. This method is invoked exactly once per execution of a model. It finalizes an execution, typically closing files, displaying final results, etc. If any other method from this interface is invoked after this, it must begin with preinitialize().- Specified by:
wrapup
in interfaceComponent
- Throws:
IllegalActionException
- If wrapup fails.
-
_addPort
protected void _addPort(Port port) throws IllegalActionException, NameDuplicationException
Add a port to this entity. This overrides the base class to throw an exception if the added port is not an instance of MethodCallPort. 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 entity, but does not check. The caller should check. Derived classes may override this method to further constrain to a subclass of MethodCallPort. This method is not synchronized on the workspace, so the caller should be.- Overrides:
_addPort
in classEntity
- Parameters:
port
- The port to add to this entity.- Throws:
IllegalActionException
- If the port class is not acceptable to this entity, or the port has no name.NameDuplicationException
- If the port name collides with a name already in the entity.
-
-