GammaRay API Documentation  3.2.0
Public Member Functions | Protected Member Functions | List of all members
GammaRay::MetaObject Class Referenceabstract

Compile-time introspection adaptor for non-QObject classes. More...

#include <metaobject.h>

Public Member Functions

void addBaseClass (MetaObject *baseClass)
 Add a base class meta object.
 
void addProperty (MetaProperty *property)
 Add a property for this class. More...
 
void * castForPropertyAt (void *object, int index) const
 Casts a void pointer for an instance of this type to one appropriate for use with the property at index index. More...
 
void * castFrom (void *object, MetaObject *baseClass) const
 Casts to a void pointer for an instance of this type coming from the given base class. More...
 
void * castTo (void *object, const QString &baseClass) const
 Casts to a void pointer for an instance of this type to one referring to the given base class type. More...
 
QString className () const
 Returns the name of the class represented by this object.
 
bool inherits (const QString &className) const
 Returns true if this class inherits (directly or indirectly) a class named className.
 
bool isPolymorphic () const
 Returns true if this is a polymorphic type. More...
 
MetaPropertypropertyAt (int index) const
 Returns the property adaptor for index index.
 
int propertyCount () const
 Returns the amount of properties available in this class (including base classes).
 
void setClassName (const QString &className)
 Sets the name of this class to className.
 
MetaObjectsuperClass (int index=0) const
 Returns the MetaObject for the index base class.
 

Protected Member Functions

virtual void * castFromBaseClass (void *object, int baseClassIndex) const =0
 Casts down from base class baseClassIndex. More...
 
virtual void * castToBaseClass (void *object, int baseClassIndex) const =0
 Casts up to base class baseClassIndex. More...
 
virtual bool isClassPolymorphic () const =0
 Returns if this type is polymorphic. More...
 

Detailed Description

Compile-time introspection adaptor for non-QObject classes.

Member Function Documentation

◆ addProperty()

void GammaRay::MetaObject::addProperty ( MetaProperty property)

Add a property for this class.

This transfers ownership.

◆ castForPropertyAt()

void* GammaRay::MetaObject::castForPropertyAt ( void *  object,
int  index 
) const

Casts a void pointer for an instance of this type to one appropriate for use with the property at index index.

Make sure to use this when dealing with multi-inheritance.

◆ castFrom()

void* GammaRay::MetaObject::castFrom ( void *  object,
MetaObject baseClass 
) const

Casts to a void pointer for an instance of this type coming from the given base class.

This performs the equivalent of a dynamic_cast and thus can return nullptr.

◆ castFromBaseClass()

virtual void* GammaRay::MetaObject::castFromBaseClass ( void *  object,
int  baseClassIndex 
) const
protectedpure virtual

Casts down from base class baseClassIndex.

This performs a dynamic cast on polymorphic types, and is undefined for non-polymorphic types.

◆ castTo()

void* GammaRay::MetaObject::castTo ( void *  object,
const QString &  baseClass 
) const

Casts to a void pointer for an instance of this type to one referring to the given base class type.

If baseClass is not a base class of this type, nullptr is returned.

◆ castToBaseClass()

virtual void* GammaRay::MetaObject::castToBaseClass ( void *  object,
int  baseClassIndex 
) const
protectedpure virtual

Casts up to base class baseClassIndex.

This is important when traversing multi-inheritance trees.

◆ isClassPolymorphic()

virtual bool GammaRay::MetaObject::isClassPolymorphic ( ) const
protectedpure virtual

Returns if this type is polymorphic.

This can but does not require to return true for types derives from a polymorphic type.

◆ isPolymorphic()

bool GammaRay::MetaObject::isPolymorphic ( ) const

Returns true if this is a polymorphic type.

See also
std::is_polymorphic

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
GammaRay Qt-application inspection and manipulation tool
https://www.kdab.com/development-resources/qt-tools/gammaray/
Generated by doxygen 1.9.1