Skip to content

File include/brisk/core/MetaClass.hpp


MetaClass class

MetaClass

Represents metadata for a class.

This struct stores the base class pointer and class name, forming the foundation for type identification and casting in a hierarchy. It is designed to be immutable and non-copyable.

classBase variable (MetaClass::classBase)

const MetaClass *classBase

Pointer to the base class's MetaClass, or nullptr if no base.

className variable (MetaClass::className)

std::string_view className

Name of the class as a string view.

MetaClass function (MetaClass::MetaClass)

consteval MetaClass(const MetaClass *base,
                    std::string_view className) noexcept
    : classBase(base), className(className)

Constructs a MetaClass with a base class and name.
Param base Pointer to the base class's MetaClass (nullptr if root).
Param className Name of the class.
Note This constructor is evaluated at compile-time.


MetaClassRoot class

MetaClassRoot

Root class metadata for classes with no base class in the RTTI system.

Inherits from MetaClass and sets the base class to nullptr.

MetaClassRoot function (MetaClassRoot::MetaClassRoot)

consteval MetaClassRoot(std::string_view className) noexcept
    : MetaClass

Constructs a root MetaClass with no base class.
Param className Name of the root class.


MetaClassImpl class

template <typename T, typename Base> MetaClassImpl

Template struct for derived class metadata in the RTTI system.

Inherits from MetaClass and links to the base class's metadata.
Template param T The derived class type.
Template param Base The base class type.

MetaClassImpl<T, Base> function (MetaClassImpl::MetaClassImpl<T, Base>)

consteval MetaClassImpl(std::string_view className) noexcept
    : MetaClass

Constructs metadata for a derived class.
Param className Name of the derived class.


isClassOrBase function (Internal::isClassOrBase)

bool isClassOrBase(const MetaClass *baseClass,
                   const MetaClass *instanceClass) noexcept

Checks if one class is the same as or a base of another class.
Param baseClass Pointer to the base class's MetaClass.
Param instanceClass Pointer to the instance's MetaClass.
Returns True if baseClass is in the inheritance chain of instanceClass, false otherwise.


dynamicCast function

template <typename To, typename From>
inline To dynamicCast(From *ptr) noexcept

Performs a dynamic cast between pointer types using custom RTTI.
Template param To The target pointer type.
Template param From The source pointer type.
Param ptr Pointer to the source object.
Returns Pointer of type To if the cast is valid, nullptr otherwise.


isOf function

template <typename Class, typename From>
inline bool isOf(From *ptr) noexcept

Checks if an object is of a specific class type or derived from it.
Template param Class The class type to check against.
Template param From The type of the pointer.
Param ptr Pointer to the object.
Returns True if the object is of type Class or a derived type, false otherwise.


dynamicPointerCast function

template <typename T, typename U>
std::shared_ptr<T>
dynamicPointerCast(const std::shared_ptr<U> &r) noexcept

Performs a dynamic cast on a shared_ptr using custom RTTI.
Template param T The target type of the shared_ptr.
Template param U The source type of the shared_ptr.
Param r The source shared_ptr.
Returns A shared_ptr of type T if the cast is valid, an empty shared_ptr otherwise.


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/