You.i Engine
CYIRuntimeTypeInfoTyped< CLASS, BASES > Class Template Referencefinal

Detailed Description

template<typename CLASS, typename... BASES>
class CYIRuntimeTypeInfoTyped< CLASS, BASES >

The runtime representation of a C++ type.

Instances of this class are used to represent a C++ type and manipulate that type at runtime. Unlike instances of CYIRuntimeTypeInfo, instances of this class contain extra information about the type hierarchy of the represented type.

Instances of this class can be accessed through the GetClassTypeInfo() functions of RTTI'ed classes.

Template Parameters
CLASSThe type associated with this object.
BASESThe bases of the type associated with this object. This template parameter is optional.

#include <utility/YiRtti.h>

Inheritance diagram for CYIRuntimeTypeInfoTyped< CLASS, BASES >:

Public Types

typedef CLASS ClassType
 
typedef std::tuple< BASES... > BaseTypes
 

Public Member Functions

 CYIRuntimeTypeInfoTyped (const char *pName)
 
bool CanCastToNonVirtual (const CYIRuntimeTypeInfo &baseType) const
 
template<typename T >
bool CanCastTo () const
 
template<typename T , typename... TBASES>
bool CanCastTo (const CYIRuntimeTypeInfoTyped< T, TBASES... > &baseType) const
 
std::unique_ptr< CLASS > CreateInstance () const
 
virtual bool CanCastTo (const CYIRuntimeTypeInfo &baseType) const override
 
virtual const std::vector< const CYIRuntimeTypeInfo * > & GetBasesTypeInfos () const override
 
const void * CastVoidToVoidNonVirtual (const CYIRuntimeTypeInfo &baseType, const void *pObject) const
 
virtual bool IsInstantiable () const override
 
- Public Member Functions inherited from CYIRuntimeTypeInfo
virtual ~CYIRuntimeTypeInfo ()
 
template<typename T >
std::unique_ptr< T > CreateInstance () const
 
template<typename T >
bool CanCastTo () const
 
CYIString GetName () const
 
CYIStringView GetNameAsView () const
 
void RegisterWithLinker () const
 
template<typename T >
const T * CastVoidPointer (const void *pObject) const
 
bool operator== (const CYIRuntimeTypeInfo &other) const
 
bool operator!= (const CYIRuntimeTypeInfo &other) const
 
bool operator< (const CYIRuntimeTypeInfo &other) const
 

Additional Inherited Members

- Protected Member Functions inherited from CYIRuntimeTypeInfo
 CYIRuntimeTypeInfo (CYIStringView name)
 

Member Typedef Documentation

◆ BaseTypes

template<typename CLASS, typename... BASES>
typedef std::tuple<BASES...> CYIRuntimeTypeInfoTyped< CLASS, BASES >::BaseTypes

The base types of CLASS.

To access the type of the nth base, use std::tuple_element. For example:

typename std::tuple_element<0, MyClass::BaseTypes>::type baseInstance;

◆ ClassType

template<typename CLASS, typename... BASES>
typedef CLASS CYIRuntimeTypeInfoTyped< CLASS, BASES >::ClassType

The class type.

Constructor & Destructor Documentation

◆ CYIRuntimeTypeInfoTyped()

template<typename CLASS, typename... BASES>
CYIRuntimeTypeInfoTyped< CLASS, BASES >::CYIRuntimeTypeInfoTyped ( const char *  pName)
explicit

Creates an instance of a runtime type info object.

Note
This constructor should not be called directly. Instead, type info objects should be accessed through the GetRuntimeTypeInfo() and GetClassTypeInfo() functions of a class with RTTI.
Warning
This class does not make a copy of pName, and so care must be taken to ensure that the character array pointed-to by pName remains valid for as long as this object remains valid.

Member Function Documentation

◆ CanCastTo() [1/3]

template<typename CLASS, typename... BASES>
template<typename T >
bool CYIRuntimeTypeInfoTyped< CLASS, BASES >::CanCastTo ( ) const
inline

Checks if the type represented by this object can be cast to type T. In other words, this function checks if type T is a base of this object's type.

Note
Unlike CYIRuntimeTypeInfo::CanCastTo<T>(), this function runs in constant time (using compile-time type information).
CV qualifiers of type T are ignored.
Template Parameters
TThe type to check against.
See also
CYIRuntimeTypeInfo::CanCastTo<T>()

◆ CanCastTo() [2/3]

template<typename CLASS, typename... BASES>
template<typename T , typename... TBASES>
bool CYIRuntimeTypeInfoTyped< CLASS, BASES >::CanCastTo ( const CYIRuntimeTypeInfoTyped< T, TBASES... > &  baseType) const
inline

Checks if the type represented by this object can be cast to the type represented by baseType. In other words, this function checks if baseType represents a base of this object's type.

Note
Unlike CYIRuntimeTypeInfo::CanCastTo(const CYIRuntimeTypeInfo &), this function runs in constant time (using compile-time type information).

◆ CanCastTo() [3/3]

template<typename CLASS, typename... BASES>
virtual bool CYIRuntimeTypeInfoTyped< CLASS, BASES >::CanCastTo ( const CYIRuntimeTypeInfo baseType) const
overridevirtual

Checks if the type represented by this object can be cast to the type represented by baseType. In other words, this function checks if baseType represents a base of this object's type.

Implements CYIRuntimeTypeInfo.

◆ CanCastToNonVirtual()

template<typename CLASS, typename... BASES>
bool CYIRuntimeTypeInfoTyped< CLASS, BASES >::CanCastToNonVirtual ( const CYIRuntimeTypeInfo baseType) const
inline

Checks if the type represented by this object can be cast to the type represented by baseType. In other words, this function checks if baseType represents a base of this object's type.

Note
Unlike CYIRuntimeTypeInfo::CanCastTo(const CYIRuntimeTypeInfo &), this function does not make virtual calls.

◆ CastVoidToVoidNonVirtual()

template<typename CLASS, typename... BASES>
const void* CYIRuntimeTypeInfoTyped< CLASS, BASES >::CastVoidToVoidNonVirtual ( const CYIRuntimeTypeInfo baseType,
const void *  pObject 
) const
inline

◆ CreateInstance()

template<typename CLASS, typename... BASES>
std::unique_ptr<CLASS> CYIRuntimeTypeInfoTyped< CLASS, BASES >::CreateInstance ( ) const
inline

Creates and returns a new instance of the type represented by this object using the type's default constructor.

Note
If the type represented by this object is not instantiable, a warning is logged and nullptr is returned.

◆ GetBasesTypeInfos()

template<typename CLASS, typename... BASES>
virtual const std::vector<const CYIRuntimeTypeInfo *>& CYIRuntimeTypeInfoTyped< CLASS, BASES >::GetBasesTypeInfos ( ) const
overridevirtual

Returns a vector containing pointers to the CYIRuntimeTypeInfo objects representing the bases of the type reprensented by this object. If the type represented by this object has no RTTI bases, an empty vector is returned.

Implements CYIRuntimeTypeInfo.

◆ IsInstantiable()

template<typename CLASS, typename... BASES>
virtual bool CYIRuntimeTypeInfoTyped< CLASS, BASES >::IsInstantiable ( ) const
overridevirtual

Returns true if the type represented by this object can be instantiated using CreateInstance().

Implements CYIRuntimeTypeInfo.


The documentation for this class was generated from the following file: