|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.kernel.CompositeEntity
ptolemy.actor.CompositeActor
ptolemy.actor.TypedCompositeActor
ptolemy.actor.lib.jni.CompiledCompositeActor
public class CompiledCompositeActor
A composite actor that can be optionally code generated and then invoked via the Java Native Interface (JNI).
red (zgang) |
red (zgang) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity |
---|
CompositeEntity.ContainedObjectsIterator |
Field Summary | |
---|---|
private StringBufferExec |
_executeCommands
|
private long |
_generatedCodeVersion
The workspace version for which the code was generated. |
private java.lang.reflect.Method |
_jniFireMethod
|
private java.lang.reflect.Method |
_jniInitializeMethod
|
private java.lang.Object |
_jniWrapper
|
private java.lang.reflect.Method |
_jniWrapupMethod
|
private long |
_loadedCodeVersion
The workspace version for which the code was loaded. |
private static int |
_noEffigyVersion
The version of the shared object to use if we have no effigy. |
private static boolean |
_pointerTypeInitialized
|
private java.lang.String |
_sanitizedActorName
The sanitized actor name. |
private int |
_version
The version of the shared object. |
FileParameter |
codeDirectory
The directory in which to put the generated code. |
StringParameter |
generatorPackage
The name of the package in which to look for helper class code generators. |
Parameter |
inline
If true, generate file with no functions. |
Parameter |
invokeJNI
If true, then invoke the generated code in the action methods (fire(), etc.) using the Java Native Interface (JNI). |
Parameter |
overwriteFiles
If true, overwrite preexisting files. |
Fields inherited from class ptolemy.actor.CompositeActor |
---|
_actorFiringListeners, _causalityInterface, _initializables, _notifyingActorFiring, _publishedPorts, _publisherRelations, _stopRequested |
Fields inherited from class ptolemy.kernel.CompositeEntity |
---|
_levelCrossingLinks |
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 | |
---|---|
CompiledCompositeActor()
Construct a CodeGenerationCompositeActor in the default workspace with no container and an empty string as its name. |
|
CompiledCompositeActor(CompositeEntity container,
java.lang.String name)
Create an actor with a name and a container. |
|
CompiledCompositeActor(Workspace workspace)
Construct a CodeGenerationCompositeActor in the specified workspace with no container and an empty string as a name. |
Method Summary | |
---|---|
private boolean |
_buildSharedObjectFile()
Return true if the shared object file should be built. |
protected void |
_compileJavaCode()
Compile the Java code. |
private void |
_debugAndSystemOut(java.lang.String message)
Send a debug message to all debug listeners that have registered. |
protected void |
_generateAndCompileCCode()
Generate and compile C code. |
protected void |
_generateAndCompileJavaCode()
Generate and compile the Java code. |
private java.lang.String |
_getArguments()
|
private void |
_init()
Initialize parameters. |
private java.lang.Object |
_invokeHelperMethod(java.lang.String methodName)
Invoke a method in the corresponding helper class. |
private java.lang.String |
_sharedObjectPath(java.lang.String sanitizedActorName)
Get the name of the shared object. |
private java.lang.Object |
_transferInputs(IOPort port)
|
private void |
_transferOutputs(IOPort port,
java.lang.Object outputTokens)
|
private void |
_updateSanitizedActorName()
Update the _sanitizedActorName variable. |
void |
fire()
If invokeJNI is true, then execute the fire() method of the generated code via JNI. |
java.lang.String |
getSanitizedName()
Return the sanitized file name of this actor. |
void |
initialize()
If invokeJNI is true, then generate and compile the code (if necessary), and then execute the initialize() method of the generated code via JNI. |
void |
wrapup()
If invokeJNI is true, then execute the wrapup() method of the generated code via JNI. |
Methods inherited from class ptolemy.actor.TypedCompositeActor |
---|
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _typeConstraintsFromTo, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
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 |
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 |
---|
public FileParameter codeDirectory
public StringParameter generatorPackage
public Parameter inline
public Parameter invokeJNI
public Parameter overwriteFiles
private StringBufferExec _executeCommands
private java.lang.Object _jniWrapper
private java.lang.reflect.Method _jniFireMethod
private java.lang.reflect.Method _jniInitializeMethod
private java.lang.reflect.Method _jniWrapupMethod
private java.lang.String _sanitizedActorName
private long _generatedCodeVersion
private long _loadedCodeVersion
private int _version
private static int _noEffigyVersion
private static boolean _pointerTypeInitialized
Constructor Detail |
---|
public CompiledCompositeActor()
public CompiledCompositeActor(Workspace workspace)
workspace
- The workspace that will list the actor.public CompiledCompositeActor(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of this actor.
IllegalActionException
- If the container is incompatible
with this actor.
NameDuplicationException
- If the name coincides with
an actor already in the container.Method Detail |
---|
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class CompositeActor
IllegalActionException
- If thrown by the super
class, or if there are problems invoking the fire() method of
wrapper class.public java.lang.String getSanitizedName()
StringUtilities.sanitizeName(String)
,
removing underscores and appending a version number.
The version number is necessary so that we can reload the JNI
shared object.
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class CompositeActor
IllegalActionException
- If there is no director, or
if the director's initialize() method throws it, or if the
actor is not opaque.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class CompositeActor
IllegalActionException
- If there is no director,
or if the director's wrapup() method throws it, or if this
actor is not opaque.protected void _compileJavaCode() throws IllegalActionException
javac
and javah
commands are
executed on the the java file.
IllegalActionException
- If there is a problem reading
the codeDirectory parameter.protected void _generateAndCompileCCode() throws IllegalActionException
IllegalActionException
- If the helper class cannot
be found, or if the static generateCode(TypedCompositeActor)
method in the helper class cannot be found or invoked.protected void _generateAndCompileJavaCode() throws IllegalActionException
IllegalActionException
- If thrown while getting the path
to the shared object, while writing the Java file, or while
compiling the Java file.private boolean _buildSharedObjectFile() throws IllegalActionException
IllegalActionException
- If there is a problem
generating the path to the shared object.private java.lang.String _sharedObjectPath(java.lang.String sanitizedActorName) throws IllegalActionException
sanitizedActorName
- The sanitized actor name on
which to base the name of the shared object.
IllegalActionException
- If there is a problem
reading the codeDirectory parameter.private void _debugAndSystemOut(java.lang.String message)
message
- The given debug message.private java.lang.String _getArguments()
private java.lang.Object _invokeHelperMethod(java.lang.String methodName) throws IllegalActionException
methodName
- The name of a method in the helper class.
The method must be static and take a TypedCompositeArgument as its
only argument.
IllegalActionException
- If the helper class can't be
found or if the method cannot be invoked.private void _init()
private java.lang.Object _transferInputs(IOPort port) throws IllegalActionException
IllegalActionException
private void _transferOutputs(IOPort port, java.lang.Object outputTokens) throws IllegalActionException
IllegalActionException
private void _updateSanitizedActorName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |