7#ifndef PXR_EXEC_EXEC_TYPE_REGISTRY_H
8#define PXR_EXEC_EXEC_TYPE_REGISTRY_H
14#include "pxr/exec/exec/api.h"
15#include "pxr/exec/exec/valueExtractorFunction.h"
22#include "pxr/base/tf/type.h"
26#include "pxr/base/vt/value.h"
28#include <tbb/concurrent_unordered_map.h>
32PXR_NAMESPACE_OPEN_SCOPE
34class Exec_ValueExtractor;
74 template <
typename ValueType>
78 "VtArray is not a supported execution value type.");
80 VdfIsEqualityComparable<ValueType>,
81 "Equality comparison is required for execution value types.");
82 _GetInstanceForRegistration()._RegisterType(fallback);
93 template <
typename ValueType>
95 return VdfExecutionTypeRegistry::CheckForRegistration<ValueType>();
122 template <
typename ValueType>
123 void _RegisterType(ValueType
const &fallback);
125 template <
typename T>
126 struct _CreateVector {
143 template <
typename T>
144 static auto _MakeExtractorFunction();
148 void _RegisterExtractor(
150 Exec_ValueExtractorFunction &extractor);
170 tbb::concurrent_unordered_map<TfType, Exec_ValueExtractor, TfHash>
174template <
typename ValueType>
176ExecTypeRegistry::_RegisterType(ValueType
const &fallback)
182 if constexpr (!VtIsKnownValueType<ValueType>()) {
186 _RegisterExtractor(type, *+_MakeExtractorFunction<ValueType>());
191ExecTypeRegistry::_CreateVector<T>::Create(
const T &value)
199 using ElementType =
typename T::value_type;
201 const size_t size = value.size();
204 std::copy_n(value.cdata(), size, execValue.data());
207 v.
Set(std::move(execValue));
214ExecTypeRegistry::_MakeExtractorFunction()
230 const int offset = mask.GetFirstSet();
231 return VtValue(access[offset]);
236 using ElementType =
typename T::value_type;
238 if (!
TF_VERIFY(mask.AreContiguouslySet())) {
245 const int offset = mask.GetFirstSet();
246 const size_t numValues = access.
IsBoxed()
254PXR_NAMESPACE_CLOSE_SCOPE
Defines all the types "TYPED" for which Vt creates a VtTYPEDArray typedef.
Singleton used to register and access value types used by exec computations.
EXEC_API VdfVector CreateVector(const VtValue &value) const
Construct a VdfVector whose value is copied from value.
TfType CheckForRegistration() const
Confirms that ValueType has been registered.
static EXEC_API const ExecTypeRegistry & GetInstance()
Provides access to the singleton instance, first ensuring it is constructed.
EXEC_API Exec_ValueExtractor GetExtractor(TfType type) const
Returns an extractor that produces a VtValue from values held in execution.
static void RegisterType(const ValueType &fallback)
Registers ValueType as a value type that exec computations can use for input and output values,...
Fast, compressed bit array which is capable of performing logical operations without first decompress...
Manage a single instance of an object (see.
TfType represents a dynamic runtime type.
This simple container stores multiple values that flow through the network as a single data flow elem...
static TfType Define(const T &fallback)
Registers T with execution's runtime type dispatch system.
A VdfMask is placed on connections to specify the data flowing through them.
Dispatches calls to template instantiations based on a TfType that is determined at runtime.
bool RegisterType()
Register an additional type with the type dispatch table.
A VdfTypedVector implements a VdfVector with a specific type.
A read-only accessor for low-level acces to the contents of the VdfVector.
bool IsBoxed() const
Returns true if this accessor is providing element-wise access into a boxed container.
bool IsEmpty() const
Returns true if the vector is empty.
size_t GetNumValues() const
Returns the size of the vector, i.e.
This class is used to abstract away knowledge of the cache data used for each node.
void Set(TYPE &&data)
Forwards data into the vector.
VtArray< T > ExtractAsVtArray(const size_t size, const int offset) const
Extracts this vector's values into a VtArray<T>.
ReadAccessor< TYPE > GetReadAccessor() const
GetReadAccessor() allows low level read-only access to the content of of the VdfVector via the Vdf_Ve...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Manage a single instance of an object.
A trait to detect instantiations of VtArray, specialized in array.h.