Class CompiledCompositeActor

    • Field Detail

      • codeDirectory

        public FileParameter codeDirectory
        The directory in which to put the generated code. This is a file parameter that must specify a directory. The default is $HOME/cg.
      • generatorPackage

        public StringParameter generatorPackage
        The name of the package in which to look for adapter class code generators. This is a string that defaults to "generic.program.procedural.java"
      • inline

        public Parameter inline
        If true, generate file with no functions. If false, generate file with functions. The default value is a parameter with the value true.
      • executeEmbeddedCode

        public Parameter executeEmbeddedCode
        If true, then invoke the generated code in the action methods (fire(), etc.). If the value is false, this actor will be executed executing like an ordinary composite actor. Classes like EmbeddedJavaActor set embedded to true when there is only Java code specifying the functionality of an actor.
      • overwriteFiles

        public Parameter overwriteFiles
        If true, overwrite preexisting files. The default value is a parameter with the value true.
    • Constructor Detail

      • CompiledCompositeActor

        public CompiledCompositeActor()
        Construct a CodeGenerationCompositeActor in the default workspace with no container and an empty string as its name. Add the actor to the workspace directory. You should set a director before attempting to execute it. You should set the container before sending data to it. Increment the version number of the workspace.
      • CompiledCompositeActor

        public CompiledCompositeActor​(CompositeEntity container,
                                      java.lang.String name)
                               throws IllegalActionException,
                                      NameDuplicationException
        Create an actor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor 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 actor will have no local director initially, and its executive director will be simply the director of the container. You should set a director before attempting to execute it.
        Parameters:
        container - The container actor.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
      • CompiledCompositeActor

        public CompiledCompositeActor​(Workspace workspace)
        Construct a CodeGenerationCompositeActor in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. You should set a director before attempting to execute it. You should set the container before sending data to it. Increment the version number of the workspace.
        Parameters:
        workspace - The workspace that will list the actor.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        If executeEmbeddedCode is true, then execute the fire() method of the generated code. Otherwise, delegate to the superclass, which executes this actor like an ordinary composite actor.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class CompositeActor
        Throws:
        IllegalActionException - If thrown by the super class, or if there are problems invoking the fire() method of wrapper class.
      • getSanitizedName

        public java.lang.String getSanitizedName()
        Return the sanitized file name of this actor. The sanitized name is created by invoking StringUtilities.sanitizeName(String), removing underscores and appending a version number. The version number is necessary so that we can reload the shared object.
        Returns:
        The sanitized actor name.
      • initialize

        public void initialize()
                        throws IllegalActionException
        If executeEmbeddedCode is true, then generate and compile the code (if necessary), and then execute the initialize() method of the generated code. Otherwise, delegate to the superclass, which initializes this actor like an ordinary composite actor.
        Specified by:
        initialize in interface Initializable
        Overrides:
        initialize in class CompositeActor
        Throws:
        IllegalActionException - If there is no director, or if the director's initialize() method throws it, or if the actor is not opaque.
      • wrapup

        public void wrapup()
                    throws IllegalActionException
        If executeEmbeddedCode is true, then execute the wrapup() method of the generated code. Otherwise, delegate to the superclass, which executes this actor like an ordinary composite actor.
        Specified by:
        wrapup in interface Initializable
        Overrides:
        wrapup in class CompositeActor
        Throws:
        IllegalActionException - If there is no director, or if the director's wrapup() method throws it, or if this actor is not opaque.
      • _compileJNICode

        protected void _compileJNICode()
                                throws IllegalActionException
        Compile the Java code. The javac and javah commands are executed on the the java file.
        Throws:
        IllegalActionException - If there is a problem reading the codeDirectory parameter.
      • _generateAndCompileEmbeddedCode

        protected void _generateAndCompileEmbeddedCode()
                                                throws IllegalActionException
        Generate and compile Java code.
        Throws:
        IllegalActionException - If the adapter class cannot be found, or if the static generateCode(TypedCompositeActor) method in the adapter class cannot be found or invoked.
      • _generateAndCompileJNICode

        protected void _generateAndCompileJNICode()
                                           throws IllegalActionException
        Generate and compile the JNI code.
        Throws:
        IllegalActionException - If thrown while getting the path to the shared object, while writing the Java file, or while compiling the Java file.
      • _transferOutputs

        protected static void _transferOutputs​(TypedCompositeActor compositeActor,
                                               IOPort port,
                                               java.lang.Object outputTokens)
                                        throws IllegalActionException
        Transfer the outputs.
        Parameters:
        compositeActor - The composite actor transferring the outputs.
        port - The port on which the output is to be transferred
        outputTokens - The tokens to be transferred.
        Throws:
        IllegalActionException - If there are problems getting the class or otherwise transferring the tokens.