register a class using any name
This commit is contained in:
@@ -11,17 +11,19 @@ struct XNode;
|
|||||||
typedef Actor* (*CreateActorFn)(const CString& sDir, const XNode* pNode);
|
typedef Actor* (*CreateActorFn)(const CString& sDir, const XNode* pNode);
|
||||||
|
|
||||||
// Each Actor class should have a REGISTER_ACTOR_CLASS in its CPP file.
|
// Each Actor class should have a REGISTER_ACTOR_CLASS in its CPP file.
|
||||||
#define REGISTER_ACTOR_CLASS( className ) \
|
#define REGISTER_ACTOR_CLASS_WITH_NAME( className, externalClassName ) \
|
||||||
Actor* Create##className(const CString& sDir, const XNode* pNode) { \
|
Actor* Create##className(const CString& sDir, const XNode* pNode) { \
|
||||||
className *pRet = new className; \
|
className *pRet = new className; \
|
||||||
pRet->LoadFromNode(sDir, pNode); \
|
pRet->LoadFromNode(sDir, pNode); \
|
||||||
return pRet; } \
|
return pRet; } \
|
||||||
class Register##className { \
|
class Register##className { \
|
||||||
public: \
|
public: \
|
||||||
Register##className() { ActorUtil::Register(#className,Create##className); } \
|
Register##className() { ActorUtil::Register(#externalClassName,Create##className); } \
|
||||||
}; \
|
}; \
|
||||||
static Register##className register##className;
|
static Register##className register##className;
|
||||||
|
|
||||||
|
#define REGISTER_ACTOR_CLASS( className ) REGISTER_ACTOR_CLASS_WITH_NAME( className, className )
|
||||||
|
|
||||||
namespace ActorUtil
|
namespace ActorUtil
|
||||||
{
|
{
|
||||||
// Every screen should register its class at program initialization.
|
// Every screen should register its class at program initialization.
|
||||||
|
|||||||
Reference in New Issue
Block a user