Class TypedCompositeActor
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.TypedCompositeActor
-
- ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.TypedCompositeActor
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
CompiledCompositeActor
,ModularCodeGenTypedCompositeActor
,MultiCompositeActor
,Refinement
,TypedCompositeActor
public class TypedCompositeActor extends TypedCompositeActor
Code generator adapter for typed composite actor.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Gang Zhou, Contributors: Teale Fristoe, Bert Rodiers
- Pt.AcceptedRating:
- Red (zgang)
- Pt.ProposedRating:
- Yellow (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
NamedProgramCodeGeneratorAdapter.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
ProgramCodeGeneratorAdapter.Channel
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_component, _defaultBlocks, _eol, _templateParser
-
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 TypedCompositeActor(TypedCompositeActor component)
Construct the code generator adapter associated with the given TypedCompositeActor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_generateFireCode()
Generate the fire code of the associated composite actor.void
analyzeTypeConvert()
For each actor in this typed composite actor, determine which ports need type conversion.java.lang.String
generateFireFunctionCode()
Generate The fire function code.java.lang.String
generateInitializeCode()
Generate the initialize code of the associated composite actor.void
generateModeTransitionCode(java.lang.StringBuffer code)
Generate mode transition code.java.lang.String
generatePostfireCode()
Generate the postfire code of the associated composite actor.java.lang.String
generateVariableDeclaration()
Generate variable declarations for input ports, output ports and parameters if necessary, as well as for the director and the contained actors.java.lang.String
generateVariableInitialization()
Generate variable initialization for the referenced parameters.java.lang.String
generateWrapupCode()
Generate the wrapup code of the associated composite actor.java.util.Set<java.lang.String>
getDeclareSharedCode()
Generate a set of declaration shared code fragments of the associated composite actor.java.util.Set<java.lang.String>
getHeaderFiles()
Get the header files needed by the code generated from this adapter class.java.util.Set<java.lang.String>
getIncludeDirectories()
Return the include directories specified in the "includeDirectories" blocks in the templates of the actors included in this CompositeActor.java.util.Set<java.lang.String>
getLibraries()
Return the libraries specified in the "libraries" blocks in the templates of the actors included in this CompositeActor.java.util.Set<java.lang.String>
getLibraryDirectories()
Return the libraries specified in the "libraryDirectories" blocks in the templates of the actors included in this CompositeActor.java.util.Set<Parameter>
getModifiedVariables()
Return a set of parameters that will be modified during the execution of the model.java.util.Set<java.lang.String>
getSharedCode()
Generate a set of shared code fragments of the associated composite actor.void
setupAdapter()
Set up adapters contained by the composite actor.-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.TypedCompositeActor
generatePreinitializeCode, generatePreinitializeMethodBodyCode
-
Methods inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
_generateTypeConvertStatement, copyFilesToCodeDirectory, generateFireCode, generateMainLoop, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getBufferSize, getComponent, getDefaultBlocks, getFireFunctionParameters, getName, getParameterValue, getReference, getReference, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, targetType
-
Methods inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
-
Methods inherited from class ptolemy.cg.kernel.generic.CodeGeneratorAdapter
createDecoratorAttributes, generateName
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
-
-
-
Constructor Detail
-
TypedCompositeActor
public TypedCompositeActor(TypedCompositeActor component)
Construct the code generator adapter associated with the given TypedCompositeActor.- Parameters:
component
- The associated component.
-
-
Method Detail
-
analyzeTypeConvert
public void analyzeTypeConvert() throws IllegalActionException
For each actor in this typed composite actor, determine which ports need type conversion.- Overrides:
analyzeTypeConvert
in classNamedProgramCodeGeneratorAdapter
- Throws:
IllegalActionException
- If any of the adapters of the inside actors is unavailable.- See Also:
NamedProgramCodeGeneratorAdapter.analyzeTypeConvert()
-
generateFireFunctionCode
public java.lang.String generateFireFunctionCode() throws IllegalActionException
Generate The fire function code. This method is called when the firing code of each actor is not inlined. Each actor's firing code is in a function with the same name as that of the actor.- Overrides:
generateFireFunctionCode
in classNamedProgramCodeGeneratorAdapter
- Returns:
- The fire function code.
- Throws:
IllegalActionException
- If thrown while generating fire code.
-
generateInitializeCode
public java.lang.String generateInitializeCode() throws IllegalActionException
Generate the initialize code of the associated composite actor. It first resets the read and write offset of all input ports of all contained actors and all output ports. It then gets the result of generateInitializeCode() method of the local director adapter.- Overrides:
generateInitializeCode
in classTypedCompositeActor
- Returns:
- The initialize code of the associated composite actor.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating initialize code for the actor or while resetting read and write offset.
-
generateModeTransitionCode
public void generateModeTransitionCode(java.lang.StringBuffer code) throws IllegalActionException
Generate mode transition code. It delegates to the director adapter of the local director. The mode transition code generated in this method is executed after each global iteration, e.g., in HDF model.- Overrides:
generateModeTransitionCode
in classNamedProgramCodeGeneratorAdapter
- Parameters:
code
- The string buffer that the generated code is appended to.- Throws:
IllegalActionException
- If the director adapter throws it while generating mode transition code.
-
generatePostfireCode
public java.lang.String generatePostfireCode() throws IllegalActionException
Generate the postfire code of the associated composite actor. It returns the result of generatePostfireCode() method of the local director adapter.- Overrides:
generatePostfireCode
in classNamedProgramCodeGeneratorAdapter
- Returns:
- The postfire code of the associated composite actor.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating postfire code for the actor.
-
generateVariableDeclaration
public java.lang.String generateVariableDeclaration() throws IllegalActionException
Generate variable declarations for input ports, output ports and parameters if necessary, as well as for the director and the contained actors.- Overrides:
generateVariableDeclaration
in classNamedProgramCodeGeneratorAdapter
- Returns:
- code The generated code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating variable declarations for the actor.
-
generateVariableInitialization
public java.lang.String generateVariableInitialization() throws IllegalActionException
Generate variable initialization for the referenced parameters.- Overrides:
generateVariableInitialization
in classNamedProgramCodeGeneratorAdapter
- Returns:
- code The generated code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating variable declarations for the actor.
-
generateWrapupCode
public java.lang.String generateWrapupCode() throws IllegalActionException
Generate the wrapup code of the associated composite actor. It returns the result of generateWrapupCode() method of the local director adapter.- Overrides:
generateWrapupCode
in classTypedCompositeActor
- Returns:
- The wrapup code of the associated composite actor.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating wrapup code for the actor.
-
getHeaderFiles
public java.util.Set<java.lang.String> getHeaderFiles() throws IllegalActionException
Get the header files needed by the code generated from this adapter class. It returns the result of calling getHeaderFiles() method of the adapters of all contained actors.- Overrides:
getHeaderFiles
in classNamedProgramCodeGeneratorAdapter
- Returns:
- A set of strings that are header files.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating header files for the actor.
-
getIncludeDirectories
public java.util.Set<java.lang.String> getIncludeDirectories() throws IllegalActionException
Return the include directories specified in the "includeDirectories" blocks in the templates of the actors included in this CompositeActor.- Overrides:
getIncludeDirectories
in classNamedProgramCodeGeneratorAdapter
- Returns:
- A Set of the include directories.
- Throws:
IllegalActionException
- If thrown when gathering include directories.
-
getLibraries
public java.util.Set<java.lang.String> getLibraries() throws IllegalActionException
Return the libraries specified in the "libraries" blocks in the templates of the actors included in this CompositeActor.- Overrides:
getLibraries
in classNamedProgramCodeGeneratorAdapter
- Returns:
- A Set of libraries.
- Throws:
IllegalActionException
- If thrown when gathering libraries.
-
getLibraryDirectories
public java.util.Set<java.lang.String> getLibraryDirectories() throws IllegalActionException
Return the libraries specified in the "libraryDirectories" blocks in the templates of the actors included in this CompositeActor.- Overrides:
getLibraryDirectories
in classNamedProgramCodeGeneratorAdapter
- Returns:
- A Set of libraryDirectories
- Throws:
IllegalActionException
- If thrown when gathering libraries.
-
getModifiedVariables
public java.util.Set<Parameter> getModifiedVariables() throws IllegalActionException
Return a set of parameters that will be modified during the execution of the model. These parameters are those returned by getModifiedVariables() method of directors or actors that implement ExplicitChangeContext interface.- Overrides:
getModifiedVariables
in classNamedProgramCodeGeneratorAdapter
- Returns:
- a set of parameters that will be modified.
- Throws:
IllegalActionException
- If the adapter associated with an actor or director throws it while getting modified variables.
-
getDeclareSharedCode
public java.util.Set<java.lang.String> getDeclareSharedCode() throws IllegalActionException
Generate a set of declaration shared code fragments of the associated composite actor. It returns the result of calling getDeclareSharedCode() method of the adapters of all contained actors.- Overrides:
getDeclareSharedCode
in classNamedProgramCodeGeneratorAdapter
- Returns:
- a set of shared code fragments.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating shared code for the actor.
-
getSharedCode
public java.util.Set<java.lang.String> getSharedCode() throws IllegalActionException
Generate a set of shared code fragments of the associated composite actor. It returns the result of calling getSharedCode() method of the adapters of all contained actors.- Overrides:
getSharedCode
in classTypedCompositeActor
- Returns:
- a set of shared code fragments.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating shared code for the actor.
-
setupAdapter
public void setupAdapter() throws IllegalActionException
Set up adapters contained by the composite actor. This method is run very early in the code generation sequence, so adapters that need to set up code generation-time variables may have setupAdapter() methods that need to be invoked. Variables and shared code that are to be generated should be in generateSharedCode() or other methods, not this method.- Overrides:
setupAdapter
in classNamedProgramCodeGeneratorAdapter
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while being set up.
-
_generateFireCode
protected java.lang.String _generateFireCode() throws IllegalActionException
Generate the fire code of the associated composite actor. This method first generates code for transferring any data from the input ports of this composite to the ports connected on the inside by calling the generateTransferInputsCode() method of the local director adapter. It then invokes the generateFireCode() method of its local director adapter. After the generateFireCode() method of the director adapter returns, generate code for transferring any output data created by calling the local director adapter's generateTransferOutputsCode() method.- Overrides:
_generateFireCode
in classTypedCompositeActor
- Returns:
- The generated fire code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating fire code for the actor, or the director adapter throws it while generating code for transferring data.
-
-