Graphite  Version 3
An experimental 3D geometry processing program
OGF::MetaClass Class Reference

The representation of a class in the Meta repository. More...

#include <OGF/gom/reflection/meta_class.h>

Inheritance diagram for OGF::MetaClass:
OGF::MetaType OGF::MetaInformation OGF::Object OGF::CustomAttributes GEO::Counted OGF::DynamicMetaClass

Public Member Functions

 MetaClass (const std::string &class_name, MetaClass *super_class=nullptr, bool is_abstract=false)
 Constructs a new MetaClass. More...
 
 MetaClass (const std::string &class_name, const std::string &super_class_name, bool is_abstract=false)
 Constructs a new MetaClass. More...
 
 ~MetaClass () override
 MetaClass destructor.
 
void pre_delete () override
 Removes all variables that use the meta type system before deleting. More...
 
const std::string & super_class_name () const
 Gets the name of the super class. More...
 
bool is_abstract () const
 Tests if the class is abstract. More...
 
Objectcreate (const ArgList &args)
 Creates an object of this class. More...
 
size_t nb_members (bool super=true) const
 Gets the number of class members. More...
 
MetaMemberith_member (index_t i, bool super=true) const
 Gets a MetaMember by index. More...
 
MetaMemberfind_member (const std::string &member_name, bool super=true) const
 Finds a MetaMember by name. More...
 
size_t nb_signals (bool super=true) const
 Gets the number of signals. More...
 
MetaSignalith_signal (index_t i, bool super=true) const
 Gets a MetaSignal by index. More...
 
size_t nb_slots (bool super=true) const
 Gets the number of slots. More...
 
MetaSlotith_slot (index_t i, bool super=true) const
 Gets a MetaSlot by index. More...
 
size_t nb_properties (bool super=true) const
 Gets the number of properties. More...
 
MetaPropertyith_property (index_t i, bool super=true) const
 Gets a MetaProperty by index. More...
 
size_t nb_constructors () const
 Gets the number of constructors. More...
 
MetaConstructorith_constructor (index_t i) const
 Gets a MetaConstructor by index. More...
 
MetaMethodfind_method (const std::string &method_name, bool super=true) const
 Finds a MetaMethod by name. More...
 
MetaSlotfind_slot (const std::string &slot_name, bool super=true) const
 Finds a MetaSlot by name. More...
 
MetaSignalfind_signal (const std::string &signal_name, bool super=true) const
 Finds a MetaSignal by name. More...
 
MetaPropertyfind_property (const std::string &property_name, bool super=true) const
 Finds a MetaProperty by name. More...
 
virtual MetaClasscreate_subclass (const std::string &name, bool is_abstract=false)
 Creates a new subclass dynamically. More...
 
virtual bool is_subclass_of (const MetaClass *other) const
 Tests whether this MetaClass is a subclass of another MetaClass. More...
 
void set_abstract (bool b)
 Indicate that the class is abstract. More...
 
void add_member (MetaMember *member)
 Adds a new MetaMember to this class. More...
 
void get_members (std::vector< MetaMember * > &result, bool super=true) const
 Gets all the members. More...
 
void get_methods (std::vector< MetaMethod * > &result, bool super=true) const
 Gets all the methods. More...
 
void get_signals (std::vector< MetaSignal * > &result, bool super=true) const
 Gets all the signals. More...
 
void get_slots (std::vector< MetaSlot * > &result, bool super=true) const
 Gets all the slots. More...
 
void get_properties (std::vector< MetaProperty * > &result, bool super=true) const
 Gets all the properties. More...
 
void get_constructors (std::vector< MetaConstructor * > &result) const
 Gets all the constructors. More...
 
bool is_subtype_of (const MetaType *other) const override
 
void get_used_types (std::set< std::string > &used_types, bool super=true) const
 Gets all the types used by this class. More...
 
MetaConstructorbest_constructor (const ArgList &args)
 Gets the best constructors for the specified arguments. More...
 
Factoryfactory () const
 Gets the factory. More...
 
