public abstract class PortDirector extends Director
GenericCodeGenerator
Yellow (zhouye) |
Yellow (zhouye) |
NamedProgramCodeGeneratorAdapter.VariableScope
ProgramCodeGeneratorAdapter.Channel
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_sanitizedDirectorName
The name of the director in a format suitable to be used as a
variable name.
|
Ports |
ports
The meta information about the ports in the container.
|
_component, _defaultBlocks, _eol, _templateParser
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
PortDirector(Director director)
Construct the code generator adapter associated with the given director.
|
Modifier and Type | Method and Description |
---|---|
protected static boolean |
_checkLocal(boolean forComposite,
IOPort port)
Return true if the port is a local port.
|
protected static boolean |
_checkRemote(boolean forComposite,
IOPort port)
Return true if the port is a remote port.
|
protected java.lang.String |
_generateChannelOffset(TypedIOPort port,
boolean isWrite,
java.lang.String channelString)
Generate a string that represents the offset for a dynamically determined
channel of a multiport.
|
protected java.lang.String |
_generatePortReference(TypedIOPort port,
java.lang.String[] channelAndOffset,
boolean isWrite)
Generate a string that represents the reference for an IOPort.
|
protected java.lang.String |
_getCastType(java.lang.String name)
Get the cast type.
|
protected java.lang.String[] |
_getChannelAndOffset(java.lang.String name)
Return the channel and offset given in a string.
|
protected java.lang.String |
_getRefName(java.lang.String name)
Generate a string that represents the reference to a parameter or a port
named "name".
|
protected java.lang.String |
_getRefType(Attribute attribute)
Generate a string that represents the type of an attribute (only if it
is a parameter).
|
abstract java.lang.Boolean |
allowDynamicMultiportReference()
Return whether the channels in multiports can be dynamically
referenced using the $ref macro.
|
abstract java.lang.String |
generatePortName(TypedIOPort port)
Generate sanitized name for the given named object.
|
java.lang.String |
getReference(java.lang.String name,
boolean isWrite,
NamedProgramCodeGeneratorAdapter target)
Return the reference to the specified parameter or port of the
associated actor.
|
java.lang.String |
getReference(TypedIOPort port,
java.lang.String[] channelAndOffset,
boolean forComposite,
boolean isWrite,
NamedProgramCodeGeneratorAdapter target)
Return an unique label for the given port channel referenced
by the given adapter.
|
java.lang.String |
getSanitizedDirectorName()
Return the sanitized name of this director adapter.
|
abstract java.lang.Boolean |
padBuffers()
Return whether we need to pad buffers or not.
|
_ceilToPowerOfTwo, _generateVariableDeclaration, _generateVariableInitialization, _getParameter, generateCodeForGet, generateCodeForSend, generateConstructorCode, generateFireCode, generateFireFunctionCode, generateInitializeCode, generateModeTransitionCode, generatePostfireCode, generatePreinitializeCode, generatePreinitializeMethodBodyCode, generateTransferInputsCode, generateTransferInputsCode, generateTransferOutputsCode, generateTransferOutputsCode, generateVariableDeclaration, generateVariableDeclaration, generateVariableInitialization, generateVariableInitialization, generateWrapupCode, getComponent, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getParameter
_generateFireCode, _generateTypeConvertStatement, analyzeTypeConvert, copyFilesToCodeDirectory, generateMainLoop, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getBufferSize, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getHeaderFiles, getName, getParameterValue, getReference, getReference, getSharedCode, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, setupAdapter, targetType
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
createDecoratorAttributes, generateName
_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
public Ports ports
protected java.lang.String _sanitizedDirectorName
public PortDirector(Director director)
director
- The associated director.public abstract java.lang.Boolean allowDynamicMultiportReference() throws IllegalActionException
IllegalActionException
- If the expression cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.public abstract java.lang.String generatePortName(TypedIOPort port) throws IllegalActionException
port
- The port for which the name is generated.IllegalActionException
- If the variablesAsArrays parameter
cannot be read or if the buffer size of the port cannot be read.public java.lang.String getReference(java.lang.String name, boolean isWrite, NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
Usually given the name of an input port, getReference(String name) returns a target language variable name representing the input port. Given the name of an output port, getReference(String name) returns variable names representing the input ports connected to the output port. However, if the name of an input port starts with '@', getReference(String name) returns variable names representing the input ports connected to the given input port on the inside. If the name of an output port starts with '@', getReference(String name) returns variable name representing the the given output port which has inside receivers. The special use of '@' is for composite actor when tokens are transferred into or out of the composite actor.
getReference
in class Director
name
- The name of the parameter or portisWrite
- Whether to generate the write or read offset.target
- The ProgramCodeGeneratorAdapter for which code needs to be generated.IllegalActionException
- If the parameter or port does not
exist or does not have a value.public java.lang.String getReference(TypedIOPort port, java.lang.String[] channelAndOffset, boolean forComposite, boolean isWrite, NamedProgramCodeGeneratorAdapter target) throws IllegalActionException
port
- The given port.channelAndOffset
- The given channel and offset.forComposite
- Whether the given adapter is associated with
a CompositeActorisWrite
- The type of the reference. True if this is
a write reference; otherwise, this is a read reference.target
- The ProgramCodeGeneratorAdapter for which code
needs to be generated.IllegalActionException
- If the adapter throws it while
generating the label.public java.lang.String getSanitizedDirectorName()
public abstract java.lang.Boolean padBuffers() throws IllegalActionException
IllegalActionException
- If the expression cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.protected static boolean _checkLocal(boolean forComposite, IOPort port)
forComposite
- True if we are checking for a compositeport
- The port to be checked.protected static boolean _checkRemote(boolean forComposite, IOPort port)
forComposite
- True if this for a composite.port
- The port to check.protected java.lang.String _generateChannelOffset(TypedIOPort port, boolean isWrite, java.lang.String channelString) throws IllegalActionException
port
- The referenced port.isWrite
- Whether to generate the write or read offset.channelString
- The string that will determine the channel.IllegalActionException
- If thrown while generating the port name.protected java.lang.String _generatePortReference(TypedIOPort port, java.lang.String[] channelAndOffset, boolean isWrite) throws IllegalActionException
port
- The port to get the reference.isWrite
- Whether to generate the write or read offset.channelAndOffset
- The string[] that will determine the channel and the offset.IllegalActionException
- If thrown while generating
the channel offsite or generating the port name.protected java.lang.String _getCastType(java.lang.String name) throws IllegalActionException
name
- The name with # syntax.IllegalActionException
- If there are more than two #
in the name, indicating an invalid cast type.protected java.lang.String[] _getChannelAndOffset(java.lang.String name) throws IllegalActionException
name
- The given string.IllegalActionException
- If the channel index or offset
specified in the given string is illegal.protected java.lang.String _getRefName(java.lang.String name) throws IllegalActionException
name
- The name.IllegalActionException
- If the reference cannot
be found or is an invalid cast type.protected java.lang.String _getRefType(Attribute attribute)
attribute
- The attribute, which is typically a Parameter.