6#ifndef MATERIALX_GENCONTEXT_H
7#define MATERIALX_GENCONTEXT_H
53 _sourceCodeSearchPath.append(path);
59 _sourceCodeSearchPath.append(path);
65 return _sourceCodeSearchPath.find(filename);
72 _reservedWords.insert(names.begin(), names.end());
79 return _reservedWords;
90 void getNodeImplementationNames(
StringSet& names);
93 void clearNodeImplementations();
99 auto it = _userData.find(name);
100 if (it != _userData.end())
102 it->second.push_back(data);
106 _userData[name] = { data };
113 auto it = _userData.find(name);
114 if (it != _userData.end())
116 it->second.pop_back();
121 void clearUserData();
128 auto it = _userData.find(name);
129 return it != _userData.end() && !it->second.empty() ? it->second.back()->asA<T>() :
nullptr;
135 void addInputSuffix(
const ShaderInput* input,
const string& suffix);
144 void getInputSuffix(
const ShaderInput* input,
string& suffix)
const;
149 void addOutputSuffix(
const ShaderOutput* output,
const string& suffix);
158 void getOutputSuffix(
const ShaderOutput* output,
string& suffix)
const;
176 std::unordered_map<string, ShaderNodeImplPtr> _nodeImpls;
179 std::unordered_map<string, vector<GenUserDataPtr>> _userData;
182 std::unordered_map<const ShaderInput*, string> _inputSuffix;
185 std::unordered_map<const ShaderOutput*, string> _outputSuffix;
Cross-platform support for file and search paths.
Shader generation options class.
User data base class for shader generation.
std::shared_ptr< GenUserData > GenUserDataPtr
Shared pointer to a GenUserData.
Definition: GenUserData.h:20
std::set< string > StringSet
A set of strings.
Definition: Library.h:60
Macros for declaring imported and exported symbols.
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
shared_ptr< ShaderGenerator > ShaderGeneratorPtr
Shared pointer to a ShaderGenerator.
Definition: Library.h:38
Classes for nodes created during shader generation.
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:28
A sequence of file paths, which may be queried to find the first instance of a given filename on the ...
Definition: File.h:213
A context class for shader generation.
Definition: GenContext.h:27
void registerSourceCodeSearchPath(const FilePath &path)
Add to the search path used for finding source code.
Definition: GenContext.h:51
GenOptions & getOptions()
Return shader generation options.
Definition: GenContext.h:39
ShaderGenerator & getShaderGenerator()
Return shader generatior.
Definition: GenContext.h:33
void popUserData(const string &name)
Remove user data from the context.
Definition: GenContext.h:111
void addReservedWords(const StringSet &names)
Add reserved words that should not be used as identifiers during code generation.
Definition: GenContext.h:70
void pushUserData(const string &name, GenUserDataPtr data)
Add user data to the context to make it available during shader generator.
Definition: GenContext.h:97
FilePath resolveSourceFile(const FilePath &filename) const
Resolve a file using the registered search paths.
Definition: GenContext.h:63
void registerSourceCodeSearchPath(const FileSearchPath &path)
Add to the search path used for finding source code.
Definition: GenContext.h:57
const GenOptions & getOptions() const
Return shader generation options.
Definition: GenContext.h:45
std::shared_ptr< T > getUserData(const string &name)
Return user data with given name, or nullptr if no data is found.
Definition: GenContext.h:126
const StringSet & getReservedWords() const
Return the set of reserved words that should not be used as identifiers during code generation.
Definition: GenContext.h:77
Class holding options to configure shader generation.
Definition: GenOptions.h:65
Base class for shader generators All third-party shader generators should derive from this class.
Definition: ShaderGenerator.h:30
An output on a ShaderNode.
Definition: ShaderNode.h:289