|
AndroMeta
2.0.0
|
Interface used to dynamically instantiate a class from M, recreate a stored object, or create a remote object. More...
#include <MFactory.h>
Public Member Functions | |
| MFactory (const mstr &className) | |
| virtual | ~MFactory () |
| virtual MObjectBase * | create (mnode f) |
| virtual MObject * | create (MBrokerBase *broker) |
| virtual MObjectBase * | recreate (const mvar &v) |
Static Public Member Functions | |
| static MObjectBase::ClassIdType | allocateClassId () |
| static MObjectBase * | construct (mnode f) |
| static MObjectBase * | restore (const mvar &v) |
Interface used to dynamically instantiate a class from M, recreate a stored object, or create a remote object.
Factories enable dynamic instantiation of a class from M, the re-creation of stored objects from an mvar, and the creation of remote objects (client-side distributed objects). To allow a class to be instantiated from the M intepreter, the user creates an MFactory subclass, re-implementing the relevant methods: create() and recreate(). The factory should then be instantiated statically/globally such that enabling the factory is a simple matter of linking the appropriate library/object.
| Meta::MFactory::MFactory | ( | const mstr & | className | ) |
Constructor.
| className | The name of the class that this factory refers to. |
| virtual Meta::MFactory::~MFactory | ( | ) | [virtual] |
Destructor.
| static MObjectBase::ClassIdType Meta::MFactory::allocateClassId | ( | ) | [static] |
| static MObjectBase* Meta::MFactory::construct | ( | mnode | f | ) | [static] |
Construct an object from a function. This searches for the appropriate factory and creates the object using the available factories and their create() methods.
| f | Function to create a class, e.g: MRandom(10) |
| virtual MObjectBase* Meta::MFactory::create | ( | mnode | f | ) | [virtual] |
Reimplement to allow this factory's class to be instantiated from the M interpreter. Default behavior is to return null (disabled).
| f | The function node passed to the create the object, e.g: MRandom(10) so that the args may be passed to the appropriate C++ constructor. Should return null in the case of args mismatch. |
| virtual MObject* Meta::MFactory::create | ( | MBrokerBase * | broker | ) | [virtual] |
Reimplement to allow this factory's class to be obtained via a distributed broker. This method provides the client-side object of the distributed object. It calls a class-specific constructor which in turn calls MObject(MBrokerBase* broker). The default behavior is to return null (disabled).
| virtual MObjectBase* Meta::MFactory::recreate | ( | const mvar & | v | ) | [virtual] |
| static MObjectBase* Meta::MFactory::restore | ( | const mvar & | v | ) | [static] |
Restore an object from a stored mvar. This searches for the appropriate factory and re-creates the object using that factory's recreate() method.
1.7.6.1