Class ProgramCodeGeneratorAdapter
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
NamedProgramCodeGeneratorAdapter
,Receiver
public class ProgramCodeGeneratorAdapter extends CodeGeneratorAdapter
An adapter that generates code for programs.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Bert Rodiers
- Pt.AcceptedRating:
- Red (rodiers)
- Pt.ProposedRating:
- Red (rodiers)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProgramCodeGeneratorAdapter.Channel
A class that defines a channel object.-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
_component
The associated component.protected static java.lang.String[]
_defaultBlocks
The code block table that stores the code block body (StringBuffer) with the code block name (String) as key.protected static java.lang.String
_eol
End of line character.protected TemplateParser
_templateParser
The strategy for generating code for this adapter.-
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 ProgramCodeGeneratorAdapter(java.lang.Object component)
Construct the code generator adapter associated with the given component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_generateBlockByName(java.lang.String blockName)
Generate code for a given block.ProgramCodeGeneratorAdapter
getAdapter(java.lang.Object component)
Get the code generator adapter associated with the given component.ProgramCodeGenerator
getCodeGenerator()
Get the code generator associated with this adapter class.java.lang.Object
getComponent()
Get the component associated with this adapter.TemplateParser
getTemplateParser()
Get the template parser associated with this strategy.java.lang.String
processCode(java.lang.String code)
Process the specified code, replacing macros with their values.void
setCodeGenerator(GenericCodeGenerator codeGenerator)
Set the code generator associated with this adapter class.void
setTemplateParser(TemplateParser templateParser)
Set the template parser for this adapter.java.lang.String
toString()
Return the class name and the full name of the object, with syntax "className {fullName}".-
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, 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
-
-
-
-
Field Detail
-
_component
protected java.lang.Object _component
The associated component.
-
_defaultBlocks
protected static final java.lang.String[] _defaultBlocks
The code block table that stores the code block body (StringBuffer) with the code block name (String) as key.
-
_eol
protected static final java.lang.String _eol
End of line character. Under Unix: "\n", under Windows: "\n\r". We use a end of line character so that the files we generate have the proper end of line character for use by other native tools.
-
_templateParser
protected TemplateParser _templateParser
The strategy for generating code for this adapter.
-
-
Method Detail
-
getAdapter
public final ProgramCodeGeneratorAdapter getAdapter(java.lang.Object component) throws IllegalActionException
Get the code generator adapter associated with the given component.- Parameters:
component
- The given component.- Returns:
- The code generator adapter.
- Throws:
IllegalActionException
- If the adapter class cannot be found.
-
getCodeGenerator
public ProgramCodeGenerator getCodeGenerator()
Get the code generator associated with this adapter class.- Specified by:
getCodeGenerator
in classCodeGeneratorAdapter
- Returns:
- The code generator associated with this adapter class.
- See Also:
setCodeGenerator(GenericCodeGenerator)
-
getComponent
public java.lang.Object getComponent()
Get the component associated with this adapter.- Returns:
- The associated component.
-
processCode
public final java.lang.String processCode(java.lang.String code) throws IllegalActionException
Process the specified code, replacing macros with their values.- Parameters:
code
- The code to process.- Returns:
- The processed code.
- Throws:
IllegalActionException
- If illegal macro names are found.
-
setTemplateParser
public final void setTemplateParser(TemplateParser templateParser)
Set the template parser for this adapter.- Parameters:
templateParser
- The template parser.- See Also:
getTemplateParser()
-
setCodeGenerator
public void setCodeGenerator(GenericCodeGenerator codeGenerator)
Set the code generator associated with this adapter class.- Specified by:
setCodeGenerator
in classCodeGeneratorAdapter
- Parameters:
codeGenerator
- The code generator associated with this adapter class.- See Also:
getCodeGenerator()
-
getTemplateParser
public final TemplateParser getTemplateParser()
Get the template parser associated with this strategy.- Returns:
- The associated template parser.
- See Also:
setTemplateParser(TemplateParser)
-
toString
public java.lang.String toString()
Description copied from class:NamedObj
Return the class name and the full name of the object, with syntax "className {fullName}".
-
_generateBlockByName
protected java.lang.String _generateBlockByName(java.lang.String blockName) throws IllegalActionException
Generate code for a given block. The comment includes the portion of the blockName parameter up until the string "Block".- Parameters:
blockName
- The name of the block, which usually ends with the string "Block".- Returns:
- The generated wrapup code.
- Throws:
IllegalActionException
- If thrown while appending to the the block or processing the macros.
-
-