void set_factory (Factory *f)
 Sets the factory. More...
 
void search (const std::string &needle, const std::string &path="") override
 Displays the names of all objects that contain a substring. More...
 
std::string get_doc () const override
 Gets the documentation. More...
 
- Public Member Functions inherited from OGF::MetaType
 MetaType (const std::string &name)
 MetaType constructor. More...
 
 ~MetaType () override
 MetaType destructor.
 
const std::string & name () const
 Gets the C++ name of the type. More...
 
void set_typeid_name (const std::string &typeid_name)
 Sets the typeid name. More...
 
const std::string & typeid_name () const
 Gets the typeid name. More...
 
LifeCyclelife_cycle () const
 Gets the LifeCycle associated with the type. More...
 
void set_life_cycle (LifeCycle *life_cycle)
 Sets the LifeCycle associated with the type. More...
 
Serializerserializer () const
 Gets the serializer associated with the type. More...
 
void set_serializer (Serializer *ser)
 Sets the serializer associated with the type. More...
 
- Public Member Functions inherited from OGF::MetaInformation
bool has_custom_attribute (const std::string &name) const
 Tests whether a given custom attribute exists. More...
 
std::string ith_custom_attribute_name (index_t i) const
 Gets the name of a custom attribute by index. More...
 
std::string ith_custom_attribute_value (index_t i) const
 Gets the value of a custom attribute by index. More...
 
std::string custom_attribute_value (const std::string &name) const
 Gets the value of a new custom attribute. More...
 
void create_custom_attribute (const std::string &name, const std::string &value)
 Creates a new custom attribute. More...
 
void set_custom_attribute (const std::string &name, const std::string &value)
 Sets the value of a new custom attribute. More...
 
- Public Member Functions inherited from OGF::Object
 Object (bool transient=false)
 Object constructor. More...
 
virtual ~Object ()
 Object destructor.
 
virtual MetaClassmeta_class () const
 Gets the meta class. More...
 
virtual void set_meta_class (MetaClass *mclass)
 Sets the meta class. More...
 
unsigned int id () const
 Gets the identifier of this object. More...
 
std::string string_id () const
 Gets the unique string identifier. More...
 
bool has_method (const std::string &method_name) const
 Tests whether a method is defined. More...
 
virtual bool invoke_method (const std::string &method_name, const ArgList &args, Any &ret_val)
 Invokes a method by method name and argument list, and gets the return value. More...
 
bool invoke_method (const std::string &method_name, const ArgList &args)
 Invokes a method by method name and argument list. More...
 
bool invoke_method (const std::string &method_name)
 Invokes a method by method name. More...
 
bool has_property (const std::string &prop_name) const
 Tests whether a property is defined. More...
 
virtual bool get_property (const std::string &prop_name, std::string &prop_value) const
 Gets a property. More...
 
virtual Connectionconnect_signal_to_slot (const std::string &signal_name, Object *to, const std::string &slot_name)
 Connects a signal with a slot of another object. More...
 
virtual void add_connection (Connection *connection)
 Adds a connection to this object. More...
 
virtual void remove_connection (Connection *connection)
 Removes a connection to this object. More...
 
virtual void get_element (index_t i, Any &value) const
 Gets an element by index. More...
 
virtual void set_element (index_t i, const Any &value)
 Sets an element by index. More...
 
bool get_signals_enabled () const
 Tests wheter signals are enabled. More...
 
void set_signals_enabled (bool value)
 Enables or disables signals. More...
 
bool get_slots_enabled () const
 Tests wheter slots are enabled. More...
 
void set_slots_enabled (bool value)
 Enables or disables slots. More...
 
MetaClassget_meta_class () const
 Gets the meta class. More...
 
std::string get_string_id () const
 Gets the unique string identifier. More...
 
virtual Sign compare (const Object *other) const
 Compares this object with another one. More...
 
virtual bool is_a (const MetaType *type) const
 Tests whether this object inherits a given type. More...
 
void disconnect ()
 Removes all connections from signals of this objects. More...
 
void enable_signals ()
 Enables signals.
 
