bool CObject::ResolveIDs(CODB& oDB) { m_poClass = oDB.Id2Ptr(m_poClass); // remap the atom list CVectorAtom aoAtoms; for (auto const &itAtom : m_aoAtoms) { // replace the surrogate with the real pointer aoAtoms.push_back( oDB.Id2Ptr(itAtom) ); } // for (auto const &itAtom : m_aoAtoms) m_aoAtoms.swap(aoAtoms); // remap the child-reasons-map // // DO NOT TRY TO REMAP THE TRUE MAP IN ONE STEP USING THE ITERATOR !! // because this will be an unsure operation. The map is a "unique-map" // during remapping some duplicate key may appear: // the "surrogate-key" will be replaced by the true pointer, this // translates a long value to a pointer value = 32bit int -> 32bit int CMapChildren moChildren; for (CMapChildren::iterator itChild=m_moChildren.begin(); itChild!=moChildren.end(); ++itChild) { // remap the list of reasons CListReason* ploReasons = new CListReason; for (auto const &itReason : *itChild->second) { ploReasons->insert( oDB.Id2Ptr(itReason) ); } // for (auto const &itReason : *itChild->second) // delete it->second because it was allocated while loading delete itChild->second; itChild->second = 0; // append the remapped child with his remapped (link-)reasons // to the temporary map moChildren[oDB.Id2Ptr(itChild->first)] = ploReasons; } // for (CMapChildren::iterator itChild=m_moChildren.begin(); ... // assign the temporary child-reasons-map to the true one m_moChildren = moChildren; inherited::ResolveIDs(oDB); return true; } // bool CObject::ResolveIDs(CODB& oDB)
bool CRoot::Validate(CODB& roODatabase) { if ( m_lid != -1) { return true; } m_lid = roODatabase.IdValidate(this); TimeStampUpdate(); return (m_lid != -1); } // CRoot::Validate(CODB& oODatabase)
int main (int argc, char * const argv[]) { CODB odb; // CClass* poClassAdr = odb.NewClass (_TEXT("Person")); CClass* poClassWrd = odb.NewClass (_TEXT("Word")); for (int n=0; n < 40; n++) { CObject* poObject = odb.NewObject(_TEXT("Wort"), poClassWrd); poObject->AtomAdd( odb.Add(new CAtom(_TEXT("en"), _TEXT("Cinema"))) ); poObject->AtomAdd( odb.Add(new CAtom(_TEXT("de"), _TEXT("Kino"))) ); } odb.SaveXML("wb-40.odb"); return 0; } // int main (int argc, char * const argv[])
bool CClass::ResolveIDs(CODB& oDB) { m_poOMAL = oDB.Id2Ptr(m_poOMAL); inherited::ResolveIDs(oDB); return true; } // bool CClass::ResolveIDs(CODB& oDB)