com.jogamp.opencl
Class CLProgramBuilder

java.lang.Object
  extended by com.jogamp.opencl.CLProgramBuilder
All Implemented Interfaces:
CLBuildConfiguration, CLProgramConfiguration, Serializable, Cloneable

public final class CLProgramBuilder
extends Object
implements CLProgramConfiguration, Serializable, Cloneable

CLProgramBuilder is a helper for building programs with more complex configurations or building multiple programs with similar configurations.

Author:
Michael Bien
See Also:
CLProgram.prepare(), createConfiguration(), createConfiguration(com.jogamp.opencl.CLProgram), loadConfiguration(java.io.ObjectInputStream), loadConfiguration(java.io.ObjectInputStream, com.jogamp.opencl.CLContext), Serialized Form

Method Summary
 CLProgramBuilder asBuildConfiguration()
          Returns a new instance of of this configuration without a CLProgram, program binaries or sources associated with it.
 CLProgram build()
          Builds or rebuilds a program.
 CLProgram build(CLBuildListener listener)
          Builds or rebuilds a program.
 CLProgram build(CLProgram program)
          Builds or rebuilds the program.
 CLProgram build(CLProgram program, CLBuildListener listener)
          Builds or rebuilds the program.
 CLProgramBuilder clone()
          Clones this configuration.
static CLBuildConfiguration createConfiguration()
          Creates a new CLBuildConfiguration.
static CLProgramConfiguration createConfiguration(CLProgram program)
          Creates a new CLProgramConfiguration for this program.
 boolean equals(Object o)
           
 CLProgramBuilder forDevice(CLDevice device)
          Adds the device as build target.
 CLProgramBuilder forDevices(CLDevice... devices)
          Adds the devices as build target.
 CLProgram getProgram()
          Returns the program.
 int hashCode()
           
static CLBuildConfiguration loadConfiguration(ObjectInputStream ois)
          Loads a CLBuildConfiguration.
static CLProgramConfiguration loadConfiguration(ObjectInputStream ois, CLContext context)
          Loads a CLProgramConfiguration containing a CLProgram.
 CLProgramBuilder reset()
          Resets this builder's configuration like options, devices and definitions.
 CLProgramConfiguration resetDefines()
          Resets this builder's macro definitions.
 CLProgramConfiguration resetDevices()
          Resets this builder's device list.
 CLProgramConfiguration resetOptions()
          Resets this builder's configuration options.
 void save(ObjectOutputStream oos)
          Saves this configuration to the ObjectOutputStream.
 CLProgramBuilder setProgram(CLProgram program)
          Sets the program which should be build.
 String toString()
           
 CLProgramBuilder withDefine(String name)
          Adds the definition to the build configuration.
 CLProgramBuilder withDefine(String name, Object value)
          Adds the definition to the build configuration.
 CLProgramBuilder withDefines(Map<String,? extends Object> defines)
          Adds the definitions to the build configuration.
 CLProgramBuilder withDefines(String... names)
          Adds the definitions to the build configuration.
 CLProgramBuilder withOption(String option)
          Adds the compiler option to the build configuration.
 CLProgramBuilder withOptions(String... options)
          Adds the compiler options to the build configuration.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createConfiguration

public static CLBuildConfiguration createConfiguration()
Creates a new CLBuildConfiguration.


createConfiguration

public static CLProgramConfiguration createConfiguration(CLProgram program)
Creates a new CLProgramConfiguration for this program.


loadConfiguration

public static CLBuildConfiguration loadConfiguration(ObjectInputStream ois)
                                              throws IOException,
                                                     ClassNotFoundException
Loads a CLBuildConfiguration.

Parameters:
ois - The ObjectInputStream for reading the object.
Throws:
IOException
ClassNotFoundException

loadConfiguration

public static CLProgramConfiguration loadConfiguration(ObjectInputStream ois,
                                                       CLContext context)
                                                throws IOException,
                                                       ClassNotFoundException
Loads a CLProgramConfiguration containing a CLProgram. The CLProgram is initialized and ready to be build after this method call. This method prefers program initialization from binaries if this fails or if no binaries have been found, it will try to load the program from sources. If This also fails an appropriate exception will be thrown.

Parameters:
ois - The ObjectInputStream for reading the object.
context - The context used for program initialization.
Throws:
IOException
ClassNotFoundException

save

public void save(ObjectOutputStream oos)
          throws IOException
Description copied from interface: CLBuildConfiguration
Saves this configuration to the ObjectOutputStream. The caller is responsible for closing the stream.

Specified by:
save in interface CLBuildConfiguration
Throws:
IOException

withOption

public CLProgramBuilder withOption(String option)
Description copied from interface: CLBuildConfiguration
Adds the compiler option to the build configuration.

Specified by:
withOption in interface CLBuildConfiguration
Specified by:
withOption in interface CLProgramConfiguration
See Also:
CLProgram.CompilerOptions

withOptions

public CLProgramBuilder withOptions(String... options)
Description copied from interface: CLBuildConfiguration
Adds the compiler options to the build configuration.

