RslStruct Class Reference

RslStruct Class Reference

#include <RslPlugin.h>

Public Member Functions

 RslStruct (const RslArg *arg)
 Construct an RslStruct from an RslArg.
 
const char * GetName () const
 Get the type name.
 
unsigned int GetNumMembers () const
 Get the number of struct members.
 
const RslArgoperator[] (int i) const
 Returns an RslArg for the specified struct member.
 

Friends

class RslStructArray
 

Detailed Description

An RslStruct represents a struct value. See the "Structs in RSL" application note for more information.

An RslStruct is constructed from an RslArg. An RslStruct can be used like an array of RslArg, using an index operator to obtain the RslArg for each struct member. Each of those can in turn be used to construct an iterator to access the data. For example, a struct containing a float and a color can be used as follows:

RslArg* structArg = argv[1];
RslStruct structure(structArg);
const RslArg* floatArg = structure[0];
const RslArg* colorArg = structure[1];
RslFloatIter f(floatArg);
RslColorIter c(colorArg);

or more concisely,

RslStruct structure(argv[1]);
RslFloatIter f(structure[0]);
RslColorIter c(structure[1]);

Unless it is overloaded, a plugin function usually knows the types of its arguments. The shader compiler's typechecker ensures that its arguments always match its function prototype.

Nevertheless, it is sometimes useful to "introspect" a struct type. This is especially helpful for detecting "version skew", which might arise if a member is added to a struct definition without making corresponding modifications to plugins that depend upon it.

An RslStruct provides a GetName() method that returns the struct type name. The GetNumMembers() method returns the number of members. Information about the struct members is obtained from their RslArg objects using the usual type and detail queries (e.g. IsFloat(), IsStruct(), IsArray(), GetArrayLength(), IsVarying()). In addition, RslArg provides a GetName() method that returns the name of a struct member.


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