MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / removeModuleDefinition

Method removeModuleDefinition

engine/source/module/moduleManager.cc:1787–1879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785//-----------------------------------------------------------------------------
1786
1787bool ModuleManager::removeModuleDefinition( ModuleDefinition* pModuleDefinition )
1788{
1789 // Sanity!
1790 AssertFatal( pModuleDefinition != NULL, "Cannot remove module definition if it is NULL." );
1791
1792 // Fetch module Id.
1793 StringTableEntry moduleId = pModuleDefinition->getModuleId();
1794
1795 // Is the module definition registered with this module manager?
1796 if ( pModuleDefinition->getModuleManager() != this )
1797 {
1798 // No, so warn.
1799 Con::warnf("Cannot remove module definition '%s' as it is not registered with this module manager.", moduleId );
1800 return false;
1801 }
1802
1803 // Is the module definition loaded?
1804 if ( pModuleDefinition->getLoadCount() > 0 )
1805 {
1806 // No, so warn.
1807 Con::warnf("Cannot remove module definition '%s' as it is loaded.", moduleId );
1808 return false;
1809 }
1810
1811 // Find module Id.
1812 typeModuleIdDatabaseHash::iterator moduleItr = mModuleIdDatabase.find( moduleId );
1813
1814 // Sanity!
1815 AssertFatal( moduleItr != mModuleIdDatabase.end(), "Failed to find module definition." );
1816
1817 // Fetch modules definitions.
1818 ModuleDefinitionEntry* pDefinitions = moduleItr->value;
1819
1820 // Fetch version Id.
1821 const U32 versionId = pModuleDefinition->getVersionId();
1822
1823 // Iterate module definitions.
1824 for ( ModuleDefinitionEntry::iterator definitionItr = pDefinitions->begin(); definitionItr != pDefinitions->end(); ++definitionItr )
1825 {
1826 // Skip if this isn't the version Id we're searching for.
1827 if ( versionId != (*definitionItr)->getVersionId() )
1828 continue;
1829
1830 // Remove definition entry.
1831 pDefinitions->erase( definitionItr );
1832
1833 // Remove notification before we delete it.
1834 clearNotify( pModuleDefinition );
1835
1836 // Delete module definition.
1837 pModuleDefinition->deleteObject();
1838
1839 // Are there any modules left for this module Id?
1840 if ( findModuleId( moduleId ) == NULL )
1841 {
1842 bool moduleIdFound = false;
1843
1844 // No, so remove from groups.

Callers 1

Calls 10

warnfFunction · 0.85
getModuleIdMethod · 0.80
getModuleManagerMethod · 0.80
getLoadCountMethod · 0.80
getVersionIdMethod · 0.80
deleteObjectMethod · 0.80
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected