ptolemy.codegen.java.actor.lib.colt
Class ColtRandomSource

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.codegen.kernel.CodeGeneratorHelper
          extended by ptolemy.codegen.java.kernel.JavaCodeGeneratorHelper
              extended by ptolemy.codegen.java.actor.lib.colt.ColtRandomSource
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ActorCodeGenerator, ComponentCodeGenerator, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
ColtBinomial, ColtBinomialSelector, ColtPoisson

public abstract class ColtRandomSource
extends JavaCodeGeneratorHelper

A helper class for ptolemy.actor.lib.colt.ColtRandomSource.

Since:
Ptolemy II 8.0
Version:
$Id: ColtRandomSource.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Christopher Brooks
See Also:
Serialized Form
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (zgang)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
CodeGeneratorHelper.Channel, CodeGeneratorHelper.VariableScope
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
_codeGenerator, _codeStream, _eol, _INDENT1, _INDENT2, _parseTreeCodeGenerator, _portConversions, _referencedParameters
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ColtRandomSource(ColtRandomSource actor)
          Construct the RandomSource helper.
 
Method Summary
protected  java.lang.String _generateFireCode()
          Generate fire code.
protected abstract  java.lang.String _generateRandomNumber()
          Generate code for producing a new random number.
 java.lang.String generateInitializeCode()
          Generate the code for initializing the random number generator with the seed, if it has been given.
 java.util.Set getHeaderFiles()
          Get the files needed by the code generated for the ColtRandomSource actor.
 
Methods inherited from class ptolemy.codegen.java.kernel.JavaCodeGeneratorHelper
_generateInputVariableDeclaration, _generateOutputVariableDeclaration, _generateReferencedParameterDeclaration, _generateTypeConvertVariableDeclaration, _replaceMacro, generateVariableDeclaration, getCodeGenerator, getFunctionInvocation, getJVMHeaderFiles, getNewInvocation, getParseTreeCodeGenerator, getReference
 
Methods inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
_createBufferSizeAndOffsetMap, _createInputBufferSizeAndOffsetMap, _findClosedParen, _generateBlockCode, _generateBlockCode, _generateTypeConvertMethod, _generateTypeConvertStatement, _generateTypeConvertStatements, _getCastType, _getChannelAndOffset, _getFireFunctionArguments, _getHelper, _getHelper, _getIndentPrefix, _getReference, _getReferenceChannels, _getTypeConvertChannels, _getTypeConvertReference, _indexOf, addFunctionUsed, addNewTypeUsed, analyzeTypeConvert, checkLocal, checkRemote, codeGenType, copyFilesToCodeDirectory, createOffsetVariablesIfNeeded, generateChannelOffset, generateFireCode, generateFireFunctionCode, generateFireFunctionCode2, generateModeTransitionCode, generateName, generateOffset, generatePortReference, generatePostfireCode, generatePrefireCode, generatePreinitializeCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, generateVariableInitialization, generateVariableName, generateWrapupCode, getBufferSize, getBufferSize, getComponent, getDefaultBlocks, getDirector, getDirectorHelper, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getObject, getParameterValue, getPort, getRates, getReadOffset, getReference, getReference, getReference, getSharedCode, getSinkChannels, getSize, getSourceChannel, getWCET, getWriteOffset, isPrimitive, isPrimitive, parseList, processCode, resetInputPortsOffset, setBufferSize, setCodeGenerator, setReadOffset, setWriteOffset, targetType, toString
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColtRandomSource

public ColtRandomSource(ColtRandomSource actor)
Construct the RandomSource helper.

Parameters:
actor - the associated actor.
Method Detail

_generateFireCode

protected java.lang.String _generateFireCode()
                                      throws IllegalActionException
Generate fire code.

Overrides:
_generateFireCode in class CodeGeneratorHelper
Returns:
The generated code.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).

generateInitializeCode

public java.lang.String generateInitializeCode()
                                        throws IllegalActionException
Generate the code for initializing the random number generator with the seed, if it has been given. A seed of zero is interpreted to mean that no seed is specified. In such cases, a seed based on the current time and this instance of a ColtRandomSource is used to be fairly sure that two identical sequences will not be returned.

Specified by:
generateInitializeCode in interface ComponentCodeGenerator
Overrides:
generateInitializeCode in class CodeGeneratorHelper
Returns:
The initialize code of this actor.
Throws:
IllegalActionException - Not thrown in this class.

getHeaderFiles

public java.util.Set getHeaderFiles()
                             throws IllegalActionException
Get the files needed by the code generated for the ColtRandomSource actor.

Specified by:
getHeaderFiles in interface ActorCodeGenerator
Overrides:
getHeaderFiles in class JavaCodeGeneratorHelper
Returns:
A set of strings that are names of the files needed by the code generated for the ColtRandomSource actor.
Throws:
IllegalActionException - Not Thrown in this subclass.

_generateRandomNumber

protected abstract java.lang.String _generateRandomNumber()
                                                   throws IllegalActionException
Generate code for producing a new random number.

Returns:
The code that produces a new random number.
Throws:
IllegalActionException - Not thrown in this base class.