This class stores metadata about the classes in the library. The stored information goes well beyond the standard 'type_info'. More...
#include <utils.h>
Public Types | |
typedef Object *(* | creatorDefault )() |
typedef Object *(* | creatorString )(const string &) |
Public Member Functions | |
void | connect (Functor *c, Signal a) const |
void | disconnect (Functor *c, Signal a) const |
MetaClass (const string &cat, const string &cls, bool def=false) | |
MetaClass (const string &cat, const string &cls, creatorDefault f, bool def=false) | |
MetaClass (const string &cat, const string &cls, creatorString f, bool def=false) | |
MetaClass () | |
bool | operator!= (const MetaClass &b) const |
bool | operator< (const MetaClass &b) const |
bool | operator== (const MetaClass &b) const |
bool | raiseEvent (Object *v, Signal a) const |
void | registerClass (const string &, const string &, bool=false, creatorDefault=NULL) |
virtual | ~MetaClass () |
Static Public Member Functions | |
static Action | decodeAction (const char *) |
static Action | decodeAction (const AttributeList &) |
static const MetaClass * | findClass (const char *) |
static void | printClasses () |
Public Attributes | |
union { | |
creatorDefault factoryMethodDefault | |
creatorString factoryMethodString | |
}; | |
const MetaCategory * | category |
PyTypeObject * | pythonClass |
string | type |
const Keyword * | typetag |
Friends | |
template<class T , class U > | |
class | FunctorInstance |
template<class T , class U > | |
class | FunctorStatic |
class | MetaCategory |
Additional Inherited Members | |
![]() | |
NonCopyable () | |
~NonCopyable () | |
This class stores metadata about the classes in the library. The stored information goes well beyond the standard 'type_info'.
A MetaClass instance represents metadata for a specific instance type. A MetaCategory instance represents metadata for a category of object. For instance, 'Resource' is a category while 'ResourceDefault' and 'ResourceInfinite' are specific classes.
The metadata class also maintains subscriptions to certain events. Registered classes and objects will receive callbacks when objects are being created, changed or deleted.
The proper usage is to include the following code snippet in every class:
Creating a MetaClass object isn't sufficient. It needs to be registered, typically in an initialization method:
typedef Object*(* frepple::utils::MetaClass::creatorDefault)() |
typedef Object*(* frepple::utils::MetaClass::creatorString)(const string &) |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
This function will analyze the string being passed, and return the appropriate action. The string is expected to be one of the following:
Definition at line 471 of file utils/library.cpp.
|
static |
This method picks up the attribute named "ACTION" from the list and calls the method decodeAction(const XML_Char*) to analyze it.
Definition at line 483 of file utils/library.cpp.
|
static |
Find a particular class by its name. If it can't be located the return value is NULL.
Definition at line 434 of file utils/library.cpp.
|
inline |
|
inline |
|
inline |
|
static |
Print all registered factory methods to the standard output for debugging purposes.
Definition at line 450 of file utils/library.cpp.
This method should be called whenever objects of this class are being created, updated or deleted. It will run the callback method of all subscribers.
If the function returns true, all callback methods approved of the event. If false is returned, one of the callbacks disapproved it and the event action should be allowed to execute.
Definition at line 491 of file utils/library.cpp.
void frepple::utils::MetaClass::registerClass | ( | const string & | a, |
const string & | b, | ||
bool | def = false , |
||
creatorDefault | f = NULL |
||
) |
Initialize the data structure and register the class.
Definition at line 323 of file utils/library.cpp.
|
friend |
|
friend |
|
friend |
union { ... } |
const MetaCategory* frepple::utils::MetaClass::category |
creatorDefault frepple::utils::MetaClass::factoryMethodDefault |
creatorString frepple::utils::MetaClass::factoryMethodString |
PyTypeObject* frepple::utils::MetaClass::pythonClass |
string frepple::utils::MetaClass::type |
const Keyword* frepple::utils::MetaClass::typetag |