KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::TIsDerivedFrom< DerivedType, BaseType > Struct Template Reference

Is type DerivedType inherited from BaseType? More...

#include <SubClassOf.h>

Public Types

typedef char No[1]
 
typedef char Yes[2]
 

Static Public Member Functions

static YesTest (BaseType *)
 Handy function called when type-cast succeeds.
 
static YesTest (const BaseType *)
 Handy variant function called when type-cast succeeds.
 
static NoTest (...)
 Handy function called when type-cast does not succeed.
 
static DerivedType * DerivedTypePtr ()
 

Static Public Attributes

static constexpr bool Value = sizeof(Test(DerivedTypePtr())) == sizeof(Yes)
 
static constexpr bool IsDerived = Value
 

Detailed Description

template<typename DerivedType, typename BaseType>
struct Karma::TIsDerivedFrom< DerivedType, BaseType >

Is type DerivedType inherited from BaseType?

Remarks
Note that this is a hierarchy detecting mechanism similar to UObjectBase::IsA while being used for different purpose of direct Class type. IsA is used for UClass hierarchy purpose used in game code (that we introduce by hand, more like uscript like hierarchy).

Member Typedef Documentation

◆ No

template<typename DerivedType, typename BaseType>
typedef char Karma::TIsDerivedFrom< DerivedType, BaseType >::No[1]

When polymorphism fails, i.e there is no child-parent type relation for DerivedType and BaseType.

◆ Yes

template<typename DerivedType, typename BaseType>
typedef char Karma::TIsDerivedFrom< DerivedType, BaseType >::Yes[2]

When polymorphism succeeds, i.e there is child-parent type relation for DerivedType and BaseType.

Member Function Documentation

◆ DerivedTypePtr()

template<typename DerivedType, typename BaseType>
static DerivedType * Karma::TIsDerivedFrom< DerivedType, BaseType >::DerivedTypePtr ( )
inlinestatic

Makes a DerivedType ptr

Returns
pointer to DerivedType
Since
Karma 1.0.0

◆ Test() [1/3]

template<typename DerivedType, typename BaseType>
static No & Karma::TIsDerivedFrom< DerivedType, BaseType >::Test ( ...)
static

Handy function called when type-cast does not succeed.

Parameters
...Whatever the DerivedType is
Returns
No reference of specified size known from declaration and definition No.
Since
Karma 1.0.0

◆ Test() [2/3]

template<typename DerivedType, typename BaseType>
static Yes & Karma::TIsDerivedFrom< DerivedType, BaseType >::Test ( BaseType * )
static

Handy function called when type-cast succeeds.

Parameters
someBaseTypePointer to (type-cast) BaseType
Returns
Yes reference of specified size known from declaration and definition Yes.
Since
Karma 1.0.0

◆ Test() [3/3]

template<typename DerivedType, typename BaseType>
static Yes & Karma::TIsDerivedFrom< DerivedType, BaseType >::Test ( const BaseType * )
static

Handy variant function called when type-cast succeeds.

Parameters
someBaseTypePointer to (type-cast) const BaseType
Returns
Yes reference of specified size known from declaration and definition Yes.
Since
Karma 1.0.0

Member Data Documentation

◆ Value

template<typename DerivedType, typename BaseType>
bool Karma::TIsDerivedFrom< DerivedType, BaseType >::Value = sizeof(Test(DerivedTypePtr())) == sizeof(Yes)
staticconstexpr

Test the derived type pointer. If it inherits from BaseType, the Test( BaseType* ) will be chosen. If it does not, Test( ... ) will be chosen.


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