CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
MetaObject Class Reference

Duck-typed objects. More...

#include <cc/MetaObject>

Inheritance diagram for MetaObject:

Classes

struct  State
 Internal state. More...
 

Public Member Functions

 MetaObject ()=default
 Create a null meta-object.
 
 MetaObject (const String &className)
 Create meta-object of class className.
 
String className () const
 Class name
 
List< MetaObject > & children ()
 List of children
 
const List< MetaObject > & children () const
 Constant list of children
 
Map< String, Variant > & members ()
 Key-value map of object properties
 
const Map< String, Variant > & members () const
 Constant key-value map of object properties
 
bool insert (const String &name, const Variant &value)
 Convenience method to add a new member.
 
void establish (const String &name, const Variant &value)
 Convenience method to establish a new member.
 
bool contains (const String &name) const
 Convenience method to check if a member of name exists.
 
bool lookup (const String &name, Out< Variant > value) const
 Convenience method to lookup the value of member name.
 
Variant operator() (const String &name) const
 Convenience method to get the value of member name
 
Variantoperator() (const String &name)
 Convenience method to get/set the value of member name
 
long count () const
 Convenience method to get the number of children
 
const MetaObjectoperator[] (long index) const
 Convenience method to get the child at index
 
MetaObjectoperator[] (long index)
 Convenience method to get the child at index
 
MetaObject produce () const
 Produce a meta-object using this meta-object as blueprint
 
void autocomplete (InOut< MetaObject > target) const
 Add all members of this meta-object to target, which are missing in target and also append all children of this meta-object to target
 
MetaObject clone () const
 Create clone of this meta-object.
 
void realize ()
 Realize a new object after deserialization.
 
bool operator== (const MetaObject &other) const
 Compare for equality with other.
 
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 
 operator bool () const
 Check if this is a non-null object.
 
bool isNull () const
 Check if this is a null object.
 
template<class T >
bool is () const
 Check if this object is of type T.
 
template<class T >
as () const
 Cast this object to type T.
 
bool isWeak () const
 Check if the underlying object reference is weak.
 
bool operator== (const Object &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
 
long useCount () const
 Reference count.
 

Protected Member Functions

 MetaObject (State *newState)
 Initialize internal state.
 
Stateme ()
 
const Stateme () const
 
- Protected Member Functions inherited from Object
template<class T >
weak () const
 
template<class T >
void initOnce ()
 Create the object state when called the first time.
 
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 
 Object (State *newState)
 Initialize object with newState.
 
 Object (State *state, Alias)
 
 Object (State *state, Weak)
 
Objectoperator= (std::nullptr_t)
 

Additional Inherited Members

- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
 
template<class T >
static T weak (const State *state)
 
- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state
 

Detailed Description

Duck-typed objects.

Constructor & Destructor Documentation

◆ MetaObject() [1/3]

MetaObject ( )
default

Create a null meta-object.

◆ MetaObject() [2/3]

MetaObject ( const String & className)
explicit

Create meta-object of class className.

◆ MetaObject() [3/3]

MetaObject ( State * newState)
explicitprotected

Initialize internal state.

Member Function Documentation

◆ className()

String className ( ) const

Class name

◆ children() [1/2]

List< MetaObject > & children ( )

List of children

◆ children() [2/2]

const List< MetaObject > & children ( ) const

Constant list of children

◆ members() [1/2]

Map< String, Variant > & members ( )

Key-value map of object properties

◆ members() [2/2]

const Map< String, Variant > & members ( ) const

Constant key-value map of object properties

◆ insert()

bool insert ( const String & name,
const Variant & value )

Convenience method to add a new member.

◆ establish()

void establish ( const String & name,
const Variant & value )

Convenience method to establish a new member.

◆ contains()

bool contains ( const String & name) const

Convenience method to check if a member of name exists.

◆ lookup()

bool lookup ( const String & name,
Out< Variant > value ) const

Convenience method to lookup the value of member name.

◆ operator()() [1/2]

Variant operator() ( const String & name) const

Convenience method to get the value of member name

◆ operator()() [2/2]

Variant & operator() ( const String & name)

Convenience method to get/set the value of member name

◆ count()

long count ( ) const

Convenience method to get the number of children

◆ operator[]() [1/2]

const MetaObject & operator[] ( long index) const

Convenience method to get the child at index

◆ operator[]() [2/2]

MetaObject & operator[] ( long index)

Convenience method to get the child at index

◆ produce()

MetaObject produce ( ) const

Produce a meta-object using this meta-object as blueprint

◆ autocomplete()

void autocomplete ( InOut< MetaObject > target) const

Add all members of this meta-object to target, which are missing in target and also append all children of this meta-object to target

◆ clone()

MetaObject clone ( ) const

Create clone of this meta-object.

◆ realize()

void realize ( )

Realize a new object after deserialization.

Exceptions
MetaError

◆ operator==()

bool operator== ( const MetaObject & other) const

Compare for equality with other.