24 #ifndef PXR_BASE_TF_TYPE_H
25 #define PXR_BASE_TF_TYPE_H
37 #include <type_traits>
43 #ifdef PXR_PYTHON_SUPPORT_ENABLED
45 #endif // PXR_PYTHON_SUPPORT_ENABLED
86 #ifdef PXR_PYTHON_SUPPORT_ENABLED
89 struct PyPolymorphicBase
92 TF_API virtual ~PyPolymorphicBase();
94 #endif // PXR_PYTHON_SUPPORT_ENABLED
99 template <
class ... Args>
152 template <
typename T>
154 return Find(
typeid(
T));
172 template <
typename T>
179 return _FindImpl(rawPtr);
187 return _FindByTypeid(t);
194 return _FindByTypeid(t);
234 template <
typename BASE>
240 #ifdef PXR_PYTHON_SUPPORT_ENABLED
246 #endif // PXR_PYTHON_SUPPORT_ENABLED
297 #ifdef PXR_PYTHON_SUPPORT_ENABLED
308 #endif // PXR_PYTHON_SUPPORT_ENABLED
379 template <
typename T>
380 bool IsA()
const {
return IsA(Find<T>()); }
395 return IsUnknown() ? NULL : &TfType::_info;
458 const std::vector<TfType> & bases,
466 template <
typename T,
typename BaseTypes = TfType::Bases<>>
479 template <
typename T,
typename B>
489 template <
typename T>
492 #ifdef PXR_PYTHON_SUPPORT_ENABLED
497 #endif // PXR_PYTHON_SUPPORT_ENABLED
504 template <
typename Base,
typename Derived>
556 const void* addr)
const {
578 const void* addr)
const {
591 void SetFactory(std::unique_ptr<FactoryBase> factory)
const;
598 SetFactory(std::unique_ptr<FactoryBase>(std::move(factory)));
620 SetFactory(std::unique_ptr<FactoryBase>(std::move(factory)));
643 FactoryBase* _GetFactory()
const;
645 #ifdef PXR_PYTHON_SUPPORT_ENABLED
647 static TfType const &_FindImplPyPolymorphic(PyPolymorphicBase
const *
ptr);
651 _FindImpl(PyPolymorphicBase
const *rawPtr) {
652 return _FindImplPyPolymorphic(rawPtr);
658 _FindImpl(
T const *rawPtr) {
660 if (
auto ptr = dynamic_cast<PyPolymorphicBase const *>(rawPtr)) {
661 return _FindImplPyPolymorphic(
ptr);
664 return Find(
typeid(*rawPtr));
668 return Find(
typeid(
T));
674 _FindImpl(
T const *rawPtr) {
675 return Find(
typeid(*rawPtr));
678 #endif // PXR_PYTHON_SUPPORT_ENABLED
681 bool _IsAImplNoLock(
TfType queryType)
const;
683 typedef void *(*_CastFunction)(
void *,
bool derivedToBase);
685 template <
typename TypeVector>
691 template <
class HashState>
694 h.Append(type._info);
702 void _AddBasesNoLock(
703 const std::vector<TfType> &bases,
704 std::vector<std::string> *errorToEmit)
const;
708 void _AddCppCastFunc(
709 const std::type_info &baseTypeInfo, _CastFunction)
const;
713 void _DefineCppType(
const std::type_info &,
716 bool isEnumType)
const;
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 GLchar *const * string
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)
const TfType & Factory(std::unique_ptr< T > &factory) const
**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
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()
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).
void SetFactory(std::unique_ptr< T > &factory) const
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.
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
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
const TfType & Factory(std::unique_ptr< FactoryBase > factory) const
static void AddAlias(const std::string &name)
const void * CastFromAncestor(TfType ancestor, const void *addr) const
TF_API const std::type_info & GetTypeid() 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.