7 #ifndef PXR_BASE_TF_TYPE_H
8 #define PXR_BASE_TF_TYPE_H
20 #include <type_traits>
26 #ifdef PXR_PYTHON_SUPPORT_ENABLED
28 #endif // PXR_PYTHON_SUPPORT_ENABLED
69 #ifdef PXR_PYTHON_SUPPORT_ENABLED
72 struct PyPolymorphicBase
75 TF_API virtual ~PyPolymorphicBase();
77 #endif // PXR_PYTHON_SUPPORT_ENABLED
82 template <
class ... Args>
135 template <
typename T>
137 return Find(
typeid(
T));
155 template <
typename T>
162 return _FindImpl(rawPtr);
170 return _FindByTypeid(t);
177 return _FindByTypeid(t);
217 template <
typename BASE>
223 #ifdef PXR_PYTHON_SUPPORT_ENABLED
229 #endif // PXR_PYTHON_SUPPORT_ENABLED
283 #ifdef PXR_PYTHON_SUPPORT_ENABLED
294 #endif // PXR_PYTHON_SUPPORT_ENABLED
365 template <
typename T>
366 bool IsA()
const {
return IsA(Find<T>()); }
381 return IsUnknown() ? NULL : &TfType::_info;
425 Declare(
const std::string & typeName );
443 Declare(
const std::string & typeName,
444 const std::vector<TfType> & bases,
452 template <
typename T,
typename BaseTypes = TfType::Bases<>>
465 template <
typename T,
typename B>
475 template <
typename T>
478 #ifdef PXR_PYTHON_SUPPORT_ENABLED
483 #endif // PXR_PYTHON_SUPPORT_ENABLED
490 template <
typename Base,
typename Derived>
542 const void* addr)
const {
564 const void* addr)
const {
577 void SetFactory(std::unique_ptr<FactoryBase> &&factory)
const;
584 SetFactory(std::unique_ptr<FactoryBase>(std::move(factory)));
606 SetFactory(std::unique_ptr<FactoryBase>(std::move(factory)));
629 FactoryBase* _GetFactory()
const;
631 #ifdef PXR_PYTHON_SUPPORT_ENABLED
633 static TfType const &_FindImplPyPolymorphic(PyPolymorphicBase
const *
ptr);
637 _FindImpl(PyPolymorphicBase
const *rawPtr) {
638 return _FindImplPyPolymorphic(rawPtr);
644 _FindImpl(
T const *rawPtr) {
646 if (
auto ptr = dynamic_cast<PyPolymorphicBase const *>(rawPtr)) {
647 return _FindImplPyPolymorphic(
ptr);
650 return Find(
typeid(*rawPtr));
654 return Find(
typeid(
T));
660 _FindImpl(
T const *rawPtr) {
661 return Find(
typeid(*rawPtr));
664 #endif // PXR_PYTHON_SUPPORT_ENABLED
667 bool _IsAImplNoLock(
TfType queryType)
const;
669 typedef void *(*_CastFunction)(
void *,
bool derivedToBase);
671 template <
typename TypeVector>
677 template <
class HashState>
680 h.Append(type._info);
688 void _AddBasesNoLock(
689 const std::vector<TfType> &bases,
690 std::vector<std::string> *errorToEmit)
const;
694 void _AddCppCastFunc(
695 const std::type_info &baseTypeInfo, _CastFunction)
const;
699 void _DefineCppType(
const std::type_info &,
702 bool isEnumType)
const;
705 static TfType const &_DeclareImpl(
706 const std::type_info &thisTypeInfo,
707 const std::type_info **baseTypeInfos,
708 size_t numBaseTypes);
711 static TfType const &_DefineImpl(
712 const std::type_info &thisTypeInfo,
713 const std::type_info **baseTypeInfos,
714 _CastFunction *castFunctions,
716 size_t sizeofThisType,
bool isPod,
bool isEnum);
719 void _ExecuteDefinitionCallback()
const;
724 static TfType const& _FindByTypeid(
const std::type_info &);
736 template <
typename T>
762 #endif // PXR_BASE_TF_TYPE_H
bool operator<=(const TfType &t) const
static TF_API TfType const & GetUnknownType()
static TfType const & FindDerivedByName(const std::string &name)
GLsizei const GLfloat * value
static TF_API std::string GetCanonicalTypeName(const std::type_info &)
Manufacturable type (implies concrete)
static TfType const & Find()
static TfType const & FindByTypeid(const std::type_info &t)
**But if you need a result
TF_API std::vector< TfType > GetBaseTypes() const
TF_API void GetAllDerivedTypes(std::set< TfType > *result) const
TF_API TfType const & FindDerivedByName(const std::string &name) const
friend struct Tf_AddBases
static TfType const & Find(const std::type_info &t)
Base class of all factory types.
const void * CastToAncestor(TfType ancestor, const void *addr) const
friend void TfHashAppend(HashState &h, TfType const &type)
virtual TF_API ~FactoryBase()
static TfType const & Declare()
GLint GLint GLsizei GLint GLenum GLenum type
bool operator!=(const TfType &t) const
const TfType & Alias(TfType base, const std::string &name) const
const TfType & Factory() const
bool operator>(const TfType &t) const
static TfType const & Define()
static TF_API TfType const & FindByName(const std::string &name)
TF_API bool IsPlainOldDataType() const
TF_API void * CastToAncestor(TfType ancestor, void *addr) const
friend class Tf_TypeRegistry
TF_API std::vector< std::string > GetAliases(TfType derivedType) const
Metafunction returning sizeof(T) for a type T (or 0 if T is a void type).
GLuint const GLchar * name
TF_API size_t GetNBaseTypes(TfType *out, size_t maxBases) const
bool operator==(const TfType &t) const
GLboolean GLboolean GLboolean b
static TfType const & Find(const T &obj)
TF_API bool IsEnumType() const
bool operator>=(const TfType &t) const
TF_API TfType const & GetCanonicalType() const
Return the canonical type for this type.
const TfType & Factory(std::unique_ptr< FactoryBase > &&factory) const
GLfloat GLfloat GLfloat GLfloat h
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
TF_API size_t GetSizeof() const
TF_API void GetAllAncestorTypes(std::vector< TfType > *result) const
const TfType & Factory(std::unique_ptr< T > &&factory) const
void(*)(TfType) DefinitionCallback
Callback invoked when a declared type needs to be defined.
TF_API const std::string & GetTypeName() const
TfType::_TypeInfo *TfType::* UnspecifiedBoolType
TF_API void * CastFromAncestor(TfType ancestor, void *addr) const
#define PXR_NAMESPACE_CLOSE_SCOPE
static void AddAlias(const std::string &name)
const void * CastFromAncestor(TfType ancestor, const void *addr) const
TF_API const std::type_info & GetTypeid() const
void SetFactory(std::unique_ptr< T > &&factory) const
TF_API std::ostream & operator<<(std::ostream &out, const TfType &t)
Abstract (unmanufacturable and unclonable)
TF_API std::vector< TfType > GetDirectlyDerivedTypes() const
static TF_API TfType const & GetRoot()
bool operator<(const TfType &t) const
Comparison operator.