BOOL CObjects::Remove(CArrayBlockObjectPtr* papcKilled) { int i; int iNumElements; CBaseObject* pcKilled; CBaseObject* pcContainer; //No embedded objects should be in the list papcKilled. iNumElements = papcKilled->NumElements(); if (iNumElements == 0) { return TRUE; } for (i = 0; i < iNumElements; i++) { pcKilled = *papcKilled->Get(i); if (pcKilled->IsEmbedded()) { pcContainer = pcKilled->GetEmbeddingContainer(); gcLogger.Error2(__METHOD__, " Object of class [", pcKilled->ClassName(), "] is marked for killing but is embedded in object with index [", IndexToString(pcContainer->GetOI()),"] of class [", pcContainer->ClassName(), "].", NULL); return FALSE; } else if (!pcKilled->IsAllocatedInObjects()) { gcLogger.Error2(__METHOD__, " Object of class [", pcKilled->ClassName(), "] is marked for killing but is not allocated in Objects [0x", PointerToString(this),"].", NULL); return FALSE; } } for (i = 0; i < iNumElements; i++) { pcKilled = *papcKilled->Get(i); pcKilled->RemoveAllPointerTosDontKill(); } KillDontFreeObjects(papcKilled); FreeObjects(papcKilled); return TRUE; }
void CEmbeddedObject::LogNotExpectedToBeEmbedded(char* szMethod) { CBaseObject* pcContainer; pcContainer = GetEmbeddingContainer(); gcLogger.Error2(szMethod, " Cannot be called on embedded object of class [", ClassName(), "] with embedding index [", IndexToString(pcContainer->GetOI()),"] and embedding class [", pcContainer->ClassName(), "].", NULL); }
CBaseObject* CObjectAllocator::Add(char* szClassName, char* szObjectName, OIndex oiForced, OIndex* poiExisting) { CBaseObject* pvObject; CBaseObject* pvExisting; BOOL bResult; pvObject = mpcObjects->Allocate(szClassName); if (!pvObject) { gcLogger.Error2(__METHOD__, " Cannot add object named [", szObjectName, "] class [", szClassName, "].", NULL); return NULL; } if (!pvObject->IsNamed()) { gcLogger.Error2(__METHOD__, " Cannot add object named [", szObjectName, "] the class ", pvObject->ClassName(), " is not derived from NamedObject.", NULL); pvObject->Kill(); return NULL; } pvExisting = mpcObjects->GetFromMemory(szObjectName); if (pvExisting == NULL) { bResult = mpcObjects->AddWithIDAndName(pvObject, szObjectName, oiForced); if (!bResult) { pvObject->Kill(); return NULL; } LOG_OBJECT_ALLOCATION(pvObject); *poiExisting = INVALID_O_INDEX; return pvObject; } else { *poiExisting = pvExisting->GetOI(); pvObject = ReplaceExisting(pvExisting, pvObject, szObjectName, oiForced); LOG_OBJECT_ALLOCATION(pvObject); return pvObject; } }