Loading...
Searching...
No Matches
VdfContext Class Reference

A context is the parameter bundle passed to callbacks of computations. More...

#include <context.h>

Public Member Functions

 VdfContext (const VdfContext &rhs)=delete
 
VdfContextoperator= (const VdfContext &rhs)=delete
 
 VdfContext (const VdfEvaluationState &state, const VdfNode &node)
 Constructs a VdfContext for the given node with the current evaluation state.
 
 VdfContext (const VdfEvaluationState &state, const VdfNode &node, const VdfScheduleTaskIndex invocation)
 Constructs a VdfContext for the given node and node invocation with the current evaluation state.
 
template<typename T >
VdfByValueOrConstRef< T > GetInputValue (const TfToken &name) const
 Returns a value from the input named name of type T.
 
template<typename T >
const T * GetInputValuePtr (const TfToken &name) const
 Returns a pointer to the value from the input named name if the
input has a valid value, otherwise returns nullptr.
 
template<typename T >
const T * GetInputValuePtr (const TfToken &name, const T *defPtr) const
 Returns a pointer to the value from the input named name if the
input has a valid value, otherwise returns defPtr.
 
template<typename T >
bool HasInputValue (const TfToken &name) const
 Returns true, if there are input values from the input named name of type T.
 
VDF_API bool IsOutputRequested (const TfToken &outputName) const
 Returns true if the output named outputName is requested by at least one downstream node, or false if there are no consumers for the output or if outputName isn't a valid output on this node.
 
template<typename T >
void SetOutput (const TfToken &outputName, const T &value) const
 Sets the value of the output named outputName to value.
 
template<typename T >
void SetOutput (const T &value) const
 Sets the value of the output to value.
 
template<typename T >
void SetOutput (T &&value) const
 Sets the value of the output to value.
 
template<typename T >
void SetOutput (const TfToken &outputName, T &&value) const
 Sets the value of the output named outputName to value.
 
template<typename T >
void SetEmptyOutput () const
 Sets an empty value on the output.
 
template<typename T >
void SetEmptyOutput (const TfToken &outputName) const
 Sets an empty value on the output named outputName.
 
VDF_API void SetOutputToReferenceInput (const TfToken &inputName) const
 Sets the one and only output to have the same output value as the value on the output connected to input inputName.
 
