gov.llnl.babel.backend

Class CodeGenerationFactory


public class CodeGenerationFactory
extends java.lang.Object

This class stores and serves up instances CodeGenerator based on the string name of the code that the user wishes to generate. Classes derived from CodeGenerator will register themselves with this class (usually as part of a static initialization block). If a match based on the string name is not available, this class will try to dynamically load an instance based on some simple naming rules.
See Also:
CodeGenerator

Constructor Summary

CodeGenerationFactory()
Create a new instance of CodeGenerationFactory and initialize with reasonable defaults.

Method Summary

Collection
getBuildGenerators(String language)
Get the build generator appropriate for this language.
CodeGenerator
getCodeGenerator(String language, String mode)
Get a registered codeGenerator from the factory.
void
printRegisteredGenerators(PrintStream out)
void
registerBuildGenerator(BuildGenerator gen)
void
registerCodeGenerator(CodeGenerator gen)
Register a CodeGenerators with the factory.

Constructor Details

CodeGenerationFactory

public CodeGenerationFactory()
Create a new instance of CodeGenerationFactory and initialize with reasonable defaults.

Method Details

getBuildGenerators

public Collection getBuildGenerators(String language)
Get the build generator appropriate for this language.
Returns:
A collection of BuildGenerator interfaces. The elements of the collection are newly created instances. Two calls to getBuildGenerators with the same arguments will return separate instaces of the BuildGenerators.

getCodeGenerator

public CodeGenerator getCodeGenerator(String language,
                                      String mode)
Get a registered codeGenerator from the factory.
Parameters:
language - String name of the language
mode - Usually one of "stub", "skel", "ior", or "text"
Returns:
Live CodeGenerator or null if no match found. When not-null, the return value is a new instance of a CodeGenerator (i.e., two successive calls to getCodeGenerator with the same arguments will return two distinct instances of this CodeGenerator).

printRegisteredGenerators

public void printRegisteredGenerators(PrintStream out)

registerBuildGenerator

public void registerBuildGenerator(BuildGenerator gen)

registerCodeGenerator

public void registerCodeGenerator(CodeGenerator gen)
Register a CodeGenerators with the factory.
Parameters:
gen - instance of a CodeGenerator;