25#ifndef PXR_BASE_TS_TYPE_REGISTRY_H
26#define PXR_BASE_TS_TYPE_REGISTRY_H
29#include "pxr/base/tf/api.h"
30#include "pxr/base/tf/hashmap.h"
33#include "pxr/base/ts/data.h"
35PXR_NAMESPACE_OPEN_SCOPE
62 Ts_PolymorphicDataHolder *holder,
71 _dataFactoryMap[TfType::Find<T>()] = factory;
78 Ts_PolymorphicDataHolder *holder,
96#define TS_REGISTER_TYPE(TYPE) \
97TF_REGISTRY_FUNCTION(TsTypeRegistry) { \
98 TsTypeRegistry ® = TsTypeRegistry::GetInstance(); \
99 reg.RegisterTypedDataFactory<TYPE>( \
100 [](Ts_PolymorphicDataHolder *holder, const VtValue &value) { \
101 holder->New(value.Get<TYPE>()); \
105PXR_NAMESPACE_CLOSE_SCOPE
Manage a single instance of an object (see.
static T & GetInstance()
Return a reference to an object of type T, creating it if necessary.
TfType represents a dynamic runtime type.
Type registry which provides a mapping from dynamically typed objects to statically typed internal on...
void(* TypedDataFactory)(Ts_PolymorphicDataHolder *holder, const VtValue &value)
A TypedDataFactory is a function which initializes an Ts_PolymorphicDataHolder instance for a given V...
static TS_API TsTypeRegistry & GetInstance()
Return the single instance of TsTypeRegistry.
TS_API void InitializeDataHolder(Ts_PolymorphicDataHolder *holder, const VtValue &value)
Initialize an Ts_PolymorphicDataHolder so that it holds an Ts_TypedData of the appropriate type with ...
TfHashMap< TfType, TypedDataFactory, TfHash > DataFactoryMap
Map from TfTypes to TypedDataFactories.
TS_API bool IsSupportedType(const TfType &type) const
Returns true if the type of value is a type we can make keyframes for.
void RegisterTypedDataFactory(TypedDataFactory factory)
Registers a TypedDataFactory for a particular type.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Manage a single instance of an object.