HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VdfInputValuesPointer< T > Class Template Reference

#include <inputValuesPointer.h>

+ Inheritance diagram for VdfInputValuesPointer< T >:

Public Member Functions

 VdfInputValuesPointer (const VdfContext &context, const TfToken &inputName)
 
 ~VdfInputValuesPointer ()
 
const TGetData () const
 
size_t GetSize () const
 
 operator TfSpan< const T > () const
 

Additional Inherited Members

- Protected Member Functions inherited from VdfIterator
 ~VdfIterator ()=default
 
const VdfNode_GetNode (const VdfContext &context) const
 
const VdfExecutorInterface_GetExecutor (const VdfContext &context) const
 
VDF_API const VdfVector_GetInputValue (const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
 
VDF_API const VdfVector_GetRequiredInputValue (const VdfContext &context, const VdfConnection &connection, const VdfMask &mask) const
 
VDF_API const VdfOutput_GetRequiredOutputForWriting (const VdfContext &context, const TfToken &name) const
 
VDF_API VdfVector_GetOutputValueForWriting (const VdfContext &context, const VdfOutput &output) const
 
VDF_API bool _GetOutputMasks (const VdfContext &context, const VdfOutput &output, const VdfMask **requestMask, const VdfMask **affectsMask) const
 
VDF_API bool _IsRequiredInput (const VdfContext &context, const VdfConnection &connection) const
 
VDF_API const VdfMask_GetRequestMask (const VdfContext &context, const VdfOutput &output) const
 
VDF_API void _ForEachScheduledOutput (const VdfContext &context, const VdfNode &node, const VdfScheduledOutputCallback &callback) const
 

Detailed Description

template<typename T>
class VdfInputValuesPointer< T >

VdfInputValuesPointer is a smart pointer object that guarantees contiguous memory access to the requested input values, regardless of the actual memory layout in the output buffers.

Warning
Due to performance caveats described below, accessing values through an iterator (e.g. VdfReadIterator) or the VdfContext is generally a better choice.

If the memory layout of input values is not contiguous in the output buffers, this class will make a copy of the input values in order to satisfy the contiguous access guarantees. Note that it can be expensive to make this copy. If necessary, the copy will be produced at time of construction.

If the memory layout of input values is already contiguous in the output buffers, this class will provide contiguous access into those buffers without making any copies.

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 copies will be made or not.

The only way to guarantee that no copies will be made is by accessing data through iterators (e.g. VdfReadIterator) or the VdfContext (e.g. VdfContext::GetInputValue). The use of iterators or the VdfContext instead of using VdfInputValuesPointer is strongly encouraged. When calling into functions, a good pattern is to parameterize said functions with iterator ranges, rather than raw pointers or specific container types.

```{.cpp} template < Iterator > MyFunction(Iterator begin, Iterator end) { for (Iterator it = begin; it != end; ++it) { ... } } ```

When using iterator ranges is not possible, for example when calling into functions from a third party library, VdfInputValuesPointer may be used to satisfy the required contiguous memory access guarantees.

```{.cpp} VdfInputValuesPointer<GfVec3d> points(context, _tokens->points); ThirdPartyFunction(points.GetData(), points.GetSize(), ...); ```

Definition at line 76 of file inputValuesPointer.h.

Constructor & Destructor Documentation

template<typename T >
VdfInputValuesPointer< T >::VdfInputValuesPointer ( const VdfContext context,
const TfToken inputName 
)

Construct a new instance of this class with access to the input values provided by the input named inputName. If the data provided by inputName is not contiguous in memory, the constructor will make a copy of the input values.

Definition at line 138 of file inputValuesPointer.h.

template<typename T >
VdfInputValuesPointer< T >::~VdfInputValuesPointer ( )

Destructor.

Definition at line 217 of file inputValuesPointer.h.

Member Function Documentation

template<typename T >
const T* VdfInputValuesPointer< T >::GetData ( ) const
inline

Returns an immutable raw pointer to the data. Accessing data outside the bounds established by GetSize() is invalid and will lead to undefined behavior.

Definition at line 95 of file inputValuesPointer.h.

template<typename T >
size_t VdfInputValuesPointer< T >::GetSize ( ) const
inline

Returns the size of the data in number of elements stored.

Definition at line 101 of file inputValuesPointer.h.

template<typename T >
VdfInputValuesPointer< T >::operator TfSpan< const T > ( ) const
inline

Construct a read-only TfSpan viewing this object's data. This enables the use of VdfInputValuesPointer with template methods that require STL container API. This user-defined conversion is necessary because the API on this class is incompatible with the STL requirements of the implicit container-conversion constructor on TfSpan.

Definition at line 111 of file inputValuesPointer.h.


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