hkRenamedClassNameRegistry.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:3k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /* 
  2.  * 
  3.  * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
  4.  * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
  5.  * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
  6.  * 
  7.  */
  8. #ifndef HK_SERIALIZE_RENAMED_CLASSNAME_REGISTRY_H
  9. #define HK_SERIALIZE_RENAMED_CLASSNAME_REGISTRY_H
  10. #include <Common/Base/Reflection/Registry/hkClassNameRegistry.h>
  11. #include <Common/Serialize/Version/hkVersionRegistry.h>
  12. class hkRenamedClassNameRegistry : public hkClassNameRegistry
  13. {
  14. public:
  15. /// This takes an existing reg and just queries into it
  16. hkRenamedClassNameRegistry( const hkVersionRegistry::ClassRename* renames = HK_NULL, const hkClassNameRegistry* originalRegistry = HK_NULL )
  17. : m_originalRegistry(HK_NULL)
  18. {
  19. setOriginalRegistry( originalRegistry );
  20. registerRenames( renames );
  21. }
  22. ~hkRenamedClassNameRegistry()
  23. {
  24. if( m_originalRegistry )
  25. {
  26. m_originalRegistry->removeReference();
  27. }
  28. }
  29. virtual const char* getName() const
  30. {
  31. return m_originalRegistry ? m_originalRegistry->getName() : HK_NULL;
  32. }
  33. virtual void getClasses( hkArray<const hkClass*>& classes ) const
  34. {
  35. if( m_originalRegistry )
  36. {
  37. m_originalRegistry->getClasses(classes);
  38. }
  39. }
  40. virtual const hkClass* getClassByName( const char* oldname ) const
  41. {
  42. const char* name = m_renames.getWithDefault( oldname, oldname );
  43. return m_originalRegistry ? m_originalRegistry->getClassByName(name) : HK_NULL;
  44. }
  45. void setOriginalRegistry( const hkClassNameRegistry* originalRegistry )
  46. {
  47. if( originalRegistry )
  48. {
  49. originalRegistry->addReference();
  50. }
  51. if( m_originalRegistry )
  52. {
  53. m_originalRegistry->removeReference();
  54. }
  55. m_originalRegistry = originalRegistry;
  56. }
  57. const char* getRename( const char* oldName ) const
  58. {
  59. return m_renames.getWithDefault(oldName, HK_NULL);
  60. }
  61. void registerRenames( const hkVersionRegistry::ClassRename* renames )
  62. {
  63. if( renames )
  64. {
  65. for( const hkVersionRegistry::ClassRename* r = renames; r->oldName != HK_NULL; ++r )
  66. {
  67. m_renames.insert( r->oldName, r->newName );
  68. }
  69. }
  70. }
  71. hkStringMap<const char*> m_renames;
  72. const hkClassNameRegistry* m_originalRegistry;
  73. };
  74. #endif // HK_SERIALIZE_RENAMED_CLASSNAME_REGISTRY_H
  75. /*
  76. * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20090216)
  77. * Confidential Information of Havok.  (C) Copyright 1999-2009
  78. * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
  79. * Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership
  80. * rights, and intellectual property rights in the Havok software remain in
  81. * Havok and/or its suppliers.
  82. * Use of this software for evaluation purposes is subject to and indicates
  83. * acceptance of the End User licence Agreement for this product. A copy of
  84. * the license is included with this software and is also available at www.havok.com/tryhavok.
  85. */