|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This interface is for objects that can be instantiated. Such objects serve a role similar to "classes" in Java and other object oriented languages. They are Ptolemy II objects, but whose purpose is to serve as a factory for instances that are (deep) clones of themselves. Normally, they play no role in the execution of a model, and their ports cannot be connected to other ports.
An object that implements this interface can be in one of two states.
Either it is a class definition (isClassDefinition() returns true)
or it is not. Only objects that are class definitions can be instantiated.
Instantiation is done via the instantiate(NamedObj, String)
method. If an object
is instantiated from this object, then the new object is called the "child"
and this object is called the "parent." An instance of Instantiable can have
at most one parent (returned by the getParent() method), but it
can have many children (returned by the getChildren() method).
An object may be both a child and a parent.
A child is required to be a deep clone of its parent. That is, every object deeply contained by the parent must have a corresponding object deeply contained by the child. The object that is deeply contained by the parent is called the "prototype" and the object deeply contained by the child is called the "derived" object. A derived object has the same name relative to the child as the prototype has relative to the parent. Moreover, a derived object is an instance of the same Java class as the prototype.
This correspondence between a parent and child is called the "derivation invariant." Any correct implementation of this interface must ensure that the derivation invariant is always satisfied, even if the parent changes after the child was instantiated. If new objects are added to the parent, then derived objects must be added to the child.
| Green (neuendor) |
| Green (eal) |
| Method Summary | |
java.util.List |
getChildren()
Return a list of weak references to instances of Instantiable that are children of this object. |
Instantiable |
getParent()
Return the parent of this object, or null if there is none. |
Instantiable |
instantiate(NamedObj container,
java.lang.String name)
Create an instance by (deeply) cloning this object and then adjusting the parent-child relationships between the clone and its parent. |
boolean |
isClassDefinition()
Return true if this object is a class definition, which means that it can be instantiated. |
| Methods inherited from interface ptolemy.kernel.util.Derivable |
getDerivedLevel, getDerivedList, getPrototypeList, propagateExistence, propagateValue |
| Methods inherited from interface ptolemy.kernel.util.Nameable |
description, getContainer, getFullName, getName, getName, setName |
| Method Detail |
public java.util.List getChildren()
public Instantiable getParent()
public Instantiable instantiate(NamedObj container,
java.lang.String name)
throws java.lang.CloneNotSupportedException,
IllegalActionException,
NameDuplicationException
The new object is not a class definition by default (it is an
"instance" rather than a "class"). That is, isClassDefinition()
returns false.
container - The container for the instance, or null
to instantiate it at the top level.name - The name for the instance.
java.lang.CloneNotSupportedException - If this object
cannot be cloned.
IllegalActionException - If this object is not a
class definition or the proposed container is not acceptable.
NameDuplicationException - If the name collides with
an object already in the container.public boolean isClassDefinition()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||