//--------------------------------------------------------------------- void PageManager::destroyContentCollection(PageContentCollection* coll) { PageContentCollectionFactory* fact = getContentCollectionFactory(coll->getType()); if (fact) fact->destroyInstance(coll); else OGRE_DELETE coll; // normally a safe fallback }
//--------------------------------------------------------------------- bool Page::prepareImpl(StreamSerialiser& stream, PageData* dataToPopulate) { // Now do the real loading if (!stream.readChunkBegin(CHUNK_ID, CHUNK_VERSION, "Page")) return false; // pageID check (we should know the ID we're expecting) uint32 storedID; stream.read(&storedID); if (mID != storedID) { LogManager::getSingleton().stream() << "Error: Tried to populate Page ID " << mID << " with data corresponding to page ID " << storedID; stream.undoReadChunk(CHUNK_ID); return false; } PageManager* mgr = getManager(); while(stream.peekNextChunkID() == CHUNK_CONTENTCOLLECTION_DECLARATION_ID) { const StreamSerialiser::Chunk* collChunk = stream.readChunkBegin(); String factoryName; stream.read(&factoryName); stream.readChunkEnd(CHUNK_CONTENTCOLLECTION_DECLARATION_ID); // Supported type? PageContentCollectionFactory* collFact = mgr->getContentCollectionFactory(factoryName); if (collFact) { PageContentCollection* collInst = collFact->createInstance(); if (collInst->prepare(stream)) // read type-specific data { dataToPopulate->collectionsToAdd.push_back(collInst); } else { LogManager::getSingleton().stream() << "Error preparing PageContentCollection type: " << factoryName << " in " << *this; collFact->destroyInstance(collInst); } } else { LogManager::getSingleton().stream() << "Unsupported PageContentCollection type: " << factoryName << " in " << *this; // skip stream.readChunkEnd(collChunk->id); } } mModified = false; return true; }
//--------------------------------------------------------------------- PageContentCollection* PageManager::createContentCollection(const String& typeName) { PageContentCollectionFactory* fact = getContentCollectionFactory(typeName); if (!fact) OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, typeName + " is not the name of a valid PageContentCollectionFactory", "PageManager::createContentCollection"); return fact->createInstance(); }