示例#1
0
/// Unregister a type.
///
/// Note that this should only be called by the static type release functions (i.e. Entity::ReleaseStaticType()).
///
/// @param[in] pType  Type to unregister.  References to the parent type and the type template will be released as well.
///
/// @see Register()
void GameObjectType::Unregister( const GameObjectType* pType )
{
    HELIUM_ASSERT( pType );

    // Unregister all child types first.
    const Composite* pDerived = pType->m_FirstDerived;
    while( pDerived )
    {
        HELIUM_ASSERT( pDerived->GetReflectionType() == Reflect::ReflectionTypes::GameObjectType );
        const GameObjectType* pDerivedGameObjectType = static_cast< const GameObjectType* >( pDerived );
        const Composite* pNextDerived = pDerived->m_NextSibling;

        RELEASE_STATIC_TYPE_CALLBACK* pReleaseStaticType = pDerivedGameObjectType->m_pReleaseStaticTypeCallback;
        HELIUM_ASSERT( pReleaseStaticType );
        pReleaseStaticType();

        pDerived = pNextDerived;
    }

    // Remove this type from all type registries.
    Reflect::Registry* pRegistry = Reflect::Registry::GetInstance();
    HELIUM_ASSERT( pRegistry );
    pRegistry->UnregisterType( pType );

    HELIUM_ASSERT( sm_pLookupMap );
    HELIUM_VERIFY( sm_pLookupMap->Remove( pType->GetName() ) );
}