HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenContext Class Reference

#include <GenContext.h>

Public Member Functions

 GenContext (ShaderGeneratorPtr sg)
 Constructor. More...
 
ShaderGeneratorgetShaderGenerator ()
 Return shader generatior. More...
 
GenOptionsgetOptions ()
 Return shader generation options. More...
 
const GenOptionsgetOptions () const
 Return shader generation options. More...
 
void registerSourceCodeSearchPath (const FilePath &path)
 
void registerSourceCodeSearchPath (const FileSearchPath &path)
 
FilePath resolveSourceFile (const FilePath &filename, const FilePath &localPath) const
 
void addReservedWords (const StringSet &names)
 
const StringSetgetReservedWords () const
 
void addNodeImplementation (const string &name, ShaderNodeImplPtr impl)
 Cache a shader node implementation. More...
 
ShaderNodeImplPtr findNodeImplementation (const string &name) const
 
void getNodeImplementationNames (StringSet &names)
 Get the names of all cached node implementations. More...
 
void clearNodeImplementations ()
 Clear all cached shader node implementation. More...
 
void pushClosureContext (ClosureContext *cct)
 Push a new closure context to use for closure evaluation. More...
 
void popClosureContext ()
 Pop the current closure context. More...
 
ClosureContextgetClosureContext ()
 Return the current closure context. More...
 
void pushParentNode (ConstNodePtr node)
 Push a parent node onto the stack. More...
 
void popParentNode ()
 Pop the current parent node from the stack. More...
 
const vector< ConstNodePtr > & getParentNodes ()
 Return the current stack of parent nodes. More...
 
void pushUserData (const string &name, GenUserDataPtr data)
 
void popUserData (const string &name)
 Remove user data from the context. More...
 
void clearUserData ()
 Clear all user data from the context. More...
 
template<class T >
std::shared_ptr< TgetUserData (const string &name)
 
void addInputSuffix (const ShaderInput *input, const string &suffix)
 
void removeInputSuffix (const ShaderInput *input)
 
void getInputSuffix (const ShaderInput *input, string &suffix) const
 
void addOutputSuffix (const ShaderOutput *output, const string &suffix)
 
void removeOutputSuffix (const ShaderOutput *output)
 
void getOutputSuffix (const ShaderOutput *output, string &suffix) const
 
void setApplicationVariableHandler (ApplicationVariableHandler handler)
 Set handler for application variables. More...
 
ApplicationVariableHandler getApplicationVariableHandler () const
 Get handler for application variables. More...
 

Protected Member Functions

 GenContext ()=delete
 

Protected Attributes

ShaderGeneratorPtr _sg
 
GenOptions _options
 
FileSearchPath _sourceCodeSearchPath
 
StringSet _reservedWords
 
std::unordered_map< string,
ShaderNodeImplPtr
_nodeImpls
 
std::unordered_map< string,
vector< GenUserDataPtr > > 
_userData
 
std::unordered_map< const
ShaderInput *, string
_inputSuffix
 
std::unordered_map< const
ShaderOutput *, string
_outputSuffix
 
vector< ClosureContext * > _closureContexts
 
vector< ConstNodePtr_parentNodes
 
ApplicationVariableHandler _applicationVariableHandler
 

Detailed Description

A context class for shader generation. Used for thread local storage of data needed during shader generation.

Definition at line 30 of file GenContext.h.

Constructor & Destructor Documentation

GenContext::GenContext ( ShaderGeneratorPtr  sg)

Constructor.

GenContext::GenContext ( )
protecteddelete

Member Function Documentation

void GenContext::addInputSuffix ( const ShaderInput input,
const string suffix 
)

Add an input suffix to be used for the input in this context.

Parameters
inputNode input
suffixSuffix string
void GenContext::addNodeImplementation ( const string name,
ShaderNodeImplPtr  impl 
)

Cache a shader node implementation.

void GenContext::addOutputSuffix ( const ShaderOutput output,
const string suffix 
)

Add an output suffix to be used for the output in this context.

Parameters
outputNode output
suffixSuffix string
void GenContext::addReservedWords ( const StringSet names)
inline

Add reserved words that should not be used as identifiers during code generation.

Definition at line 82 of file GenContext.h.

void GenContext::clearNodeImplementations ( )

Clear all cached shader node implementation.

void GenContext::clearUserData ( )

Clear all user data from the context.

ShaderNodeImplPtr GenContext::findNodeImplementation ( const string name) const

Find and return a cached shader node implementation, or return nullptr if no implementation is found.

ApplicationVariableHandler GenContext::getApplicationVariableHandler ( ) const
inline

Get handler for application variables.

Definition at line 218 of file GenContext.h.

ClosureContext* GenContext::getClosureContext ( )
inline

