Loading...
Searching...
No Matches
ExecTypeRegistry Class Reference

Singleton used to register and access value types used by exec computations. More...

#include <typeRegistry.h>

Public Member Functions

 ExecTypeRegistry (ExecTypeRegistry const &)=delete
 
ExecTypeRegistryoperator= (ExecTypeRegistry const &)=delete
 
template<typename ValueType >
TfType CheckForRegistration () const
 Confirms that ValueType has been registered.
 
EXEC_API VdfVector CreateVector (const VtValue &value) const
 Construct a VdfVector whose value is copied from value.
 
EXEC_API Exec_ValueExtractor GetExtractor (TfType type) const
 Returns an extractor that produces a VtValue from values held in execution.
 

Static Public Member Functions

static EXEC_API const ExecTypeRegistryGetInstance ()
 Provides access to the singleton instance, first ensuring it is constructed.
 
template<typename ValueType >
static void RegisterType (const ValueType &fallback)
 Registers ValueType as a type that exec computations can use for input and output values, with the fallback value fallback.
 

Friends

class TfSingleton< ExecTypeRegistry >
 

Detailed Description

Singleton used to register and access value types used by exec computations.

Value types that are used for exec computation input and output values must be registered with this registry.

The registry is initialized with all value types that Sdf suports for attribute and metadata values.

Definition at line 49 of file typeRegistry.h.

Member Function Documentation

◆ CheckForRegistration()

template<typename ValueType >
TfType CheckForRegistration ( ) const
inline

Confirms that ValueType has been registered.

If ValueType has been registered with the ExecTypeRegistry, the corresponding TfType is returned.

Warning
If ValueType has not been registerd, a fatal error is emitted.

Definition at line 136 of file typeRegistry.h.

◆ CreateVector()

EXEC_API VdfVector CreateVector ( const VtValue & value) const

Construct a VdfVector whose value is copied from value.

◆ GetExtractor()

EXEC_API Exec_ValueExtractor GetExtractor ( TfType type) const

Returns an extractor that produces a VtValue from values held in execution.

Note that type is the type that should be held in the VtValue extraction result. This is distinct from the execution data-flow type.

◆ GetInstance()

static EXEC_API const ExecTypeRegistry & GetInstance ( )
static

Provides access to the singleton instance, first ensuring it is constructed.

◆ RegisterType()

template<typename ValueType >
void RegisterType ( const ValueType & fallback)
static

Registers ValueType as a type that exec computations can use for input and output values, with the fallback value fallback.

In any circumstance that requires an arbitrary value of type ValueType must be produced, fallback will be used.

All types that can be used to author attribute and metadata values in USD are available as exec value types by default. User-defined types must be registered using this function.

Warning
If a given ValueType is registered more than once, all calls must specify the same fallback; the equality operator for the type is used to verify that all fallback values have the same value.

Value Type Requirements

Values produced by computations will, in general, be copied, cached, and made available to computation callbacks that are evaluated in parallel. Therefore, care must be taken when choosing exec value types. Types that strictly obey value semantics are safe to use as exec value types and it is preferable to use such types whenever possible.

When computations produce large data that would be inefficient to copy, it is appealing to have the computation return a pointer. But many pointer types are not safe to use as exec value types: Parallel evalution makes it unsafe for computation callbacks to mutate pointed-to data. Additionally, doing so could modify data that is held in a cache, which would thwart the exec system's ability to correctly invalidate caches. Therefore, pointer types are generally unsafe to use, other than strong shared references to const data. In particular, std::shared_ptr<const T> and TfRefPtr<const T> are recommended for use as exec value types, when a pointer type is required. (Though using these types doesn't, of course, guaranty safety, since the pointed-to type could have const methods that mutate data, etc.)

Note
  • Exec value types must be copyable, as mentioned above.
  • Exec value types must also be equality comparable, e.g., so that we can compare fallback values to ensure that multiple registrations are consistent (as mentioned above).

Example

struct CustomType {
int i;
std::string s;
friend
bool operator==(const CustomType &a, const CustomType &b) {
return a.i == b.i && a.s == b.s;
}
};
{
}
Singleton used to register and access value types used by exec computations.
static void RegisterType(const ValueType &fallback)
Registers ValueType as a type that exec computations can use for input and output values,...
#define TF_REGISTRY_FUNCTION(KEY_TYPE)
Define a function that is called on demand by TfRegistryManager.

Definition at line 248 of file typeRegistry.h.

Friends And Related Symbol Documentation

◆ TfSingleton< ExecTypeRegistry >

friend class TfSingleton< ExecTypeRegistry >
friend

Definition at line 154 of file typeRegistry.h.


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