Kanzi  3.9.4
Kanzi Engine API
kanzi::Metaclass Class Referenceabstract

Metaclass provides type inspection mechanism for Kanzi classes. More...

#include <kanzi/core/metadata/metaclass.hpp>

Inheritance diagram for kanzi::Metaclass:
[legend]

Public Types

typedef MessageTypeContainer::const_iterator MessageTypeIterator
 
typedef MetaclassContainer::const_iterator MetaclassIterator
 
typedef MetaMethodContainer::const_iterator MetaMethodIterator
 Iterator for MetaMethod container. More...
 
typedef PropertyTypeContainer::const_iterator PropertyTypeIterator
 

Public Member Functions

void addMessageType (AbstractMessageType messageType)
 
void addMethod (const MetaMethod *method)
 Registers a method to the metaclass. More...
 
void addMixin (const Metaclass *metaclass)
 
void addNestedMetaclass (const Metaclass *metaclass)
 
void addPropertyType (AbstractPropertyType propertyType)
 
MessageTypeIterator beginMessageTypes () const
 
MetaMethodIterator beginMethod () const
 Creates a const_iterator pointing to the top of the metamethod container. More...
 
MetaclassIterator beginMixinMetaclasses () const
 
MetaclassIterator beginNestedMetaclasses () const
 
PropertyTypeIterator beginPropertyTypes () const
 
virtual shared_ptr< MetaObjectcreate (Domain *domain, string_view name) const =0
 
template<typename Type >
shared_ptr< Type > create (Domain *domain, string_view name) const
 Creates an instance of a class this metaclass describes. More...
 
MessageTypeIterator endMessageTypes () const
 
MetaMethodIterator endMethod () const
 Creates a const_iterator pointing to the end of the metamethod container. More...
 
MetaclassIterator endMixinMetaclasses () const
 
MetaclassIterator endNestedMetaclasses () const
 
PropertyTypeIterator endPropertyTypes () const
 
const MetaMethodfindMethod (string_view name) const
 Returns the metamethod registered in the metaclass with the given name. More...
 
const MetaclassgetBase () const
 Returns the metaclass of the base class. More...
 
PropertyTypeEditorInfoSharedPtr getEditorInfo () const
 
const char * getName () const
 
bool isAbstract () const
 Returns true if the class described by the metaclass is abstract, false otherwise. More...
 
bool isDerivedFrom (const Metaclass *metaclass) const
 Determines whether the class this metaclass describes derives from a class described by specified metaclass. More...
 
bool isDerivedFromMixin (const Metaclass *metaclass) const
 Searches for the specified metaclass among mixin metaclasses of this metaclass and its base metaclasses. More...
 
virtual bool isMetaclassOf (const MetaObject &object) const =0
 Checks whether this metaclass describes the class of an object instance. More...
 
bool isSealed () const
 Internal function. More...
 
void seal ()
 Internal function. More...
 
void setEditorInfo (PropertyTypeEditorInfoSharedPtr editorInfo)
 

Protected Member Functions

void checkSealed () const
 
void clearAbstract ()
 
 Metaclass (const Metaclass *baseClass, FixedString name)
 
 Metaclass (const Metaclass *baseClass, MetadataGeneratedName name)
 
void setAbstract ()
 
virtual ~Metaclass ()
 

Detailed Description

Metaclass provides type inspection mechanism for Kanzi classes.

Classes deriving from Object can register information about their type, properties, methods, messages by using Metaclass and accompanying macros. Such information is used by serialization, scripting and to display friendly type information in Kanzi Studio.

Use KZ_METACLASS_BEGIN and KZ_METACLASS_END inside your class body to declare a metaclass. Serialization and functions instantiating objects use metaclass name to identify types. Use KZ_METACLASS_PROPERTY_TYPE to register a property type of your class to the metaclass. Use KZ_METACLASS_MESSAGE_TYPE to register a message type of your class to the metaclass. Use KZ_METACLASS_METHOD to register a MetaMethod of your class to the metaclass.

Member Typedef Documentation

◆ MetaclassIterator

typedef MetaclassContainer::const_iterator kanzi::Metaclass::MetaclassIterator

◆ PropertyTypeIterator

typedef PropertyTypeContainer::const_iterator kanzi::Metaclass::PropertyTypeIterator

◆ MessageTypeIterator

typedef MessageTypeContainer::const_iterator kanzi::Metaclass::MessageTypeIterator

◆ MetaMethodIterator

typedef MetaMethodContainer::const_iterator kanzi::Metaclass::MetaMethodIterator

Iterator for MetaMethod container.

Constructor & Destructor Documentation

◆ Metaclass() [1/2]

kanzi::Metaclass::Metaclass ( const Metaclass baseClass,
FixedString  name 
)
inlineexplicitprotected

◆ Metaclass() [2/2]

kanzi::Metaclass::Metaclass ( const Metaclass baseClass,
MetadataGeneratedName  name 
)
inlineexplicitprotected

◆ ~Metaclass()

