uint32 CSharedParamsManager::GenerateCRC32(const char *pName) { // Check lock. if(VerifyUnlocked()) { // Check name. if(pName) { // Check to see if name has already been registered. uint32 crc32 = gEnv->pSystem->GetCrc32Gen()->GetCRC32(pName); TNameMap::const_iterator iName = m_names.find(crc32); if(iName == m_names.end()) { // Register name. m_names.insert(TNameMap::value_type(crc32, pName)); return crc32; } else if(iName->second == pName) { return crc32; } } } return 0; }
void CSharedParamsManager::RemoveByType(const CSharedParamsTypeInfo &typeInfo) { // Check lock. if(VerifyUnlocked()) { // Remove records by type. for(TRecordMap::iterator iRecord = m_records.begin(), iEndRecord = m_records.end(); iRecord != iEndRecord; ) { const ISharedParamsPtr &pSharedParams = iRecord->second; if(pSharedParams->GetTypeInfo() == typeInfo) { TRecordMap::iterator iEraseRecord = iRecord; ++ iRecord; m_records.erase(iEraseRecord); } else { ++ iRecord; } } } }
ISharedParamsConstPtr CSharedParamsManager::Get(const char *pName) const { // Check lock. if(VerifyUnlocked()) { // Check name. if(pName) { uint32 crc32 = gEnv->pSystem->GetCrc32Gen()->GetCRC32(pName); TNameMap::const_iterator iName = m_names.find(crc32); if(iName != m_names.end() && iName->second == pName) { // Get record. return Get(crc32); } } } return ISharedParamsConstPtr(); }
ISharedParamsConstPtr CSharedParamsManager::Get(uint32 crc32) const { // Check lock. if(VerifyUnlocked()) { // Get record. TRecordMap::const_iterator iRecord = m_records.find(crc32); if(iRecord != m_records.end()) { return iRecord->second; } } return ISharedParamsConstPtr(); }
void CSharedParamsManager::Remove(uint32 crc32) { // Check lock. if(VerifyUnlocked()) { // Get record. TRecordMap::iterator iRecord = m_records.find(crc32); if(iRecord != m_records.end()) { // Remove record. m_records.erase(iRecord); } } }
ISharedParamsConstPtr CSharedParamsManager::Register(uint32 crc32, const ISharedParams &sharedParams) { // Check lock. if(VerifyUnlocked()) { // Check name has been registered. if(m_names.find(crc32) != m_names.end()) { // Are we running the editor? If so don't register shared parameters. if(gEnv->IsEditor()) { return ISharedParamsConstPtr(sharedParams.Clone()); } else { // Check to see if record already exists. if(m_records.find(crc32) == m_records.end()) { // Clone shared parameters. ISharedParamsPtr pSharedParams(sharedParams.Clone()); if(pSharedParams) { // Store record. m_records.insert(TRecordMap::value_type(crc32, pSharedParams)); m_sizeOfSharedParams += pSharedParams->GetTypeInfo().GetSize(); return pSharedParams; } } } } } return ISharedParamsConstPtr(); }
ISharedParamsConstPtr CSharedParamsManager::Register(const char *pName, const ISharedParams &sharedParams) { // Check lock. if(VerifyUnlocked()) { // Generate 32 bit crc. uint32 crc32 = GenerateCRC32(pName); if(crc32) { // Register shared parameters. return Register(crc32, sharedParams); } } return ISharedParamsConstPtr(); }
void CSharedParamsManager::Remove(const char *pName) { // Check lock. if(VerifyUnlocked()) { // Check name. if(pName) { uint32 crc32 = gEnv->pSystem->GetCrc32Gen()->GetCRC32(pName); TNameMap::const_iterator iName = m_names.find(crc32); if(iName != m_names.end() && iName->second == pName) { // Remove record. Remove(crc32); } } } }
void CSharedParamsManager::Remove(const char* pName) { // Check lock. if (VerifyUnlocked()) { // Check name. if (pName) { uint32 crc32 = CCrc32::Compute(pName); TNameMap::const_iterator iName = m_names.find(crc32); if (iName != m_names.end() && iName->second == pName) { // Remove record. Remove(crc32); } } } }