Provides fast RTTI abilities in C++, loosely based off LLVM techniques.
More...
Go to the source code of this file.
Provides fast RTTI abilities in C++, loosely based off LLVM techniques.
- Author
- Ken Kopelson (ken@m.nosp@m.etae.nosp@m.ra.co.nosp@m.m)
- Version
- 0.1
- Date
- 2019-12-26
- Copyright
- Copyright (c) 2019
◆ RTTI_BASE_CLASS_PRIVATE
| #define RTTI_BASE_CLASS_PRIVATE const RTTI _classType; |
◆ RTTI_BASE_CLASS_PROTECTED_CONSTRUCTOR
| #define RTTI_BASE_CLASS_PROTECTED_CONSTRUCTOR |
( |
|
BASE_CLASS | ) |
|
Value:BASE_CLASS(RTTI classType) : _classType(classType) { \
}
◆ RTTI_BASE_CLASS_PUBLIC
| #define RTTI_BASE_CLASS_PUBLIC const RTTI getClassType() const { return _classType; } |
◆ RTTI_BASE_CLASS_TREE
| #define RTTI_BASE_CLASS_TREE |
( |
|
... | ) |
|
Value:enum RTTI{ __VA_ARGS__ }; \
static RTTI _rttiTree;
Creates an enum of an entire class tree.
Each class is specified with two entries Each branch starts with _FT_X and ends with _LT_X.
{_FT_Shape, _FT_Square, _FT_Rectangle, _LT_Rectangle, _LT_Square, _FT_Ellipse, _FT_Circle, _LT_Circle, _LT_Ellipse, _LT_Shape }
This macro should be specified in the protected section of your base class
◆ RTTI_PROTECTED_CONSTRUCTOR
| #define RTTI_PROTECTED_CONSTRUCTOR |
( |
|
PARENT_CLASS, |
|
|
|
THIS_CLASS |
|
) |
| |
Value:THIS_CLASS(RTTI classType) : PARENT_CLASS(classType) { \
}
◆ RTTI_PUBLIC_DEFAULT_CONSTRUCTOR
| #define RTTI_PUBLIC_DEFAULT_CONSTRUCTOR |
( |
|
THIS_CLASS, |
|
|
|
RTTI_TYPE |
|
) |
| |
Value:THIS_CLASS() : THIS_CLASS(_FT_##RTTI_TYPE) { \
}
◆ RTTI_PUBLIC_METHODS
| #define RTTI_PUBLIC_METHODS |
( |
|
BASE_CLASS, |
|
|
|
RTTI_TYPE |
|
) |
| |
Value:static bool isTypeOf(const BASE_CLASS *clazz) { \
const RTTI rttiType = clazz->getClassType(); \
return (rttiType >= _FT_##RTTI_TYPE && rttiType <= _LT_##RTTI_TYPE); \
}
This macro should be specified in the public section of all classes that derive from the base class.
- Parameters
-
| BASE_CLASS | - This specifies the actual base class name |
| RTTI_TYPE | - This specifies the root part of the RTTI part (without FT or LT) |