void disable_signals ()
 Disables signals.
 
void enable_slots ()
 Enables slots.
 
void disable_slots ()
 Disables slots.
 
void set_properties (const ArgList &args)
 Sets several properties in a single call. More...
 
virtual bool set_property (const std::string &name, const std::string &value)
 Sets an individual property. More...
 
void help () const
 Displays some help about this object. More...
 
virtual bool set_property (const std::string &name, const Any &value)
 Sets an individual property. More...
 
virtual bool get_property (const std::string &prop_name, Any &prop_value) const
 Gets a property. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 
- Public Member Functions inherited from OGF::CustomAttributes
size_t nb_custom_attributes () const
 Gets the number of custom attributes. More...
 
std::string ith_custom_attribute_name (index_t i) const
 Gets the name of a custom attribute by index. More...
 
std::string ith_custom_attribute_value (index_t i) const
 Gets the value of a custom attribute by index. More...
 
bool has_custom_attribute (const std::string &name) const
 Tests whether a given custom attribute exists. More...
 
void create_custom_attribute (const std::string &name, const std::string &value)
 Creates a new custom attribute. More...
 
void set_custom_attribute (const std::string &name, const std::string &value)
 Sets the value of a new custom attribute. More...
 
std::string custom_attribute_value (const std::string &name) const
 Gets the value of a new custom attribute. More...
 
void clear_custom_attributes ()
 Clears the custom attributes.
 

Public Attributes

 __pad0__: MetaClass* super_class() const
 
