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) | |
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 |
Protected Member Functions | |
MetaClass () | |
Friends | |
class | FunctorInstance |
class | FunctorStatic |
class | MetaCategory |
Detailed Description
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:
In the header file: class X : public Object { public: virtual const MetaClass& getType() {return *metadata;} static const MetaClass *metadata; } In the implementation file: const MetaClass *X::metadata;
Creating a MetaClass object isn't sufficient. It needs to be registered, typically in an initialization method:
void initialize() { ... Y::metadata = new MetaCategory("Y","Ys", reader_method, writer_method); X::metadata = new MetaClass("Y","X", factory_method); ... }
- See also:
- MetaCategory
Member Typedef Documentation
typedef Object*(* frepple::utils::MetaClass::creatorDefault)() |
typedef Object*(* frepple::utils::MetaClass::creatorString)(const string &) |
Constructor & Destructor Documentation
virtual frepple::utils::MetaClass::~MetaClass | ( | ) | [inline, virtual] |
frepple::utils::MetaClass::MetaClass | ( | const string & | cat, |
const string & | cls, | ||
bool | def = false |
||
) | [inline] |
frepple::utils::MetaClass::MetaClass | ( | const string & | cat, |
const string & | cls, | ||
creatorDefault | f, | ||
bool | def = false |
||
) | [inline] |
frepple::utils::MetaClass::MetaClass | ( | const string & | cat, |
const string & | cls, | ||
creatorString | f, | ||
bool | def = false |
||
) | [inline] |
frepple::utils::MetaClass::MetaClass | ( | ) | [inline, protected] |
Member Function Documentation
Action frepple::utils::MetaClass::decodeAction | ( | const char * | x | ) | [static] |
This function will analyze the string being passed, and return the appropriate action. The string is expected to be one of the following:
- 'A' for action ADD
- 'C' for action CHANGE
- 'AC' for action ADD_CHANGE
- 'R' for action REMOVE
- Any other value will result in a data exception
Definition at line 465 of file utils/library.cpp.
Action frepple::utils::MetaClass::decodeAction | ( | const AttributeList & | atts | ) | [static] |
This method picks up the attribute named "ACTION" from the list and calls the method decodeAction(const XML_Char*) to analyze it.
- See also:
- decodeAction(const XML_Char*)
Definition at line 477 of file utils/library.cpp.
const MetaClass * frepple::utils::MetaClass::findClass | ( | const char * | c | ) | [static] |
Find a particular class by its name. If it can't be located the return value is NULL.
Definition at line 428 of file utils/library.cpp.
bool frepple::utils::MetaClass::operator!= | ( | const MetaClass & | b | ) | const [inline] |
bool frepple::utils::MetaClass::operator< | ( | const MetaClass & | b | ) | const [inline] |
bool frepple::utils::MetaClass::operator== | ( | const MetaClass & | b | ) | const [inline] |
void frepple::utils::MetaClass::printClasses | ( | ) | [static] |
Print all registered factory methods to the standard output for debugging purposes.
Definition at line 444 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 485 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 317 of file utils/library.cpp.
Friends And Related Function Documentation
friend class FunctorInstance [friend] |
friend class FunctorStatic [friend] |
friend class MetaCategory [friend] |
Member Data Documentation
union { ... } |
A factory method for the registered class.
PyTypeObject* frepple::utils::MetaClass::pythonClass |
The documentation for this class was generated from the following files:
Documentation generated for frePPLe by
