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"
24#include "pxr/base/tf/type.h"
28#include "pxr/base/vt/value.h"
30#include <tbb/concurrent_unordered_map.h>
36PXR_NAMESPACE_OPEN_SCOPE
38class Exec_ValueExtractor;
124 template <
typename ValueType>
135 template <
typename ValueType>
138 "Use ExecTypeRegistry::RegisterType<T>() to register execution "
166 template <
typename ValueType>
167 void _RegisterType(ValueType
const &fallback);
169 template <
typename T>
170 struct _CreateVector {
173 return Create(value.UncheckedGet<T>());
187 template <
typename T>
188 static auto _MakeExtractorFunction();
192 void _RegisterExtractor(
194 Exec_ValueExtractorFunction &extractor);
213 template <
typename T>
214 struct _IsPointerToNonConst : std::false_type {};
216 template <
typename T>
217 struct _IsPointerToNonConst<
std::shared_ptr<T>> :
218 std::negation<std::is_const<T>> {};
220 template <
typename T>
221 struct _IsPointerToNonConst<
TfRefPtr<T>> :
222 std::negation<std::is_const<T>> {};
242 tbb::concurrent_unordered_map<TfType, Exec_ValueExtractor, TfHash>
246template <
typename ValueType>
250 using T = std::decay_t<ValueType>;
252 std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>,
253 "Execution value types must be copyable.");
256 "Execution value types must support equality comparison.");
258 !std::is_pointer_v<T>,
259 "Raw pointers are not supported execution value types.");
261 !_IsPointerToNonConst<T>::value,
262 "Pointers to non-const data are not supported execution value "
266 "VtArray is not a supported execution value type.");
268 _GetInstanceForRegistration()._RegisterType(fallback);
271template <
typename ValueType>
273ExecTypeRegistry::_RegisterType(ValueType
const &fallback)
283 _RegisterExtractor(type, *+_MakeExtractorFunction<ValueType>());
288ExecTypeRegistry::_CreateVector<T>::Create(
const T &value)
296 using ElementType =
typename T::value_type;
298 const size_t size = value.size();
301 std::copy_n(value.cdata(), size, execValue.data());
304 v.
Set(std::move(execValue));
311ExecTypeRegistry::_MakeExtractorFunction()
326 const int offset = mask.GetFirstSet();
327 return VtValue(access[offset]);
332 using ElementType =
typename T::value_type;
334 if (!
TF_VERIFY(mask.AreContiguouslySet())) {
341 const int offset = mask.GetFirstSet();
342 const size_t numValues = access.
IsBoxed()
350PXR_NAMESPACE_CLOSE_SCOPE
Defines all the types "TYPED" for which Vt creates a VtTYPEDArray typedef.
constexpr bool VtIsKnownValueType()
Returns true if T is a type that appears in VT_VALUE_TYPES.
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 void RegisterType(const ValueType &fallback)
Registers ValueType as a type that exec computations can use for input and output values,...
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.
Fast, compressed bit array which is capable of performing logical operations without first decompress...
Reference-counted smart pointer utility class.
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 CheckForRegistration(const char *const additionalErrorMsg=nullptr)
Checks if T is defined as an execution value type.
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...
constexpr bool VdfIsEqualityComparable
Variable template that returns true if equality comparison is a valid operation for 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.