Workspace 6.21.5
Public Member Functions | Static Public Member Functions | List of all members
ShaderImplementationFactoryTraits< T > Class Template Reference

Traits class for shaderimpls of type T. More...

#include <Rendering/SceneComponents/Shaders/shaderimplementationfactorytraits.h>

Public Member Functions

CSIRO_EXPORTSPEC WSGLBlinnPhongShaderImplementationcreate (Shader &shader)
 
CSIRO_EXPORTSPEC const ShaderImplementationFactorygetInstance ()
 

Static Public Member Functions

static T * create (Shader &shader)
 
static void destroy (T *op)
 
static const ShaderImplementationFactorygetInstance ()
 
static const Application::WorkspacePlugingetPlugin ()
 
static const SceneRendererTypeIdgetSceneRendererTypeId ()
 
static QString getType ()
 

Detailed Description

template<typename T>
class CSIRO::Rendering::ShaderImplementationFactoryTraits< T >

In order to ensure that shaderimpl factories used across plugins are portable (ie will work on all platforms), there are cases where the code must prevent the compiler from having the chance to inline certain functions. In particular, the TypedShaderImplementationFactory template implements some memory allocation and deallocation, and this must not be allowed to get inlined or else memory could be allocated in one module and deallocated in another, and that is not portable. Therefore, the ShaderImplementationFactoryTraits class provides an interface to the TypedShaderImplementationFactory functions but in a way that hides its implementation. The factory is ultimately instantiated by the DEFINE_SHADER_IMPL_FACTORY macro and the client code instantiates the ShaderImplementationFactoryTraits class whenever it is needed. The macro defines the functions that are only declared in the ShaderImplementationFactoryTraits class, and by only using the macro in an implementation file and never a header, the two classes are effectively decoupled and client code never sees the implementation of TypedShaderImplementationFactory.

Member Function Documentation

◆ create() [1/2]

◆ create() [2/2]

static T * create ( Shader shader)
static
Returns
A new dynamically allocated shaderimpl of type T.

Conceptually similar to the C++ new operator.

See also
TypedShaderImplementationFactory::create()

◆ destroy()

static void destroy ( T *  op)
inlinestatic
Parameters
opA shaderimpl assumed to be of type T that is also assumed to have been created by a call to create().

Deletes op. Conceptually similar to the C++ delete operator.

See also
TypedShaderImplementationFactory::destroy()

◆ getInstance() [1/2]

◆ getInstance() [2/2]

static const ShaderImplementationFactory & getInstance ( )
static
Returns
The factory responsible for shaderimpls of type T.

◆ getPlugin()

static const Application::WorkspacePlugin & getPlugin ( )
inlinestatic
Returns
The plugin that provides the factory for impls of type T.
See also
ShaderImplementationFactory::getPlugin()

◆ getSceneRendererTypeId()

static const SceneRendererTypeId & getSceneRendererTypeId ( )
inlinestatic
Returns
The type of renderer associated with this shader type.
See also
ShaderImplementationFactory::getSceneRendererType()

◆ getType()

static QString getType ( )
inlinestatic
Returns
The type name that shader impls of type T are known by in a workspace.
See also
ShaderImplementationFactory::getType()