Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.cal.services
Class ProgramModelManager

java.lang.Object
  extended by org.openquark.cal.services.ProgramModelManager
Direct Known Subclasses:
WorkspaceManager

public class ProgramModelManager
extends Object

This class presents a higher-level abstraction to the program manager. It can manage queries and changes to the program without having to know about a program manager.

Author:
Edward Lam

Nested Class Summary
static class ProgramModelManager.CompilationOptions
          A class to encapsulate the various compilation options when compiling a module or adjunct.
 
Constructor Summary
ProgramModelManager(ProgramManager programManager)
          Constructor for a program model manager.
 
Method Summary
 void addStatusListener(StatusListener listener)
           
 void compile(ModuleSourceDefinitionGroup definitionGroup, CompilerMessageLogger logger, boolean dirtyModulesOnly, StatusListener statusListener)
          Compile the modules in this manager.
 void compile(ModuleSourceDefinitionGroup definitionGroup, CompilerMessageLogger logger, boolean dirtyModulesOnly, StatusListener statusListener, ProgramModelManager.CompilationOptions options)
          Compile the modules in this manager.
 Compiler getCompiler()
          Get the Compiler for this manager.
 Compiler getCompiler(ProgramModelManager.CompilationOptions compilationOptions)
          Get the Compiler for this manager.
 Set<ModuleName> getDependentModuleNames(ModuleName targetModule)
           
 org.openquark.cal.machine.MachineFunction getMachineFunction(QualifiedName functionName)
          Retrieves the specified machine function.
 MachineStatistics getMachineStatistics()
           
 MachineStatistics getMachineStatisticsForModule(ModuleName moduleName)
           
 MachineType getMachineType()
          Returns the machine type associated with this WorkspaceManager.
 org.openquark.cal.machine.Module getModule(ModuleName name)
          Gets the module with a given moduleName.
 ModuleName[] getModuleNamesInProgram()
          Returns the names of the modules contained by the Program instance encapsulated by this WorkspaceManager.
 List<org.openquark.cal.machine.Module> getModules()
          Return a list of Module object for modules contained the ProgramManager instance encapsulated by this ProgramModleManager.
 ModuleTypeInfo getModuleTypeInfo(ModuleName moduleName)
           
 int getNFunctionsInModule(ModuleName moduleName)
          Returns the number of functions in the specified module.
protected  ProgramManager getProgramManager()
           
 TypeChecker getTypeChecker()
           
 boolean hasModuleInProgram(ModuleName moduleName)
          Returns true iff the specified module is in the Program instance encapsulated by this WorkspaceManager.
 ExecutionContext makeExecutionContext(ExecutionContextProperties properties)
          Factory method for creating a machine-specific execution context.
 ExecutionContext makeExecutionContextWithDefaultProperties()
          Factory method for creating a machine-specific execution context with default values for the execution context's properties.
 CALExecutor makeExecutor(ExecutionContext context)
          Factory method for creating a machine-specific executor.
 CALExecutor makeExecutorWithNewContext(ExecutionContextProperties properties)
          Factory method for creating a machine-specific executor with a new execution context.
 CALExecutor makeExecutorWithNewContextAndDefaultProperties()
          Factory method for creating a machine-specific executor with a new execution context and default values for the execution context's properties.
 CompilerMessage.Severity makeModule(ModuleSourceDefinition sourceDef, CompilerMessageLogger logger)
          Compile a module to the current program.
 CompilerMessage.Severity makeModule(ModuleSourceDefinition sourceDef, CompilerMessageLogger logger, ProgramModelManager.CompilationOptions options)
          Compile a module to the current program.
 CompilerMessage.Severity makeModules(ModuleName[] moduleNames, ModuleSourceDefinitionGroup definitionGroup, CompilerMessageLogger logger)
          Compile module(s) to the current program.
 CompilerMessage.Severity makeModules(ModuleName[] moduleNames, ModuleSourceDefinitionGroup definitionGroup, CompilerMessageLogger logger, ProgramModelManager.CompilationOptions options)
          Compile module(s) to the current program.
protected  ProgramModifier makeProgramModifier(ProgramModelManager.CompilationOptions options)
          Makes a new disposable copy of the program modifier.
 boolean removeModule(ModuleName moduleName)
          Remove a module from the program.
 void removeStatusListener(StatusListener listener)
           
 void resetCachedResults(ExecutionContext context)
          Discarded any cached (memoized) results in this program.
 void resetCachedResults(ModuleName moduleName, ExecutionContext context)
          Discard any cached (memoized) results in the named module and any dependent modules.
 void resetMachineState(ExecutionContext context)
          Discarded the machine state, including any cached (memoized) results in this program.
 void resetMachineState(ModuleName moduleName, ExecutionContext context)
          Discard the machine state, including any cached (memoized) results in the named module and any dependent modules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgramModelManager

public ProgramModelManager(ProgramManager programManager)
Constructor for a program model manager. This is intended to be called by the unit testing infrastructure to specify a custom ProgramManager.

Parameters:
programManager - the ProgramManager for this ProgramModelManager.
Method Detail

makeProgramModifier

protected ProgramModifier makeProgramModifier(ProgramModelManager.CompilationOptions options)
Makes a new disposable copy of the program modifier.

Parameters:
options - - the values for compiler options
Returns:
a copy of the program modifier, either a new one, or the private copy held by this workspace manager.

getCompiler

public Compiler getCompiler()
Get the Compiler for this manager.

Returns:
Compiler

getCompiler

public Compiler getCompiler(ProgramModelManager.CompilationOptions compilationOptions)
Get the Compiler for this manager.

Parameters:
compilationOptions - the compilation options for the compiler.
Returns:
Compiler

getTypeChecker

public TypeChecker getTypeChecker()
Returns:
a type checker associated with this manager.

makeExecutionContext

public ExecutionContext makeExecutionContext(ExecutionContextProperties properties)
Factory method for creating a machine-specific execution context.

Parameters:
properties - the ExecutionContextProperties instance encapsulating an immutable map of key-value pairs which is exposed as system properties from within CAL.
Returns:
a new CALExecutor.Context instance.

makeExecutionContextWithDefaultProperties

public ExecutionContext makeExecutionContextWithDefaultProperties()
Factory method for creating a machine-specific execution context with default values for the execution context's properties.

Returns:
a new CALExecutor.Context instance.

makeExecutor

public CALExecutor makeExecutor(ExecutionContext context)
Factory method for creating a machine-specific executor.

Parameters:
context - the execution context to be used by the executor.
Returns:
a new CALExecutor instance.

makeExecutorWithNewContext

public CALExecutor makeExecutorWithNewContext(ExecutionContextProperties properties)
Factory method for creating a machine-specific executor with a new execution context.

Parameters:
properties - the ExecutionContextProperties instance encapsulating an immutable map of key-value pairs which is exposed as system properties from within CAL.
Returns:
a new CALExecutor instance with a new execution context.

makeExecutorWithNewContextAndDefaultProperties

public CALExecutor makeExecutorWithNewContextAndDefaultProperties()
Factory method for creating a machine-specific executor with a new execution context and default values for the execution context's properties.

Returns:
a new CALExecutor instance with a new execution context.

compile

public void compile(ModuleSourceDefinitionGroup definitionGroup,
                    CompilerMessageLogger logger,
                    boolean dirtyModulesOnly,
                    StatusListener statusListener)
Compile the modules in this manager.

Parameters:
logger - the logger used to log error messages.
dirtyModulesOnly - if true, only dirty (uncompiled or changed) modules will be compiled.
statusListener - a listener, possibly null, for the status of the compilation process

compile

public void compile(ModuleSourceDefinitionGroup definitionGroup,
                    CompilerMessageLogger logger,
                    boolean dirtyModulesOnly,
                    StatusListener statusListener,
                    ProgramModelManager.CompilationOptions options)
Compile the modules in this manager.

Parameters:
logger - the logger used to log error messages.
dirtyModulesOnly - if true, only dirty (uncompiled or changed) modules will be compiled.
statusListener - a listener, possibly null, for the status of the compilation process
options - - values for compilation options

getProgramManager

protected final ProgramManager getProgramManager()
Returns:
the program manager.

makeModule

public CompilerMessage.Severity makeModule(ModuleSourceDefinition sourceDef,
                                           CompilerMessageLogger logger)
Compile a module to the current program. Dependent modules will be removed from the program.

Parameters:
sourceDef - the ModuleSourceDefinition to compile.
logger - the logger to use during the compile.
Returns:
the highest error condition experienced

makeModule

public CompilerMessage.Severity makeModule(ModuleSourceDefinition sourceDef,
                                           CompilerMessageLogger logger,
                                           ProgramModelManager.CompilationOptions options)
Compile a module to the current program. Dependent modules will be removed from the program.

Parameters:
sourceDef - the ModuleSourceDefinition to compile.
logger - the logger to use during the compile.
options - - values for the compilation options
Returns:
the highest error condition experienced

makeModules