Specified by:
withOptions in interface CLBuildConfiguration
Specified by:
withOptions in interface CLProgramConfiguration
See Also:
CLProgram.CompilerOptions

withDefine

public CLProgramBuilder withDefine(String name)
Description copied from interface: CLBuildConfiguration
Adds the definition to the build configuration.

Specified by:
withDefine in interface CLBuildConfiguration
Specified by:
withDefine in interface CLProgramConfiguration
See Also:
CLProgram.define(java.lang.String)

withDefines

public CLProgramBuilder withDefines(String... names)
Description copied from interface: CLBuildConfiguration
Adds the definitions to the build configuration.

Specified by:
withDefines in interface CLBuildConfiguration
Specified by:
withDefines in interface CLProgramConfiguration
See Also:
CLProgram.define(java.lang.String)

withDefine

public CLProgramBuilder withDefine(String name,
                                   Object value)
Description copied from interface: CLBuildConfiguration
Adds the definition to the build configuration.

Specified by:
withDefine in interface CLBuildConfiguration
Specified by:
withDefine in interface CLProgramConfiguration
See Also:
CLProgram.define(java.lang.String, java.lang.Object)

withDefines

public CLProgramBuilder withDefines(Map<String,? extends Object> defines)
Description copied from interface: CLBuildConfiguration
Adds the definitions to the build configuration.

Specified by:
withDefines in interface CLBuildConfiguration
Specified by:
withDefines in interface CLProgramConfiguration
See Also:
CLProgram.define(java.lang.String, java.lang.Object)

forDevice

public CLProgramBuilder forDevice(CLDevice device)
Description copied from interface: CLBuildConfiguration
Adds the device as build target.

Specified by:
forDevice in interface CLBuildConfiguration
Specified by:
forDevice in interface CLProgramConfiguration

forDevices

public CLProgramBuilder forDevices(CLDevice... devices)
Description copied from interface: CLBuildConfiguration
Adds the devices as build target.

Specified by:
forDevices in interface CLBuildConfiguration
Specified by:
forDevices in interface CLProgramConfiguration

build

public CLProgram build()
Description copied from interface: CLProgramConfiguration
Builds or rebuilds a program.

Specified by:
build in interface CLProgramConfiguration

build

public CLProgram build(CLBuildListener listener)
Description copied from interface: CLProgramConfiguration
Builds or rebuilds a program.

Specified by:
build in interface CLProgramConfiguration
Parameters:
listener - The callback who will be notified when the program has built.

build

public CLProgram build(CLProgram program)
Description copied from interface: CLBuildConfiguration
Builds or rebuilds the program.

Specified by:
build in interface CLBuildConfiguration
Parameters:
program - The program which should be build.

build

public CLProgram build(CLProgram program,
                       CLBuildListener listener)
Description copied from interface: CLBuildConfiguration
Builds or rebuilds the program.

Specified by:
build in interface CLBuildConfiguration
Parameters:
program - The program which should be build.
listener - The callback who is notified when the program has built.

reset

public CLProgramBuilder reset()
Description copied from interface: CLBuildConfiguration
Resets this builder's configuration like options, devices and definitions.

Specified by:
reset in interface CLBuildConfiguration
Specified by:
reset in interface CLProgramConfiguration

resetDefines

public CLProgramConfiguration resetDefines()
Description copied from interface: CLBuildConfiguration
Resets this builder's macro definitions.

Specified by:
resetDefines in interface CLBuildConfiguration
Specified by:
resetDefines in interface CLProgramConfiguration

resetDevices

public CLProgramConfiguration resetDevices()
Description copied from interface: CLBuildConfiguration
Resets this builder's device list.

Specified by:
resetDevices in interface CLBuildConfiguration
Specified by:
resetDevices in interface CLProgramConfiguration

resetOptions

public CLProgramConfiguration resetOptions()
Description copied from interface: CLBuildConfiguration
Resets this builder's configuration options.

Specified by:
resetOptions in interface CLBuildConfiguration
Specified by:
resetOptions in interface CLProgramConfiguration

asBuildConfiguration

public CLProgramBuilder asBuildConfiguration()
Description copied from interface: CLProgramConfiguration
Returns a new instance of of this configuration without a CLProgram, program binaries or sources associated with it.

Specified by:
asBuildConfiguration in interface CLProgramConfiguration

clone

public CLProgramBuilder clone()
Description copied from interface: CLBuildConfiguration
Clones this configuration.

Specified by:
clone in interface CLBuildConfiguration
Specified by:
clone in interface CLProgramConfiguration
Overrides:
clone in class Object

getProgram

public CLProgram getProgram()
Description copied from interface: CLProgramConfiguration
Returns the program.

Specified by:
getProgram in interface CLProgramConfiguration

setProgram

public CLProgramBuilder setProgram(CLProgram program)
Description copied from interface: CLBuildConfiguration
Sets the program which should be build.

Specified by:
setProgram in interface CLBuildConfiguration

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object