Return the current closure context.

Definition at line 123 of file GenContext.h.

void GenContext::getInputSuffix ( const ShaderInput input,
string suffix 
) const

Get an input suffix to be used for the input in this context.

Parameters
inputNode input
suffixSuffix string returned. Is empty if not found.
void GenContext::getNodeImplementationNames ( StringSet names)

Get the names of all cached node implementations.

GenOptions& GenContext::getOptions ( )
inline

Return shader generation options.

Definition at line 43 of file GenContext.h.

const GenOptions& GenContext::getOptions ( ) const
inline

Return shader generation options.

Definition at line 49 of file GenContext.h.

void GenContext::getOutputSuffix ( const ShaderOutput output,
string suffix 
) const

Get an output suffix to be used for the output in this context.

Parameters
outputNode output
suffixSuffix string returned. Is empty if not found.
const vector<ConstNodePtr>& GenContext::getParentNodes ( )
inline

Return the current stack of parent nodes.

Definition at line 141 of file GenContext.h.

const StringSet& GenContext::getReservedWords ( ) const
inline

Return the set of reserved words that should not be used as identifiers during code generation.

Definition at line 89 of file GenContext.h.

ShaderGenerator& GenContext::getShaderGenerator ( )
inline

Return shader generatior.

Definition at line 37 of file GenContext.h.

template<class T >
std::shared_ptr<T> GenContext::getUserData ( const string name)
inline

Return user data with given name, or nullptr if no data is found.

Definition at line 177 of file GenContext.h.

void GenContext::popClosureContext ( )
inline

Pop the current closure context.

Definition at line 114 of file GenContext.h.

void GenContext::popParentNode ( )
inline

Pop the current parent node from the stack.

Definition at line 135 of file GenContext.h.

void GenContext::popUserData ( const string name)
inline

Remove user data from the context.

Definition at line 162 of file GenContext.h.

void GenContext::pushClosureContext ( ClosureContext cct)
inline

Push a new closure context to use for closure evaluation.

Definition at line 108 of file GenContext.h.

void GenContext::pushParentNode ( ConstNodePtr  node)
inline

Push a parent node onto the stack.

Definition at line 129 of file GenContext.h.

void GenContext::pushUserData ( const string name,
GenUserDataPtr  data 
)
inline

Add user data to the context to make it available during shader generator.

Definition at line 148 of file GenContext.h.

void GenContext::registerSourceCodeSearchPath ( const FilePath path)
inline

Register a user search path for finding source code during code generation.

Definition at line 56 of file GenContext.h.

void GenContext::registerSourceCodeSearchPath ( const FileSearchPath path)
inline

Register a user search path for finding source code during code generation.

Definition at line 63 of file GenContext.h.

void GenContext::removeInputSuffix ( const ShaderInput input)

Remove an input suffix to be used for the input in this context.

Parameters
inputNode input
void GenContext::removeOutputSuffix ( const ShaderOutput output)

Remove an output suffix to be used for the output in this context.

Parameters
outputNode output
FilePath GenContext::resolveSourceFile ( const FilePath filename,
const FilePath localPath 
) const
inline

Resolve a source code filename, first checking the given local path then checking any file paths registered by the user.

Definition at line 70 of file GenContext.h.

void GenContext::setApplicationVariableHandler ( ApplicationVariableHandler  handler)
inline

Set handler for application variables.

Definition at line 212 of file GenContext.h.

Member Data Documentation

ApplicationVariableHandler GenContext::_applicationVariableHandler
protected

Definition at line 239 of file GenContext.h.

vector<ClosureContext*> GenContext::_closureContexts
protected

Definition at line 236 of file GenContext.h.

std::unordered_map<const ShaderInput*, string> GenContext::_inputSuffix
protected

Definition at line 233 of file GenContext.h.

std::unordered_map<string, ShaderNodeImplPtr> GenContext::_nodeImpls
protected

Definition at line 231 of file GenContext.h.

GenOptions GenContext::_options
protected

Definition at line 227 of file GenContext.h.

std::unordered_map<const ShaderOutput*, string> GenContext::_outputSuffix
protected

Definition at line 234 of file GenContext.h.

vector<ConstNodePtr> GenContext::_parentNodes
protected

Definition at line 237 of file GenContext.h.

StringSet GenContext::_reservedWords
protected

Definition at line 229 of file GenContext.h.

ShaderGeneratorPtr GenContext::_sg
protected

Definition at line 226 of file GenContext.h.

FileSearchPath GenContext::_sourceCodeSearchPath
protected

Definition at line 228 of file GenContext.h.

std::unordered_map<string, vector<GenUserDataPtr> > GenContext::_userData
protected

Definition at line 232 of file GenContext.h.


The documentation for this class was generated from the following file: