24#ifndef PXR_BASE_TF_TYPE_IMPL_H
25#define PXR_BASE_TF_TYPE_IMPL_H
29PXR_NAMESPACE_OPEN_SCOPE
31template <
class DERIVED,
class BASE>
33Tf_CastToParent(
void* addr,
bool derivedToBase);
36template <
typename TypeVector>
39template <
typename... Bases>
40struct Tf_AddBases<
TfType::Bases<Bases...>>
44 static std::vector<TfType>
47 return std::vector<TfType> {
54 template <
typename Derived>
56 RegisterCasts(
TfType const* type)
58 (type->_AddCppCastFunc(
59 typeid(Bases), &Tf_CastToParent<Derived, Bases>), ...);
63template <
class T,
class BaseTypes>
68 std::vector<TfType> baseTfTypes = Tf_AddBases<BaseTypes>::Declare();
70 const std::type_info &typeInfo =
typeid(T);
75template <
typename T,
typename BaseTypes>
82 std::vector<TfType> baseTfTypes = Tf_AddBases<BaseTypes>::Declare();
85 const std::type_info &typeInfo =
typeid(T);
90 const bool isPodType = std::is_pod<T>::value;
91 const bool isEnumType = std::is_enum<T>::value;
94 newType._DefineCppType(typeInfo, sizeofType, isPodType, isEnumType);
95 Tf_AddBases<BaseTypes>::template RegisterCasts<T>(&newType);
104 return Define<T, Bases<> >();
109template <
class DERIVED,
class BASE>
111Tf_CastToParent(
void* addr,
bool derivedToBase)
115 DERIVED* derived =
reinterpret_cast<DERIVED*
>(addr);
116 BASE* base = derived;
120 BASE* base =
reinterpret_cast<BASE*
>(addr);
121 DERIVED* derived =
static_cast<DERIVED*
>(base);
126PXR_NAMESPACE_CLOSE_SCOPE
TfType represents a dynamic runtime type.
static TfType const & Define()
Define a TfType with the given C++ type T and C++ base types B.
static TfType const & Declare()
Declares a TfType with the given C++ type T and C++ base types Bases.
static TF_API std::string GetCanonicalTypeName(const std::type_info &)
Return the canonical typeName used for a given std::type_info.
Metafunction returning sizeof(T) for a type T (or 0 if T is a void type).