#include <class_registry.h>
Nevrax France
Definition at line 88 of file class_registry.h.
Static Public Member Functions | |
| bool | checkObject (IClassable *obj) |
| check if the object has been correctly registered. Must be used for debug only, and Must compile with RTTI. | |
| IClassable * | create (const std::string &className) throw (ERegistry) |
| Create an object from his class name. | |
| void | registerClass (const std::string &className, IClassable *(*creator)(), const std::string &typeidCheck) throw (ERegistry) |
| Register your class for future Instanciation. | |
Private Types | |
| typedef std::hash_map< std::string, CClassNode > | TClassMap |
Static Private Member Functions | |
| void | init () |
| Inits the ClassRegistry (especially RegistredClasses). | |
Static Private Attributes | |
| TClassMap * | RegistredClasses = NULL |
|
|
Definition at line 108 of file class_registry.h. Referenced by init(). |
|
|
check if the object has been correctly registered. Must be used for debug only, and Must compile with RTTI.
Definition at line 91 of file class_registry.cpp. References NLMISC::IClassable::getClassName(), init(), and RegistredClasses.
00092 {
00093 init();
00094
00095 TClassMap::iterator it;
00096 it=RegistredClasses->find(obj->getClassName());
00097 if(it==RegistredClasses->end())
00098 return false;
00099
00100 if( it->second.TypeIdCheck != string(typeid(*obj).name()) )
00101 return false;
00102
00103 return true;
00104 }
|
|
|
Create an object from his class name.
Definition at line 51 of file class_registry.cpp. References nlassert.
00052 {
00053 init();
00054
00055 TClassMap::iterator it;
00056
00057 it=RegistredClasses->find(className);
00058
00059 if(it==RegistredClasses->end())
00060 return NULL;
00061 else
00062 {
00063 IClassable *ptr;
00064 ptr=it->second.Creator();
00065 #ifdef NL_DEBUG
00066 nlassert(CClassRegistry::checkObject(ptr));
00067 #endif
00068 return ptr;
00069 }
00070
00071 }
|
|
|
Inits the ClassRegistry (especially RegistredClasses).
Definition at line 43 of file class_registry.cpp. References RegistredClasses, and TClassMap. Referenced by checkObject().
00044 {
00045 if (RegistredClasses == NULL)
00046 RegistredClasses = new TClassMap;
00047 }
|
|
||||||||||||||||
|
Register your class for future Instanciation.
Definition at line 74 of file class_registry.cpp. References NLMISC::CClassRegistry::CClassNode::Creator, nlstop, and NLMISC::CClassRegistry::CClassNode::TypeIdCheck.
00075 {
00076 init();
00077
00078 CClassNode node;
00079 node.Creator=creator;
00080 node.TypeIdCheck= typeidCheck;
00081 std::pair<TClassMap::iterator, bool> result;
00082 result = RegistredClasses->insert(TClassMap::value_type(className, node));
00083 if(!result.second)
00084 {
00085 nlstop;
00086 throw ERegisteredClass();
00087 }
00088 }
|
|
|
Definition at line 39 of file class_registry.cpp. Referenced by checkObject(), and init(). |
1.3.6