ptolemy.codegen.kernel
Interface ActorCodeGenerator

All Superinterfaces:
ComponentCodeGenerator
All Known Implementing Classes:
AbsoluteValue, AbstractActionsAttribute, Accumulator, Accumulator, AddSubtract, AddSubtract, AddSubtract, ArrayAppend, ArrayAverage, ArrayElement, ArrayElementAsMatrix, ArrayExtract, ArrayLength, ArrayLevelCrossing, ArrayMaximum, ArrayMinimum, ArrayPeakSearch, ArrayToElements, ArrayToSequence, AudioPlayer, AudioReader, AudioSDLActor, AudioWriter, Average, Bernoulli, BitsToInt, BooleanMultiplexor, BooleanMultiplexor, BooleanSelect, BooleanSwitch, BooleanToAnything, CartesianToComplex, CartesianToPolar, Case, Case, CaseDirector, CaseDirector, CCodeGeneratorHelper, Chop, Clock, CodegenActor, CodeGeneratorHelper, ColtBinomial, ColtBinomial, ColtBinomialSelector, ColtBinomialSelector, ColtPoisson, ColtPoisson, ColtRandomSource, ColtRandomSource, Commutator, Commutator, Comparator, Comparator, CompiledCompositeActor, CompiledCompositeActor, ComplexToCartesian, Const, Const, Const, Counter, CountTrues, CurrentTime, CurrentTime, CurrentTime, DEDirector, DEReceiver, Differential, Director, Director, DirectoryListing, Discard, Discard, DiscreteRandomSource, Display, Display, Display, Distributor, Distributor, DotProduct, DownSample, ElementsToArray, ElementsToArray, EmbeddedCActor, EmbeddedCActor.EmbeddedActor, EmbeddedCFileActor, EmbeddedCFileActor.EmbeddedFileActor, EmbeddedJavaActor, EmbeddedJavaActor.EmbeddedActor, Entity, Equals, Exit, Expression, Expression, Expression, ExpressionWriter, FileReader, FIR, FSMActor, FSMActor, FSMActor, FSMActor, FSMDirector, FSMDirector, FSMDirector, FSMDirector, FSMDirector, Gaussian, GiottoDirector, GiottoDirector, GradientAdaptiveLattice, HammingCoder, HammingDecoder, HDFDirector, HDFFSMDirector, Interpolator, IntToBits, IOPort, IOPort, IOPort, IORelation, IsPresent, JavaCodeGeneratorHelper, JopReadPort, JopSerialRead, JopSerialWrite, JopWatchDog, JopWritePort, Lattice, LEDMatrix, Limiter, Limiter, LineReader, LineWriter, LMSAdaptive, LogicalNot, LogicFunction, LogicFunction, LookupTable, Maximum, Minimum, Minimum, ModalController, ModalController, ModalModel, ModalModel, ModalModel, ModalPort, ModalPort, MonitorValue, MonitorValue, MovingAverage, MovingAverage, MultiCompositeActor, MultiCompositeActor, MultiCompositePort, MultiCompositePort, MultiInstanceComposite, MultiplyDivide, MultiplyDivide, MultirateFSMDirector, MultirateFSMDirector, MultirateFSMDirector, NonInterruptibleTimer, NonStrictDelay, NonStrictDisplay, NonStrictLogicFunction, NonStrictTest, OpenRTOSTarget, OrderedMerge, ParameterPort, ParameterPort, ParameterPort, PlotterBase, PNDirector, PNDirector, PolarToCartesian, PosixTarget, Publisher, Publisher, PublisherTest, PublisherTest, Pulse, Pulse, Pulse, Quantizer, RaisedCosine, Ramp, Ramp, Ramp, RampNecessaryFiles, RandomSource, RandomSource, Receiver, RecursiveLattice, Refinement, Refinement, Refinement, Refinement, RefinementPort, RefinementPort, RefinementPort, RefinementPort, Remainder, Repeat, Repeat, Rician, Round, Round, RTMaudeAdaptor, SampleDelay, SampleDelay, Scale, Scale, Scale, SDFDirector, SDFDirector, SDFDirector, SDFDirector, Sequence, Sequence, SequencePlotter, SequencePlotter, SequenceScope, SequenceToArray, SetVariable, SetVariable, SimpleALU, SingleEvent, Sink, Sleep, SliderSource, SRDirector, SRDirector, StaticALU, StaticSchedulingDirector, StaticSchedulingDirector, Stop, StringCompare, StringConst, StringConst, StringFunction, StringIndexOf, StringLength, StringLength, StringMatches, StringSimpleReplace, StringSubstring, StringToIntArray, StringToUnsignedByteArray, Subscriber, Subscriber, SubscriptionAggregator, SubscriptionAggregator, Synchronizer, Test, Test, TestCodeGeneratorHelper, TestExpression, ThrowException, ThrowModelError, TimedDelay, TimedDelay, TimedPlotter, TimedPlotter, TimedPlotter, Timer, TokenToExpression, TokenToExpression, Transition, TransitionRefinement, TransitionRefinement, TransitionRefinementPort, TransitionRefinementPort, TrigFunction, TrigFunction, TypedAtomicActor, TypedCompositeActor, TypedCompositeActor, TypedCompositeActor, TypedCompositeActor, TypedCompositeActor, TypedIOPort, TypedIOPort, UnaryMathFunction, UnaryMathFunction, Uniform, Uniform, UpSample, Variable, VariableDelay, VariableFIR, VariableLattice, VariableRecursiveLattice, VectorAssembler, VectorAssembler, VectorDisassembler, VectorDisassembler, WallClockTime, XYPlotter, XYScope

