44 virtual bool isA(
const std::size_t
id)
const
54 template <
typename TType>
57 if (
isA(TType::getClassType()))
58 return static_cast<TType*
>(
this);
68 template <
typename TType>
69 const TType*
as()
const
71 if (
isA(TType::getClassType()))
72 return static_cast<const TType*
>(
this);
78 #define KSF_RTTI_DECLARATIONS(_Type, _ParentType) \
80 virtual const std::size_t getInstanceType() const \
82 return _Type::getClassType(); \
84 static const std::size_t getClassType() \
86 static int d{0}; return (std::size_t)&d; \
88 virtual bool isA(const std::size_t id) const \
90 if (id == getClassType()) \
93 return _ParentType::isA(id); \
Implements RTTI (run-time type information) for objects.
Definition ksRtti.h:26
virtual const std::size_t getInstanceType() const =0
Retrieves type ID of the object.
const TType * as() const
Tries to cast object to the type provided as a template parameter (const version).
Definition ksRtti.h:69
TType * as()
Tries to cast object to the type provided as a template parameter.
Definition ksRtti.h:55
virtual bool isA(const std::size_t id) const
Checks whether object is of given type.
Definition ksRtti.h:44
virtual ~ksRtti()=default
Destructor.