Class Receiver
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.Receiver
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
DEReceiver
,GiottoReceiver
,PtidesBasicReceiver
,SDFReceiver
public abstract class Receiver extends ProgramCodeGeneratorAdapter
The base class adapter for Receiver.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Jia Zou, Man-Kit Leung, Isaac Liu, Bert Rodiers
- Pt.AcceptedRating:
- Red (jiazou)
- Pt.ProposedRating:
- Red (jiazou)
-
-
Nested Class Summary
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.String
_generateTypeConvertStatement(ProgramCodeGeneratorAdapter.Channel source)
Generate the type conversion statement for the particular offset of the two given channels.protected Director
_getDirectorForReceiver()
Each receiver is associated with a director, return that director.protected java.lang.String
_removeSink(java.lang.String token)
Given a String that is an assignment operation, return the right hand side (the source).abstract java.lang.String
generateGetCode(java.lang.String offset)
Generate code for getting tokens from the receiver.abstract java.lang.String
generateHasTokenCode(java.lang.String offset)
Generate code to check if the receiver has a token.java.lang.String
generateInitializeCode()
Generate the initialize code.abstract java.lang.String
generatePutCode(IOPort sourcePort, java.lang.String offset, java.lang.String token)
Generate code for putting tokens to the receiver.Receiver
getComponent()
Get the corresponding component.java.lang.String
getName()
Return the name of this receiver.-
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
-
Receiver
public Receiver(Receiver receiver) throws IllegalActionException
Construct the Receiver adapter.- Parameters:
receiver
- The ptolemy.actor.receiver that corresponds with this adapter- Throws:
IllegalActionException
- If thrown by the super class.
-
-
Method Detail
-
generateGetCode
public abstract java.lang.String generateGetCode(java.lang.String offset) throws IllegalActionException
Generate code for getting tokens from the receiver.- Parameters:
offset
- The offset in the array representation of the port.- Returns:
- The code for getting tokens from the receiver.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the get code.
-
generateHasTokenCode
public abstract java.lang.String generateHasTokenCode(java.lang.String offset) throws IllegalActionException
Generate code to check if the receiver has a token.- Parameters:
offset
- The offset in the array representation of the port.- Returns:
- The code to check if the receiver has a token.
- Throws:
IllegalActionException
- If an error occurs when getting the receiver adapters or generating their initialize code.
-
generateInitializeCode
public java.lang.String generateInitializeCode() throws IllegalActionException
Generate the initialize code. In this base class, return empty string. Subclasses may extend this method to generate initialize code of the associated component and append the code to the given string buffer.- Returns:
- The initialize code of the containing composite actor.
- Throws:
IllegalActionException
- If thrown while appending to the the block or processing the macros.
-
generatePutCode
public abstract java.lang.String generatePutCode(IOPort sourcePort, java.lang.String offset, java.lang.String token) throws IllegalActionException
Generate code for putting tokens to the receiver. Note the type conversion is also done in this put method.- Parameters:
sourcePort
- The port for which to generate the send code.offset
- The offset in the array representation of the port.token
- The token to be sent.- Returns:
- The code to put tokens to the receiver.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the send code.
-
getComponent
public Receiver getComponent()
Get the corresponding component.- Overrides:
getComponent
in classProgramCodeGeneratorAdapter
- Returns:
- the component that corresponds with this receiver.
-
getName
public java.lang.String getName()
Return the name of this receiver.- Specified by:
getName
in interfaceNameable
- Overrides:
getName
in classNamedObj
- Returns:
- the name of this receiver.
- See Also:
NamedObj.setName(String)
-
_generateTypeConvertStatement
protected abstract java.lang.String _generateTypeConvertStatement(ProgramCodeGeneratorAdapter.Channel source) throws IllegalActionException
Generate the type conversion statement for the particular offset of the two given channels. This assumes that the offset is the same for both channel. Advancing the offset of one has to advance the offset of the other.- Parameters:
source
- The given source channel.- Returns:
- The type convert statement for assigning the converted source variable to the sink variable with the given offset.
- Throws:
IllegalActionException
- If there is a problem getting the adapters for the ports or if the conversion cannot be handled.
-
_removeSink
protected java.lang.String _removeSink(java.lang.String token) throws IllegalActionException
Given a String that is an assignment operation, return the right hand side (the source).The token should be in the form of "sinkRef = $convert(sourceRef)".
- Parameters:
token
- A string that contains the assignment.- Returns:
- The right hand side of the assignment.
- Throws:
IllegalActionException
- If the token does contain a "=".
-
_getDirectorForReceiver
protected Director _getDirectorForReceiver() throws IllegalActionException
Each receiver is associated with a director, return that director.- Returns:
- The director associated with this receiver.
- Throws:
IllegalActionException
- FIXME: this is not exactly correct.
-
-