public interface ActorCodeGenerator
extends ComponentCodeGenerator

FIXME: class comments needed.

Since:
Ptolemy II 6.0
Version:
$Id: ActorCodeGenerator.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Brooks, Edward Lee, Jackie Leung, Gang Zhou, Ye Zhou, Contributors: Teale Fristoe
Accepted Rating:
Yellow (eal)
Proposed Rating:
Yellow (eal)

Method Summary
 java.lang.String createOffsetVariablesIfNeeded()
          Create read and write offset variables if needed for the associated composite actor.
 java.lang.String generateFireCode()
          Generate into the specified string buffer the code associated with one firing of the container composite actor.
 java.lang.String generateFireFunctionCode()
          Generate The fire function code.
 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 generatePrefireCode()
          Generate the prefire code of the associated composite actor.
 java.lang.String generatePreinitializeCode()
          Generate the preinitialize code of the associated composite actor.
 java.lang.String generateVariableDeclaration()
          Generate variable declarations for inputs and outputs and parameters.
 java.lang.String generateVariableInitialization()
          Generate variable initialization for the referenced parameters.
 java.util.Set getHeaderFiles()
          Get the files needed by the code generated from this helper class.
 java.util.Set getIncludeDirectories()
          Return a set of the directories to search for the actor's include files.
 java.util.Set getLibraries()
          Return a set of the libraries to link the generated code to.
 java.util.Set getLibraryDirectories()
          Return a set of the directories to search for libraries.
 java.util.Set getModifiedVariables()
          Return a set of parameters that will be modified during the execution of the model.
 java.util.Set getSharedCode()
          Generate the shared code.
 
Methods inherited from interface ptolemy.codegen.kernel.ComponentCodeGenerator
generateInitializeCode, generateWrapupCode, getComponent, setCodeGenerator
 

Method Detail

createOffsetVariablesIfNeeded

java.lang.String createOffsetVariablesIfNeeded()
                                               throws IllegalActionException
Create read and write offset variables if needed for the associated composite actor. It delegates to the director helper of the local director.

Returns:
A string containing declared read and write offset variables.
Throws:
IllegalActionException - If the helper class cannot be found or the director helper throws it.

generateFireCode

java.lang.String generateFireCode()
                                  throws IllegalActionException
Generate into the specified string buffer the code associated with one firing of the container composite actor.