Error Reporting
VDF_API void Warn (const char *fmt,...) const ARCH_PRINTF_FUNCTION(2
 Reports a warning to the system that was encountered at runtime.
 
Debugging
VDF_API std::string GetNodeDebugName () const
 Returns the debug name for the node for this context.
 
VDF_API void CodingError (const char *fmt,...) const ARCH_PRINTF_FUNCTION(2
 Invokes a coding error with an error message and a graph around the node that this context is currently referencing.
 

Friends

class VdfIterator
 
class VdfSpeculationNode
 

Detailed Description

A context is the parameter bundle passed to callbacks of computations.

It is the only API through which functions have access to their inputs.

Definition at line 39 of file context.h.

Constructor & Destructor Documentation

◆ VdfContext() [1/2]

VdfContext ( const VdfEvaluationState state,
const VdfNode node 
)
inline

Constructs a VdfContext for the given node with the current evaluation state.

Definition at line 50 of file context.h.

◆ VdfContext() [2/2]

VdfContext ( const VdfEvaluationState state,
const VdfNode node,
const VdfScheduleTaskIndex  invocation 
)
inline

Constructs a VdfContext for the given node and node invocation with the current evaluation state.

Definition at line 59 of file context.h.

Member Function Documentation

◆ CodingError()

VDF_API void CodingError ( const char *  fmt,
  ... 
) const

Invokes a coding error with an error message and a graph around the node that this context is currently referencing.

It takes a printf-style format specification.

◆ GetInputValue()

VdfByValueOrConstRef< T > GetInputValue ( const TfToken name) const
inline

Returns a value from the input named name of type T.


This method assumes that the caller expects only a single value to exist on its input.

Definition at line 300 of file context.h.

◆ GetInputValuePtr() [1/2]

const T * GetInputValuePtr ( const TfToken name) const
inline

Returns a pointer to the value from the input named name if the
input has a valid value, otherwise returns nullptr.

Definition at line 319 of file context.h.

◆ GetInputValuePtr() [2/2]

const T * GetInputValuePtr ( const TfToken name,
const T *  defPtr 
) const
inline

Returns a pointer to the value from the input named name if the
input has a valid value, otherwise returns defPtr.

Definition at line 326 of file context.h.

◆ GetNodeDebugName()

VDF_API std::string GetNodeDebugName ( ) const

Returns the debug name for the node for this context.

◆ HasInputValue()

bool HasInputValue ( const TfToken name) const
inline

Returns true, if there are input values from the input named name of type T.


Definition at line 334 of file context.h.

◆ IsOutputRequested()

VDF_API bool IsOutputRequested ( const TfToken outputName) const

Returns true if the output named outputName is requested by at least one downstream node, or false if there are no consumers for the output or if outputName isn't a valid output on this node.

This can be used by the node callback to avoid computing expensive outputs that are not needed.

NOTE: It's far preferred for computations to be designed with appropriate granularity, but this may be used in cases where the computation of multiple outputs isn't feasibly separable.

◆ SetEmptyOutput() [1/2]

void SetEmptyOutput
inline

Sets an empty value on the output.

It is invalid to call this method on any node that does not have exactly one output.

Definition at line 455 of file context.h.

◆ SetEmptyOutput() [2/2]

void SetEmptyOutput ( const TfToken outputName) const
inline

Sets an empty value on the output named outputName.

Definition at line 475 of file context.h.

◆ SetOutput() [1/4]

void SetOutput ( const T &  value) const
inline

Sets the value of the output to value.


This can be used when the node already has all the answers and doesn't want to bother with iterators.

Note that this method currently always performs a full copy, because it can't tell if we are allowed to take ownership of the given output.

It is invalid to call this method on any node that does not have exactly one output.

Definition at line 409 of file context.h.

◆ SetOutput() [2/4]

void SetOutput ( const TfToken outputName,
const T &  value 
) const
inline

Sets the value of the output named outputName to value.


This can be used when the node already has all the answers and doesn't want to bother with iterators.

Note that this method currently always performs a full copy, because it can't tell if we are allowed to take ownership of the given output.

Definition at line 394 of file context.h.

◆ SetOutput() [3/4]

void SetOutput ( const TfToken outputName,
T &&  value 
) const
inline

Sets the value of the output named outputName to value.


This can be used when the node already has all the answers and doesn't want to bother with iterators.

This method moves the data into the output, and thus avoids a copy. However, note that value will no longer contain any meaningful data after this method returned.

Definition at line 440 of file context.h.

◆ SetOutput() [4/4]

void SetOutput ( T &&  value) const
inline

Sets the value of the output to value.


This can be used when the node already has all the answers and doesn't want to bother with iterators.

This method moves the data into the output, and thus avoids a copy. However, note that value will no longer contain any meaningful data after this method returned.

It is invalid to call this method on any node that does not have exactly one output.

Definition at line 424 of file context.h.

◆ SetOutputToReferenceInput()

VDF_API void SetOutputToReferenceInput ( const TfToken inputName) const

Sets the one and only output to have the same output value as the value on the output connected to input inputName.

Calling this method when the input doesn't need to be modified gives the system an opportunity to apply some optimizations when possible.

Note that this optimization might not take effect in certain circumstances.

◆ Warn()

VDF_API void Warn ( const char *  fmt,
  ... 
) const

Reports a warning to the system that was encountered at runtime.

Exactly how the warning is presented to the user, if at all, is up to the host system.

Multiple calls to Warn() from the same node will cause the messages to be concatenated.

Friends And Related Function Documentation

◆ VdfIterator

friend class VdfIterator
friend

Definition at line 230 of file context.h.

◆ VdfSpeculationNode

friend class VdfSpeculationNode
friend

Definition at line 233 of file context.h.


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