GammaRay API Documentation  2.10.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. More...
 
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. More...
 
bool inherits (const QString &className) const
 Returns true if this class inherits (directly or indirectly) a class named className. More...
 
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. More...
 
MetaObjectsuperClass (int index=0) const
 Returns the MetaObject for the index base class. More...
 

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

void GammaRay::MetaObject::addBaseClass ( MetaObject baseClass)

Add a base class meta object.

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

Add a property for this class.

This transfers ownership.

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.

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.

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.

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.

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.

QString GammaRay::MetaObject::className ( ) const

Returns the name of the class represented by this object.

bool GammaRay::MetaObject::inherits ( const QString className) const

Returns true if this class inherits (directly or indirectly) a class named className.

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.

bool GammaRay::MetaObject::isPolymorphic ( ) const

Returns true if this is a polymorphic type.

See also
std::is_polymorphic
void GammaRay::MetaObject::setClassName ( const QString className)

Sets the name of this class to className.

MetaObject* GammaRay::MetaObject::superClass ( int  index = 0) const

Returns the MetaObject for the index base class.


Klarälvdalens Datakonsult AB (KDAB)
"The Qt Experts"
https://www.kdab.com/
GammaRay
Qt-application inspection and manipulation tool
https://www.kdab.com/gammaray/