Returns:
The generated fire code.
Throws:
IllegalActionException - If something goes wrong.

generateFireFunctionCode

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.

Returns:
The fire function code.
Throws:
IllegalActionException - If thrown while generating fire code.

generateModeTransitionCode

void generateModeTransitionCode(java.lang.StringBuffer code)
                                throws IllegalActionException
Generate mode transition code. It delegates to the director helper of the local director. The mode transition code generated in this method is executed after each global iteration, e.g., in HDF model.

Parameters:
code - The string buffer that the generated code is appended to.
Throws:
IllegalActionException - If the director helper throws it while generating mode transition code.

generatePostfireCode

java.lang.String generatePostfireCode()
                                      throws IllegalActionException
Generate the postfire code of the associated composite actor.

Returns:
The postfire code of the associated composite actor.
Throws:
IllegalActionException - If the helper associated with an actor throws it while generating the postfire code for the actor.

generatePrefireCode

java.lang.String generatePrefireCode()
                                     throws IllegalActionException
Generate the prefire code of the associated composite actor.

Returns:
The prefire code of the associated composite actor.
Throws:
IllegalActionException - If the helper associated with an actor throws it while generating the prefire code for the actor.

generatePreinitializeCode

java.lang.String generatePreinitializeCode()
                                           throws IllegalActionException
Generate the preinitialize code of the associated composite actor. It first creates buffer size and offset map for its input ports and output ports. It then gets the result of generatePreinitializeCode() method of the local director helper.

Returns:
The preinitialize code of the associated composite actor.
Throws:
IllegalActionException - If the helper associated with an actor throws it while generating preinitialize code for the actor or while creating buffer size and offset map.

getHeaderFiles

java.util.Set getHeaderFiles()
                             throws IllegalActionException
Get the files needed by the code generated from this helper class. This base class returns an empty set.

Returns:
A set of strings that are header files needed by the code generated from this helper class.
Throws:
IllegalActionException - If something goes wrong.

getIncludeDirectories

java.util.Set getIncludeDirectories()
                                    throws IllegalActionException
Return a set of the directories to search for the actor's include files.

Returns:
A set of directories to search for the actor's include files.
Throws:
IllegalActionException - If thrown when finding the directories.

getLibraries

java.util.Set getLibraries()
                           throws IllegalActionException
Return a set of the libraries to link the generated code to.

Returns:
A set of libraries to link.
Throws:
IllegalActionException - If thrown when finding the libraries.

getLibraryDirectories

java.util.Set getLibraryDirectories()
                                    throws IllegalActionException
Return a set of the directories to search for libraries.

Returns:
A set of directories to search.
Throws:
IllegalActionException - If thrown when finding the libraries.

getModifiedVariables

java.util.Set getModifiedVariables()
                                   throws IllegalActionException
Return a set of parameters that will be modified during the execution of the model. The actor gets those variables if it implements ExplicitChangeContext interface or it contains PortParameters.

Returns:
a set of parameters that will be modified.
Throws:
IllegalActionException - If an actor throws it while getting modified variables.

getSharedCode

java.util.Set getSharedCode()
                            throws IllegalActionException
Generate the shared code. This is the first generate method invoked out of all, so any initialization of variables of this helper should be done in this method. In this base class, return an empty set. Subclasses may generate code for variable declaration, defining constants, etc.

Returns:
An empty set in this base class.
Throws:
IllegalActionException - Not thrown in this base class.

generateVariableDeclaration

java.lang.String generateVariableDeclaration()
                                             throws IllegalActionException
Generate variable declarations for inputs and outputs and parameters. Append the declarations to the given string buffer.

Returns:
code The generated code.
Throws:
IllegalActionException - If the helper class for the model director cannot be found.

generateVariableInitialization

java.lang.String generateVariableInitialization()
                                                throws IllegalActionException
Generate variable initialization for the referenced parameters.

Returns:
code The generated code.
Throws:
IllegalActionException - If the helper class for the model director cannot be found.