Loading...
Searching...
No Matches
VdfReadWriteAccessor< T > Class Template Reference

VdfReadWriteAccessor allows for random access to output data. More...

#include <readWriteAccessor.h>

+ Inheritance diagram for VdfReadWriteAccessor< T >:

Public Member Functions

 VdfReadWriteAccessor (const VdfContext &context, const TfToken &name)
 Constructs a read/write accessor for the given input or output.
 
 VdfReadWriteAccessor (const VdfContext &context)
 Constructs a read/write accessor for the only output on the current node.
 
const T & operator[] (size_t index) const
 Provides constant random access to the data stored at the output.
 
T & operator[] (size_t index)
 Provides mutable random access to the data stored at the output.
 
bool IsEmpty () const
 Returns true if there is no data stored at the output.
 
size_t GetSize () const
 Returns the size of the data stored at the output.
 

Additional Inherited Members

- Protected Member Functions inherited from VdfIterator
 ~VdfIterator ()=default
 Disallow destruction via base class pointers.
 
const VdfNode_GetNode (const VdfContext &context) const
 Returns the current node being run.
 
const VdfExecutorInterface_GetExecutor (const VdfContext &context) const
 Returns the executor for the given context.
 
VDF_API const VdfVector_GetInputValue (const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
 Returns a vector for reading an input value.
 
VDF_API const VdfVector_GetRequiredInputValue (const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
 Returns the cached output value for a given output, or issues an error message if a cache value is not available.
 
VDF_API const VdfOutput_GetRequiredOutputForWriting (const VdfContext &context, const TfToken &name) const
 Returns the output for writing based on the name provided.
 
VDF_API VdfVector_GetOutputValueForWriting (const VdfContext &context, const VdfOutput &output) const
 Returns a vector for writing an output value into.
 
VDF_API bool _GetOutputMasks (const VdfContext &context, const VdfOutput &output, const VdfMask **requestMask, const VdfMask **affectsMask) const
 Retrieves the request and affects masks of the given output.
 
VDF_API bool _IsRequiredInput (const VdfContext &context, const VdfConnection &connection) const
 Returns true when the connection is scheduled and required, and false otherwise.
 
VDF_API const VdfMask_GetRequestMask (const VdfContext &context, const VdfOutput &output) const
 Returns the request mask of output, if the output has been scheduled and NULL otherwise.
 
VDF_API void _ForEachScheduledOutput (const VdfContext &context, const VdfNode &node, const VdfScheduledOutputCallback &callback) const
 Loops over each scheduled output of node and calls callback with the output and request mask in an efficient manner.
 

Detailed Description

template<typename T>
class VdfReadWriteAccessor< T >

VdfReadWriteAccessor allows for random access to output data.

The index into the data is in iteration space, i.e. access to index N returns the value of the N-th element as visited by the VdfReadWriteIterator.

Warning
Due to performance caveats described below, accessing values through an iterator (e.g. VdfReadWriteIterator) is preferred, if the data is accessed in a forward iterating pattern.

If the memory layout of the output values is not contiguous in the output buffer (e.g. a non-contiguous affects mask), the accessor will redirect access to the underlying data. This indirection can be costly. If the data is contiguous in memory, fast access will be provided through what is essentially access through pointer indirection / indexing of array elements.

Note that the memory layout of output buffers is an implementation detail of the system influenced by many factors. Subsequently, no assumptions can be made about whether access will take the fast- or the slow-path.

The only way to guarantee fast indirection is by accessing data through iterators (e.g. VdfReadWriteIterator). The use of iterators instead of using VdfReadWriteAccessor is strongly encouraged.

Definition at line 48 of file readWriteAccessor.h.

Constructor & Destructor Documentation

◆ VdfReadWriteAccessor() [1/2]

VdfReadWriteAccessor ( const VdfContext context,
const TfToken name 
)

Constructs a read/write accessor for the given input or output.

If no input with the specified name exists on the current node, or if the input does not have an associated output, attempt to find an output named name. Emits a coding error if name does not name an input or an output.

Definition at line 114 of file readWriteAccessor.h.

◆ VdfReadWriteAccessor() [2/2]

VdfReadWriteAccessor ( const VdfContext context)
inline

Constructs a read/write accessor for the only output on the current node.

If the node has more than a single output, a coding error will be emitted.

Definition at line 64 of file readWriteAccessor.h.

Member Function Documentation

◆ GetSize()

size_t GetSize ( ) const
inline

Returns the size of the data stored at the output.

Definition at line 90 of file readWriteAccessor.h.

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Returns true if there is no data stored at the output.

Definition at line 84 of file readWriteAccessor.h.

◆ operator[]() [1/2]

T & operator[] ( size_t  index)

Provides mutable random access to the data stored at the output.

Note that index must be within [0, GetSize()). Out of bounds access will lead to undefined behavior.

Definition at line 169 of file readWriteAccessor.h.

◆ operator[]() [2/2]

const T & operator[] ( size_t  index) const
inline

Provides constant random access to the data stored at the output.

Note that index must be within [0, GetSize()). Out of bounds access will lead to undefined behavior.

Definition at line 72 of file readWriteAccessor.h.


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