public CompilerMessage.Severity makeModules(ModuleName[] moduleNames,
                                            ModuleSourceDefinitionGroup definitionGroup,
                                            CompilerMessageLogger logger)
Compile module(s) to the current program. Dependent modules will be removed if not included.

Parameters:
moduleNames - a list of the names of the changed modules.
definitionGroup - the definition group from which the module definitions may be retrieved.
logger - the logger to use during the compile.
Returns:
the highest error condition experienced

makeModules

public CompilerMessage.Severity makeModules(ModuleName[] moduleNames,
                                            ModuleSourceDefinitionGroup definitionGroup,
                                            CompilerMessageLogger logger,
                                            ProgramModelManager.CompilationOptions options)
Compile module(s) to the current program. Dependent modules will be removed if not included.

Parameters:
moduleNames - a list of the names of the changed modules.
definitionGroup - the definition group from which the module definitions may be retrieved.
logger - the logger to use during the compile.
options - - the values for compilation options
Returns:
the highest error condition experienced

addStatusListener

public void addStatusListener(StatusListener listener)
Parameters:
listener - StatusListener

removeStatusListener

public void removeStatusListener(StatusListener listener)
Parameters:
listener - StatusListener

resetCachedResults

public void resetCachedResults(ExecutionContext context)
Discarded any cached (memoized) results in this program.

Parameters:
context - the context with which the cached results are associated.

resetCachedResults

public void resetCachedResults(ModuleName moduleName,
                               ExecutionContext context)
Discard any cached (memoized) results in the named module and any dependent modules.

Parameters:
moduleName -
context - the context with which the cached results are associated.

resetMachineState

public void resetMachineState(ExecutionContext context)
Discarded the machine state, including any cached (memoized) results in this program.

Parameters:
context - the context with which the machine state is associated.

resetMachineState

public void resetMachineState(ModuleName moduleName,
                              ExecutionContext context)
Discard the machine state, including any cached (memoized) results in the named module and any dependent modules.

Parameters:
moduleName -
context - the context with which the machine state is associated.

removeModule

public final boolean removeModule(ModuleName moduleName)
Remove a module from the program. Its dependents will also be removed.

Parameters:
moduleName - the name of the module to remove.
Returns:
whether removing the module was successful.

getDependentModuleNames

public Set<ModuleName> getDependentModuleNames(ModuleName targetModule)
Parameters:
targetModule -
Returns:
the names of the dependent modules.

getModuleTypeInfo

public ModuleTypeInfo getModuleTypeInfo(ModuleName moduleName)
Parameters:
moduleName -
Returns:
type info for the named module. Null if module doesn't exist.

getModule

public org.openquark.cal.machine.Module getModule(ModuleName name)
Gets the module with a given moduleName.

Parameters:
name - the module name
Returns:
the module with a given module name

getModules

public List<org.openquark.cal.machine.Module> getModules()
Return a list of Module object for modules contained the ProgramManager instance encapsulated by this ProgramModleManager.

Returns:
a list of Module objects for the modules in this program.

hasModuleInProgram

public boolean hasModuleInProgram(ModuleName moduleName)
Returns true iff the specified module is in the Program instance encapsulated by this WorkspaceManager.

Parameters:
moduleName - the name of the module to check.
Returns:
true iff the specified module is in the program.

getModuleNamesInProgram

public ModuleName[] getModuleNamesInProgram()
Returns the names of the modules contained by the Program instance encapsulated by this WorkspaceManager.

Returns:
an array of module names for the modules in the program.

getNFunctionsInModule

public int getNFunctionsInModule(ModuleName moduleName)
Returns the number of functions in the specified module.

Parameters:
moduleName - the name of the module.
Returns:
the number of functions in the specified module, or 0 if the module is not in the program.

getMachineFunction

public org.openquark.cal.machine.MachineFunction getMachineFunction(QualifiedName functionName)
                                                             throws org.openquark.cal.machine.Program.ProgramException
Retrieves the specified machine function.

Parameters:
functionName - the qualified name of the function.
Returns:
the specified machine function, or null if it does not exist.
Throws:
org.openquark.cal.machine.Program.ProgramException - if the program does not contain the module for the function.

getMachineType

public MachineType getMachineType()
Returns the machine type associated with this WorkspaceManager.

Returns:
the machine type.

getMachineStatistics

public MachineStatistics getMachineStatistics()
Returns:
the machine statistics associated with this program.

getMachineStatisticsForModule

public MachineStatistics getMachineStatisticsForModule(ModuleName moduleName)
Parameters:
moduleName -
Returns:
the machine statistics associated with the given module.

Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

Copyright © 2007 Business Objects. All rights reserved.