ponder
3.2
C++ reflection library
|
This object is used to create instances of metaclasses. More...
#include <runtime.hpp>
Public Member Functions | |
ObjectFactory (const Class &cls) | |
Constructor. More... | |
const Class & | getClass () const |
Get the class begin used. More... | |
UserObject | construct (const Args &args=Args::empty, void *ptr=nullptr) const |
Construct a new instance of the C++ class bound to the metaclass. More... | |
template<typename ... A> | |
UserObject | create (A... args) const |
Create a new instance of the class bound to the metaclass. More... | |
void | destroy (const UserObject &object) const |
Destroy an instance of the C++ class bound to the metaclass. More... | |
void | destruct (const UserObject &object) const |
Destruct an object created using placement new. More... | |
This object is used to create instances of metaclasses.
There are helpers for this class, see ponder::runtime::construct() and ponder::runtime::create().
Example of use:
|
inline |
UserObject ponder::runtime::ObjectFactory::construct | ( | const Args & | args = Args::empty , |
void * | ptr = nullptr |
||
) | const |
Construct a new instance of the C++ class bound to the metaclass.
If no constructor can match the provided arguments, UserObject::nothing is returned. If a pointer is provided then placement new is used instead of the new instance being dynamically allocated using new. The new instance is wrapped into a UserObject.
args | Arguments to pass to the constructor (empty by default) |
ptr | Optional pointer to the location to construct the object (placement new) |
|
inline |
Create a new instance of the class bound to the metaclass.
Create an object without having to create an Args list. See notes for Class::construct(). If you need to create an argument list at runtime and use it to create an object then see Class::construct().
args | An argument list. |
void ponder::runtime::ObjectFactory::destroy | ( | const UserObject & | object | ) | const |
Destroy an instance of the C++ class bound to the metaclass.
This function must be called to destroy every instance created with Class::construct.
object | Object to be destroyed |
void ponder::runtime::ObjectFactory::destruct | ( | const UserObject & | object | ) | const |
Destruct an object created using placement new.
This function must be called to destroy every instance created with Class::construct.
object | Object to be destroyed |
|
inline |
Get the class begin used.