From: <cn...@us...> - 2009-10-25 20:29:00
|
Revision: 580 http://hgengine.svn.sourceforge.net/hgengine/?rev=580&view=rev Author: cnlohr Date: 2009-10-25 20:28:46 +0000 (Sun, 25 Oct 2009) Log Message: ----------- remove wonky RTTI Type String, and make the Instace Watching feature handle it correct.y Modified Paths: -------------- Mercury2/src/MercuryNode.cpp Mercury2/src/MercuryNode.h Mercury2/src/ModuleManager.cpp Mercury2/src/ModuleManager.h Modified: Mercury2/src/MercuryNode.cpp =================================================================== --- Mercury2/src/MercuryNode.cpp 2009-10-22 19:52:50 UTC (rev 579) +++ Mercury2/src/MercuryNode.cpp 2009-10-25 20:28:46 UTC (rev 580) @@ -16,7 +16,7 @@ REGISTER_NODE_TYPE(MercuryNode); MercuryNode::MercuryNode() - :Type( 0 ), m_parent(NULL), m_prevSibling(NULL), + :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false), m_useAlphaPath(false), m_culled(false), m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 ) @@ -27,8 +27,7 @@ { #ifdef INSTANCE_WATCH - if( Type ) - DEL_INSTANCE(this, Type); + DEL_INSTANCE(this); #endif m_parent = NULL; Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-10-22 19:52:50 UTC (rev 579) +++ Mercury2/src/MercuryNode.h 2009-10-25 20:28:46 UTC (rev 580) @@ -21,7 +21,7 @@ { if (n==NULL) return NULL; return dynamic_cast<const x*>(n); } \ static x* Cast(MercuryNode* n) \ { if (n==NULL) return NULL; return dynamic_cast<x*>(n); } \ -virtual const char * GetType() { if( !Type ) Type = #x; return #x; } +virtual const char * GetType() { return #x; } /* #define GENRTTI(x) static bool IsMyType(const MercuryNode* n) \ @@ -117,8 +117,6 @@ const MercuryMatrix & GetModelViewMatrix() const { return m_pModelViewMatrix[g_iViewportID]; } inline unsigned short GetPasses() const { return m_iPasses; } - - const char * Type; protected: std::list< MercuryNode* > m_children; //These nodes are unique, not instanced MercuryNode* m_parent; @@ -167,6 +165,8 @@ std::list< std::pair< MString, Callback0R<MercuryNode*> > > m_factoryCallbacks; }; +#define NODEFACTORY NodeFactory::GetInstance() + static InstanceCounter<NodeFactory> NFcounter("NodeFactory"); #define REGISTER_NODE_TYPE(class)\ Modified: Mercury2/src/ModuleManager.cpp =================================================================== --- Mercury2/src/ModuleManager.cpp 2009-10-22 19:52:50 UTC (rev 579) +++ Mercury2/src/ModuleManager.cpp 2009-10-25 20:28:46 UTC (rev 580) @@ -134,10 +134,12 @@ void ModuleManager::RegisterInstance( void * instance, const char * sClass ) { m_hAllInstances[sClass].insert( instance ); + m_pAllInstanceTypes[instance] = sClass; } -void ModuleManager::UnregisterInstance( void * instance, const char * sClass ) +void ModuleManager::UnregisterInstance( void * instance ) { + const char * sClass = m_pAllInstanceTypes[instance]; std::set< void * > & s = m_hAllInstances[sClass]; std::set< void * >::iterator i = s.find( instance ); Modified: Mercury2/src/ModuleManager.h =================================================================== --- Mercury2/src/ModuleManager.h 2009-10-22 19:52:50 UTC (rev 579) +++ Mercury2/src/ModuleManager.h 2009-10-25 20:28:46 UTC (rev 580) @@ -4,7 +4,11 @@ #include <MercuryUtil.h> #include <MercuryHash.h> #include <MercuryThreads.h> + +#ifdef INSTANCE_WATCH #include <set> +#include <map> +#endif /* This is the module loader mechanism. This allows for run-time loading of new modules. Eventually, it will allow for run-time re-loading of modules. @@ -24,7 +28,7 @@ void ReloadModule( const MString & sClass ); void RegisterInstance( void * instance, const char * sClass ); - void UnregisterInstance( void * instance, const char * sClass ); + void UnregisterInstance( void * instance ); #endif private: @@ -33,6 +37,7 @@ #ifdef INSTANCE_WATCH MHash< std::set< void * > > m_hAllInstances; + std::map< void *, const char * > m_pAllInstanceTypes; #endif MHash< void * > m_hAllHandles; @@ -46,7 +51,7 @@ #ifdef INSTANCE_WATCH #define NEW_INSTANCE( node, t ) ModuleManager::GetInstance().RegisterInstance( node, t ); -#define DEL_INSTANCE( node, t ) ModuleManager::GetInstance().UnregisterInstance( node, t ); +#define DEL_INSTANCE( node ) ModuleManager::GetInstance().UnregisterInstance( node ); #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |