RslIter< T > Class Template Reference

An iterator is used to access grid data. More...

#include <RslPlugin.h>

List of all members.

Public Member Functions

 RslIter (const RslArg *arg)
 Construct an iterator from an argument.
 RslIter (const T *data, const RslContext *ctx)
 Construct a uniform iterator for user-provided data.
T & operator * ()
 Dereference this iterator, yielding a non-const reference.
const T & operator * () const
 Get a const reference to the data pointed to by this iterator.
RslIter< T > & operator++ ()
 Increment this iterator to point to the data for the next active point.
RslIter< T > operator++ (int)
 Post-increment this iterator.
bool IsVarying () const
 Returns true if the iterator is varying.
template<>
RslIter< RtMatrix > & operator++ ()


Detailed Description

template<typename T>
class RslIter< T >

An iterator is used to access grid data.

Incrementing an iterator skips over inactive grid points. An iterator is constructed from an RslArg and used as follows:

    RslFloatIter a(argv[0]);
    RslFloatIter b(argv[1]);
    RslFloatIter c(argv[2]);

    int n = argv[0]->NumValues();
    for (int i = 0; i < n; ++i) {
        *a = *b + *c;
        ++a; ++b; ++c;
    }

Run-time type assertions are recommended to guard against inadvert type errors:

    assert(argv[0].IsFloat());
This should be unnecessary because the shader compiler guarantees that the argument values match the parameter types specified in the plugin function prototype (in the RslFunctionTable). However, type assertions guard against inadvertent prototype errors, and they help catch errors in overloaded functions that can otherwise be difficult to diagnose.


Constructor & Destructor Documentation

template<typename T>
RslIter< T >::RslIter const RslArg arg  )  [inline]
 

Construct an iterator from an argument.

template<typename T>
RslIter< T >::RslIter const T *  data,
const RslContext ctx
[inline]
 

Construct a uniform iterator for user-provided data.

This is useful for optional arguments with default values.


Member Function Documentation

template<typename T>
bool RslIter< T >::IsVarying  )  const [inline]
 

Returns true if the iterator is varying.

Note that uniform iterators need not be incremented (although it does no harm).

template<typename T>
const T& RslIter< T >::operator *  )  const [inline]
 

Get a const reference to the data pointed to by this iterator.

This method is automatically selected by the compiler when appropriate.

template<typename T>
T& RslIter< T >::operator *  )  [inline]
 

Dereference this iterator, yielding a non-const reference.

This method is automatically selected when a dereferenced iterator is the target of an assignment, such as "*a = 0".

template<>
RslIter< RtMatrix > & RslIter< RtMatrix >::operator++  )  [inline]
 

template<typename T>
RslIter<T> RslIter< T >::operator++ int   )  [inline]
 

Post-increment this iterator.

Returns a copy of the iterator prior to incrementing, so it's not terribly efficient. The dummy integer argument is the standard C++ way of distinguishing between pre- and post-increment operators.

template<typename T>
RslIter<T>& RslIter< T >::operator++  )  [inline]
 

Increment this iterator to point to the data for the next active point.

An internal acceleration structure makes this a constant-time operation.


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