- Public Attributes inherited from OGF::MetaType
 __pad0__: virtual bool is_subtype_of(const MetaType* other) const
 
 __pad1__: const std::string& get_name() const { return name()
 
- Public Attributes inherited from OGF::MetaInformation
 __pad0__: size_t nb_custom_attributes() const
 
- Public Attributes inherited from OGF::Object
 __pad0__: virtual index_t get_nb_elements() const
 
 __pad1__: bool equals(const Object* other) const
 

Protected Member Functions

std::string new_constructor_name () const
 Generates a dummy name for a constructor. More...
 
void append_members (std::vector< MetaMember * > &result, bool super=true) const
 Gets all the members and appends them to a vector. More...
 
void append_methods (std::vector< MetaMethod * > &result, bool super=true) const
 Gets all the methods and appends them to a vector. More...
 
void append_signals (std::vector< MetaSignal * > &result, bool super=true) const
 Gets all the signals and appends them to a vector. More...
 
void append_slots (std::vector< MetaSlot * > &result, bool super=true) const
 Gets all the slots and appends them to a vector. More...
 
void append_properties (std::vector< MetaProperty * > &result, bool super=true) const
 Gets all the properties. More...
 
- Protected Member Functions inherited from OGF::Object
virtual bool emit_signal (const std::string &signal_name, const ArgList &args, bool called_from_slot=false)
 Emits a signal and calls the slots it is connected to. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Friends

class ::OGF::MetaConstructor
 

Additional Inherited Members

- Static Public Member Functions inherited from OGF::Object
static Objectid_to_object (unsigned int id)
 Gets an object from a unique object id. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Detailed Description

The representation of a class in the Meta repository.

Definition at line 64 of file meta_class.h.

Constructor & Destructor Documentation

◆ MetaClass() [1/2]

OGF::MetaClass::MetaClass ( const std::string &  class_name,
MetaClass super_class = nullptr,
bool  is_abstract = false 
)
explicit

Constructs a new MetaClass.

Parameters
[in]class_namethe C++ class name
[in]super_classa pointer to the super class, or nullptr if there is no super class
[in]is_abstractindicates whether the class is abstract (e.g. with pure virtual methods) or not. Abstract classes cannot be constructed.

◆ MetaClass() [2/2]

OGF::MetaClass::MetaClass ( const std::string &  class_name,
const std::string &  super_class_name,
bool  is_abstract = false 
)
explicit

Constructs a new MetaClass.

Parameters
[in]class_namethe C++ class name
[in]super_class_namethe C++ name of the super class
[in]is_abstractindicates whether the class is abstract (e.g. with pure virtual methods) or not. Abstract classes cannot be constructed.

Member Function Documentation

◆ add_member()

void OGF::MetaClass::add_member ( MetaMember member)
inline

Adds a new MetaMember to this class.

Parameters
[in]membera pointer to the MetaMember to be added. Ownership is transfered to this MetaClass.

Definition at line 320 of file meta_class.h.

◆ append_members()

void OGF::MetaClass::append_members ( std::vector< MetaMember * > &  result,
bool  super = true 
) const
protected

Gets all the members and appends them to a vector.

Parameters
[in,out]resulta vector of MetaMember pointers
[in]superif true, gets also the MetaMembers inherited from super classes

◆ append_methods()

void OGF::MetaClass::append_methods ( std::vector< MetaMethod * > &  result,
bool  super = true 
) const
protected

Gets all the methods and appends them to a vector.

Both signals, slots and constructors are methods.

Parameters
[in,out]resulta vector of MetaMethod pointers
[in]superif true, gets also the MetaMethods inherited from super classes

◆ append_properties()

void OGF::MetaClass::append_properties ( std::vector< MetaProperty * > &  result,
bool  super = true 
) const
protected

Gets all the properties.

Parameters
[in,out]resulta vector of MetaProperty pointers
[in]superif true, gets also the MetaProperties inherited from super classes

◆ append_signals()

void OGF::MetaClass::append_signals ( std::vector< MetaSignal * > &  result,
bool  super = true 
) const
protected

Gets all the signals and appends them to a vector.

Parameters
[in,out]resulta vector of MetaSignal pointers
[in]superif true, gets also the MetaSignals inherited from super classes

◆ append_slots()

void OGF::MetaClass::append_slots ( std::vector< MetaSlot * > &  result,
bool  super = true 
) const
protected

Gets all the slots and appends them to a vector.

Parameters
[in,out]resulta vector of MetaSlot pointers
[in]superif true, gets also the MetaSlots inherited from super classes

◆ best_constructor()

MetaConstructor* OGF::MetaClass::best_constructor ( const ArgList args)

Gets the best constructors for the specified arguments.

The best constructor is the one that uses the largest number of arguments.

Parameters
[in]argsthe arguments, as name-value pairs
Returns
a pointer to the MetaConstructor that corresponds to the best constructor.

◆ create()

Object* OGF::MetaClass::create ( const ArgList args)

Creates an object of this class.

Parameters
argsthe parameters to be passed to the constructor. The constructor that best matches the parameters list is selected.
Returns
the created object, or nullptr if no matching constructor was found or if the class is abstract.

◆ create_subclass()

virtual MetaClass* OGF::MetaClass::create_subclass ( const std::string &  name,
bool  is_abstract = false 
)
virtual

Creates a new subclass dynamically.

Parameters
[in]namethe name of the subclass to be created
[in]is_abstracttrue if the class is abstract, that is, if no object of this class can be created
Returns
the newly created subclass

To be used in scripts that create new classes dynamically

◆ factory()

Factory* OGF::MetaClass::factory ( ) const
inline

Gets the factory.

Returns
a pointer to the factory associated with this class, or nullptr if there is no factory. The returned factory is typically a FactoryMetaClass, that selects the best constructor according to the arguments.

Definition at line 433 of file meta_class.h.

◆ find_member()

MetaMember* OGF::MetaClass::find_member ( const std::string &  member_name,
bool  super = true 
) const

Finds a MetaMember by name.

Parameters
[in]member_namename of the member
[in]superif true, search also in members inherited from super class
Returns
a pointer to the found MetaMember or nullptr

◆ find_method()

MetaMethod* OGF::MetaClass::find_method ( const std::string &  method_name,
bool  super = true 
) const

Finds a MetaMethod by name.

Both signals, slots and constructors are methods.

Parameters
[in]method_namename of the method
[in]superif true, search also in members inherited from super class
Returns
a pointer to the found MetaMethod or nullptr

◆ find_property()

MetaProperty* OGF::MetaClass::find_property ( const std::string &  property_name,
bool  super = true 
) const

Finds a MetaProperty by name.

Parameters
[in]property_namename of the property
[in]superif true, search also in members inherited from super class
Returns
a pointer to the found MetaProperty or nullptr

◆ find_signal()

MetaSignal* OGF::MetaClass::find_signal ( const std::string &  signal_name,
bool  super = true 
) const

Finds a MetaSignal by name.

Parameters
[in]signal_namename of the signal
[in]superif true, search also in members inherited from super class
Returns
a pointer to the found MetaSignal or nullptr

◆ find_slot()

MetaSlot* OGF::MetaClass::find_slot ( const std::string &  slot_name,
bool  super = true 
) const

Finds a MetaSlot by name.

Parameters
[in]slot_namename of the slot
[in]superif true, search also in members inherited from super class
Returns
a pointer to the found MetaMethod or nullptr

◆ get_constructors()

void OGF::MetaClass::get_constructors ( std::vector< MetaConstructor * > &  result) const

Gets all the constructors.

Parameters
[out]resulta vector of MetaConstructor pointers

◆ get_doc()

std::string OGF::MetaClass::get_doc ( ) const
overridevirtual

Gets the documentation.

Returns
A string with a human-readable documentation about this object.

Reimplemented from OGF::Object.

◆ get_members()

void OGF::MetaClass::get_members ( std::vector< MetaMember * > &  result,
bool  super = true 
) const
inline

Gets all the members.

Parameters
[out]resulta vector of MetaMember pointers
[in]superif true, gets also the MetaMembers inherited from super classes

Definition at line 330 of file meta_class.h.

◆ get_methods()

void OGF::MetaClass::get_methods ( std::vector< MetaMethod * > &  result,
bool  super = true 
) const
inline

Gets all the methods.

Both signals, slots and constructors are methods.

Parameters
[out]resulta vector of MetaMethod pointers
[in]superif true, gets also the MetaMethods inherited from super classes

Definition at line 345 of file meta_class.h.

◆ get_properties()

void OGF::MetaClass::get_properties ( std::vector< MetaProperty * > &  result,
bool  super = true 
) const
inline

Gets all the properties.

Parameters
[out]resulta vector of MetaProperty pointers
[in]superif true, gets also the MetaProperties inherited from super classes

Definition at line 384 of file meta_class.h.

◆ get_signals()

void OGF::MetaClass::get_signals ( std::vector< MetaSignal * > &  result,
bool  super = true 
) const
inline

Gets all the signals.

Parameters
[out]resulta vector of MetaSignal pointers
[in]superif true, gets also the MetaSignals inherited from super classes

Definition at line 358 of file meta_class.h.

◆ get_slots()

void OGF::MetaClass::get_slots ( std::vector< MetaSlot * > &  result,
bool  super = true 
) const
inline

Gets all the slots.

Parameters
[out]resulta vector of MetaSlot pointers
[in]superif true, gets also the MetaSlots inherited from super classes

Definition at line 371 of file meta_class.h.

◆ get_used_types()

void OGF::MetaClass::get_used_types ( std::set< std::string > &  used_types,
bool  super = true 
) const

Gets all the types used by this class.

A type is used by this class if it appears as an argument of a method or if the class has a property of this type.

Parameters
[out]used_typesa set of strings with the C++ type names of the used types
[in]superif true, gets also the types used by super classes

◆ is_abstract()

bool OGF::MetaClass::is_abstract ( ) const
inline

Tests if the class is abstract.

Return values
trueif the class is abstract
falseotherwise

Definition at line 127 of file meta_class.h.

◆ is_subclass_of()

virtual bool OGF::MetaClass::is_subclass_of ( const MetaClass other) const
virtual

Tests whether this MetaClass is a subclass of another MetaClass.

Parameters
[in]othera pointer to a MetaClass
Return values
trueif this MetaClass is the same or is a subtype of other
falseotherwise

◆ is_subtype_of()

bool OGF::MetaClass::is_subtype_of ( const MetaType other) const
override

◆ ith_constructor()

MetaConstructor* OGF::MetaClass::ith_constructor ( index_t  i) const

Gets a MetaConstructor by index.

Parameters
[in]iindex of the property
Precondition
i < nb_constructors()

◆ ith_member()

MetaMember* OGF::MetaClass::ith_member ( index_t  i,
bool  super = true 
) const

Gets a MetaMember by index.

Parameters
[in]iindex of the MetaMember
[in]superif true, lookup also in superclasses
Precondition
i < nb_members(super)

◆ ith_property()

MetaProperty* OGF::MetaClass::ith_property ( index_t  i,
bool  super = true 
) const

Gets a MetaProperty by index.

Parameters
[in]iindex of the property
[in]superif true, lookup also in superclasses
Precondition
i < nb_properties(super)

◆ ith_signal()

MetaSignal* OGF::MetaClass::ith_signal ( index_t  i,
bool  super = true 
) const

Gets a MetaSignal by index.

Parameters
[in]iindex of the signal
[in]superif true, lookup also in superclasses
Precondition
i < nb_signals(super)

◆ ith_slot()

MetaSlot* OGF::MetaClass::ith_slot ( index_t  i,
bool  super = true 
) const

Gets a MetaSlot by index.

Parameters
[in]iindex of the slot
[in]superif true, lookup also in superclasses
Precondition
i < nb_slots(super)

◆ nb_constructors()

size_t OGF::MetaClass::nb_constructors ( ) const

Gets the number of constructors.

Returns
the number of constructors

◆ nb_members()

size_t OGF::MetaClass::nb_members ( bool  super = true) const

Gets the number of class members.

Class members are constructors, signals, slots or properties.

Parameters
[in]superif true, counts also the inherited members, else only the members declared in this class
Returns
the number of members

◆ nb_properties()

size_t OGF::MetaClass::nb_properties ( bool  super = true) const

Gets the number of properties.

Parameters
[in]superif true, counts also the inherited properties, else only the slots declared in this class
Returns
the number of properties

◆ nb_signals()

size_t OGF::MetaClass::nb_signals ( bool  super = true) const

Gets the number of signals.

Parameters
[in]superif true, counts also the inherited signals, else only the signals declared in this class
Returns
the number of signals

◆ nb_slots()

size_t OGF::MetaClass::nb_slots ( bool  super = true) const

Gets the number of slots.

Parameters
[in]superif true, counts also the inherited slots, else only the slots declared in this class
Returns
the number of slots

◆ new_constructor_name()

std::string OGF::MetaClass::new_constructor_name ( ) const
protected

Generates a dummy name for a constructor.

Each MetaMember is supposed to have a name, this function generates a unique name for each constructor ("constructor_nnn").

Returns
a unique constructor name.

◆ pre_delete()

void OGF::MetaClass::pre_delete ( )
overridevirtual

Removes all variables that use the meta type system before deleting.

If we do not do that, when deleting the meta type system, we can delete the meta information in the wrong order, and delete first meta classes that we needed to delete other ones.

Reimplemented from OGF::MetaType.

◆ search()

void OGF::MetaClass::search ( const std::string &  needle,
const std::string &  path = "" 
)
overridevirtual

Displays the names of all objects that contain a substring.

Parameters
[in]needlethe substring
[in]paththe path to be prepended to the names

Reimplemented from OGF::MetaInformation.

◆ set_abstract()

void OGF::MetaClass::set_abstract ( bool  b)
inline

Indicate that the class is abstract.

Parameters
[in]btrue if the class is abstract, false otherwise

Definition at line 309 of file meta_class.h.

◆ set_factory()

void OGF::MetaClass::set_factory ( Factory f)
inline

Sets the factory.

Parameters
[in]fa pointer to the factory to be associated with this class.

Definition at line 442 of file meta_class.h.

◆ super_class_name()

const std::string& OGF::MetaClass::super_class_name ( ) const
inline

Gets the name of the super class.

Returns
the C++ name of the super class

Definition at line 118 of file meta_class.h.


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