virtual kanzi::Metaclass::~Metaclass ( )
inlineprotectedvirtual

Member Function Documentation

◆ isMetaclassOf()

virtual bool kanzi::Metaclass::isMetaclassOf ( const MetaObject object) const
pure virtual

Checks whether this metaclass describes the class of an object instance.

Implemented in kanzi::MetaclassStaticBase, kanzi::MetaclassAbstractImpl< TClass >, and kanzi::MetaclassImpl< TClass >.

◆ create() [1/2]

virtual shared_ptr<MetaObject> kanzi::Metaclass::create ( Domain domain,
string_view  name 
) const
pure virtual

◆ create() [2/2]

template<typename Type >
shared_ptr<Type> kanzi::Metaclass::create ( Domain domain,
string_view  name 
) const
inline

Creates an instance of a class this metaclass describes.

◆ isAbstract()

bool kanzi::Metaclass::isAbstract ( ) const
inline

Returns true if the class described by the metaclass is abstract, false otherwise.

◆ isSealed()

bool kanzi::Metaclass::isSealed ( ) const
inline

Internal function.

◆ seal()

void kanzi::Metaclass::seal ( )
inline

Internal function.

◆ getBase()

const Metaclass* kanzi::Metaclass::getBase ( ) const
inline

Returns the metaclass of the base class.

◆ isDerivedFrom()

bool kanzi::Metaclass::isDerivedFrom ( const Metaclass metaclass) const
inline

Determines whether the class this metaclass describes derives from a class described by specified metaclass.

◆ addPropertyType()

void kanzi::Metaclass::addPropertyType ( AbstractPropertyType  propertyType)
inline

◆ addMessageType()

void kanzi::Metaclass::addMessageType ( AbstractMessageType  messageType)
inline

◆ addNestedMetaclass()

void kanzi::Metaclass::addNestedMetaclass ( const Metaclass metaclass)
inline

◆ addMixin()

void kanzi::Metaclass::addMixin ( const Metaclass metaclass)
inline

◆ addMethod()

void kanzi::Metaclass::addMethod ( const MetaMethod method)

Registers a method to the metaclass.

For convenience use KZ_METACLASS_METHOD macro to declare the metamethods.

Parameters
methodThe address of the MetaMethod instance to be registered.

◆ beginNestedMetaclasses()

MetaclassIterator kanzi::Metaclass::beginNestedMetaclasses ( ) const
inline

◆ endNestedMetaclasses()

MetaclassIterator kanzi::Metaclass::endNestedMetaclasses ( ) const
inline

◆ beginMixinMetaclasses()

MetaclassIterator kanzi::Metaclass::beginMixinMetaclasses ( ) const
inline

◆ endMixinMetaclasses()

MetaclassIterator kanzi::Metaclass::endMixinMetaclasses ( ) const
inline

◆ beginPropertyTypes()

PropertyTypeIterator kanzi::Metaclass::beginPropertyTypes ( ) const
inline

◆ endPropertyTypes()

PropertyTypeIterator kanzi::Metaclass::endPropertyTypes ( ) const
inline

◆ beginMessageTypes()

MessageTypeIterator kanzi::Metaclass::beginMessageTypes ( ) const
inline

◆ endMessageTypes()

MessageTypeIterator kanzi::Metaclass::endMessageTypes ( ) const
inline

◆ beginMethod()

MetaMethodIterator kanzi::Metaclass::beginMethod ( ) const

Creates a const_iterator pointing to the top of the metamethod container.

◆ endMethod()

MetaMethodIterator kanzi::Metaclass::endMethod ( ) const

Creates a const_iterator pointing to the end of the metamethod container.

◆ findMethod()

const MetaMethod* kanzi::Metaclass::findMethod ( string_view  name) const

Returns the metamethod registered in the metaclass with the given name.

Parameters
nameThe name of the metamethod.
Returns
Pointer to the metamethod, nullptr if none found.

◆ isDerivedFromMixin()

bool kanzi::Metaclass::isDerivedFromMixin ( const Metaclass metaclass) const
inline

Searches for the specified metaclass among mixin metaclasses of this metaclass and its base metaclasses.

Parameters
metaclassThe metaclass to search for.
Returns
If the class that this metaclass describes derives from a class described by specified metaclass or contains the specified metaclass as a mixin metaclass, returns true, otherwise false.
Since
Kanzi 3.9.3

◆ getName()

const char* kanzi::Metaclass::getName ( ) const
inline

◆ setEditorInfo()

void kanzi::Metaclass::setEditorInfo ( PropertyTypeEditorInfoSharedPtr  editorInfo)
inline

◆ getEditorInfo()

PropertyTypeEditorInfoSharedPtr kanzi::Metaclass::getEditorInfo ( ) const
inline

◆ checkSealed()

void kanzi::Metaclass::checkSealed ( ) const
protected

◆ setAbstract()

void kanzi::Metaclass::setAbstract ( )
inlineprotected

◆ clearAbstract()

void kanzi::Metaclass::clearAbstract ( )
inlineprotected

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