MaterialX 1.38.9
Loading...
Searching...
No Matches
VariableBlock Class Reference

A block of variables in a shader stage. More...

#include <ShaderStage.h>

Public Member Functions

 VariableBlock (const string &name, const string &instance)
 
const string & getName () const
 Get the name of this block.
 
void setName (const string &name)
 Set the name of this block.
 
const string & getInstance () const
 Get the instance name of this block.
 
void setInstance (const string &instance)
 Set the instance name of this block.
 
bool empty () const
 Return true if the block has no variables.
 
size_t size () const
 Return the number of variables in this block.
 
ShaderPortoperator[] (size_t index)
 Return a variable by index.
 
const ShaderPortoperator[] (size_t index) const
 Return a variable by index.
 
const vector< ShaderPort * > & getVariableOrder () const
 Return a const reference to our variable order vector.
 
ShaderPortoperator[] (const string &name)
 Return a variable by name. More...
 
const ShaderPortoperator[] (const string &name) const
 Return a variable by name. More...
 
ShaderPortfind (const string &name)
 Return a variable by name. More...
 
const ShaderPortfind (const string &name) const
 Return a variable by name. More...
 
ShaderPortfind (const ShaderPortPredicate &predicate)
 Find a port based on a predicate.
 
ShaderPortadd (const TypeDesc *type, const string &name, ValuePtr value=nullptr, bool shouldWiden=false)
 Add a new shader port to this block. More...
 
void add (ShaderPortPtr port)
 Add an existing shader port to this block.
 

Detailed Description

A block of variables in a shader stage.

Member Function Documentation

◆ add()

ShaderPort * add ( const TypeDesc type,
const string &  name,
ValuePtr  value = nullptr,
bool  shouldWiden = false 
)

Add a new shader port to this block.

Parameters
typeThe desired shader port type
nameThe shader port name
valueThe value to attach to the shader port
shouldWidenWhen false, an exception is thrown if the type of the existing port with the same name does not match the requested type. When true, the types can mismatch, and the type of any existing port is widened to match the requested type when necessary.
Returns
A new shader port, or a pre-existing shader port with the same name.

◆ find() [1/2]

ShaderPort * find ( const string &  name)

Return a variable by name.

Returns nullptr if no variable is found by the given name.

◆ find() [2/2]

const ShaderPort * find ( const string &  name) const

Return a variable by name.

Returns nullptr if no variable is found by the given name.

◆ operator[]() [1/2]

ShaderPort * operator[] ( const string &  name)

Return a variable by name.

Throws exception if no variable is found by the given name.

◆ operator[]() [2/2]

const ShaderPort * operator[] ( const string &  name) const

Return a variable by name.

Throws exception if no variable is found by the given name.


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