Ogre::DataStreamPtr OMEFileSystemArchive::open(const Ogre::String& filename, bool readOnly) const { Ogre::String full_path = concatenate_path(mName, filename); // Use filesystem to determine size // (quicker than streaming to the end and back) struct stat tagStat; int ret = stat(full_path.c_str(), &tagStat); assert(ret == 0 && "Problem getting file size" ); (void)ret; // Silence warning // Always open in binary mode // Also, always include reading std::ios::openmode mode = std::ios::in | std::ios::binary; std::istream* baseStream = 0; std::ifstream* roStream = 0; std::fstream* rwStream = 0; if (!readOnly && isReadOnly()) { mode |= std::ios::out; rwStream = OGRE_NEW_T(std::fstream, Ogre::MEMCATEGORY_GENERAL)(); rwStream->open(full_path.c_str(), mode); baseStream = rwStream; } else { roStream = OGRE_NEW_T(std::ifstream, Ogre::MEMCATEGORY_GENERAL)(); roStream->open(full_path.c_str(), mode); baseStream = roStream; } // Should check ensure open succeeded, in case fail for some reason. if (baseStream->fail()) { OGRE_DELETE_T(roStream, basic_ifstream, Ogre::MEMCATEGORY_GENERAL); OGRE_DELETE_T(rwStream, basic_fstream, Ogre::MEMCATEGORY_GENERAL); OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename, "FileSystemArchive::open"); } /// Construct return stream, tell it to delete on destroy Ogre::FileStreamDataStream* stream = 0; if (rwStream) { // use the writeable stream stream = OGRE_NEW Ogre::FileStreamDataStream(filename, rwStream, (size_t)tagStat.st_size, true); } else { // read-only stream Ogre::String newName = mName + ":" + filename; stream = OGRE_NEW Ogre::FileStreamDataStream(newName, roStream, (size_t)tagStat.st_size, true); } return Ogre::DataStreamPtr(stream); }
//----------------------------------------------------------------------- TextureRotator::~TextureRotator(void) { if (mDynRotation) { OGRE_DELETE_T(mDynRotation, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynRotation = 0; } if (mDynRotationSpeed) { OGRE_DELETE_T(mDynRotationSpeed, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynRotationSpeed = 0; } }
void TreeView::removeEventHandlers(void* obj) { ContainerWidget::removeEventHandlers(obj); for(int index = 0; index < TREEVIEW_EVENT_COUNT; ++index) { std::vector<EventHandlerSlot*> updatedList; std::vector<EventHandlerSlot*> listToCleanup; for(std::vector<EventHandlerSlot*>::iterator it = mTreeViewEventHandlers[index].begin(); it != mTreeViewEventHandlers[index].end(); ++it) { if((*it)->getClass() == obj) listToCleanup.push_back((*it)); else updatedList.push_back((*it)); } mTreeViewEventHandlers[index].clear(); for(std::vector<EventHandlerSlot*>::iterator it = updatedList.begin(); it != updatedList.end(); ++it) mTreeViewEventHandlers[index].push_back((*it)); for(std::vector<EventHandlerSlot*>::iterator it = listToCleanup.begin(); it != listToCleanup.end(); ++it) OGRE_DELETE_T((*it),EventHandlerSlot,Ogre::MEMCATEGORY_GENERAL); } }
//--------------------------------------------------------------------- void DefaultWorkQueue::shutdown() { if( !mIsRunning ) return; LogManager::getSingleton().stream() << "DefaultWorkQueue('" << mName << "') shutting down on thread " << #if OGRE_THREAD_SUPPORT OGRE_THREAD_CURRENT_ID #else "main" #endif << "."; mShuttingDown = true; abortAllRequests(); #if OGRE_THREAD_SUPPORT // wake all threads (they should check shutting down as first thing after wait) OGRE_THREAD_NOTIFY_ALL(mRequestCondition); // all our threads should have been woken now, so join for (WorkerThreadList::iterator i = mWorkers.begin(); i != mWorkers.end(); ++i) { (*i)->join(); OGRE_THREAD_DESTROY(*i); } mWorkers.clear(); #endif OGRE_DELETE_T(mWorkerFunc, WorkerFunc, MEMCATEGORY_GENERAL); mWorkerFunc = 0; mIsRunning = false; }
//--------------------------------------------------------------------- void DefaultWorkQueue::shutdown() { LogManager::getSingleton().stream() << "DefaultWorkQueue('" << mName << "') shutting down."; mShuttingDown = true; mTaskGroup.cancel(); abortAllRequests(); // wait until all tasks have finished. mTaskGroup.wait(); #if OGRE_NO_TBB_SCHEDULER == 0 if (mTaskScheduler.is_active()) mTaskScheduler.terminate(); #endif if (mWorkerFunc) { OGRE_DELETE_T(mWorkerFunc, WorkerFunc, MEMCATEGORY_GENERAL); mWorkerFunc = 0; } mIsRunning = false; }
//----------------------------------------------------------------------- void TextureRotator::setRotationSpeed(DynamicAttribute* dynRotationSpeed) { if (mDynRotationSpeed) OGRE_DELETE_T(mDynRotationSpeed, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynRotationSpeed = dynRotationSpeed; }
//----------------------------------------------------------------------- DataStreamPtr FileSystemArchive::open(const String& filename) const { #if (_MSC_VER >= 1400) // std::locale langLocale(""); // std::locale::global(langLocale); setlocale( LC_CTYPE, "" ); #endif String full_path = concatenate_path(mName, filename); // Use filesystem to determine size // (quicker than streaming to the end and back) struct stat tagStat; int ret = stat(full_path.c_str(), &tagStat); assert(ret == 0 && "Problem getting file size" ); // Always open in binary mode std::ifstream *origStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)(); origStream->open(full_path.c_str(), std::ios::in | std::ios::binary); // Should check ensure open succeeded, in case fail for some reason. if (origStream->fail()) { OGRE_DELETE_T(origStream, basic_ifstream, MEMCATEGORY_GENERAL); OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename, "FileSystemArchive::open"); } /// Construct return stream, tell it to delete on destroy FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(filename, origStream, tagStat.st_size, true); return DataStreamPtr(stream); }
//--------------------------------------------------------------------- DataStreamPtr FileSystemArchive::create(const String& filename) const { if (isReadOnly()) { OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Cannot create a file in a read-only archive", "FileSystemArchive::remove"); } String full_path = concatenate_path(mName, filename); // Always open in binary mode // Also, always include reading std::ios::openmode mode = std::ios::out | std::ios::binary; std::fstream* rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)(); rwStream->open(full_path.c_str(), mode); // Should check ensure open succeeded, in case fail for some reason. if (rwStream->fail()) { OGRE_DELETE_T(rwStream, basic_fstream, MEMCATEGORY_GENERAL); OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename, "FileSystemArchive::create"); } /// Construct return stream, tell it to delete on destroy FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(filename, rwStream, 0, true); return DataStreamPtr(stream); }
//--------------------------------------------------------------------- Ogre::DataStreamPtr UnicodeFileSystemArchive::create(const String& _filename) const { if (isReadOnly()) { GOTHOGRE_EXCEPT(_filename << " - Cannot create a file in" << " read-only archive " << getName() << "."); } WString wfullpath = getFullPath(_filename); // Always open in binary mode // Also, always include reading std::ios::openmode mode = std::ios::out | std::ios::binary; std::fstream* rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)(); rwStream->open(wfullpath.c_str(), mode); // Should check ensure open succeeded, in case fail for some reason. if (rwStream->fail()) { OGRE_DELETE_T(rwStream, basic_fstream, MEMCATEGORY_GENERAL); GOTHOGRE_EXCEPT(_filename << " - Cannot create file in" << " archive " << getName() << "."); } GOTHOGRE_INFO(_filename << " - " << "Saving to" << " archive " << getName() << "."); /// Construct return stream, tell it to delete on destroy FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(_filename, rwStream, 0, true); return DataStreamPtr(stream); }
//----------------------------------------------------------------------- DataStreamPtr FileSystemArchive::open(const String& filename, bool readOnly) const { String full_path = concatenate_path(mName, filename); // Use filesystem to determine size // (quicker than streaming to the end and back) struct stat tagStat; stat(full_path.c_str(), &tagStat); // Always open in binary mode std::ifstream *origStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)(); origStream->open(full_path.c_str(), std::ios::in | std::ios::binary); // Should check ensure open succeeded, in case fail for some reason. if (origStream->fail()) { OGRE_DELETE_T(origStream, basic_ifstream, MEMCATEGORY_GENERAL); OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename, "FileSystemArchive::open"); } // Construct return stream, tell it to delete on destroy FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(filename, origStream, tagStat.st_size, true); return DataStreamPtr(stream); }
//----------------------------------------------------------------------- void PhysXActorExtern::setPhysicsShape(PhysicsShapeDesc* physicsShapeDesc) { if (mPhysicsShapeDesc) { OGRE_DELETE_T(mPhysicsShapeDesc, PhysicsShapeDesc, Ogre::MEMCATEGORY_SCENE_OBJECTS); } switch (physicsShapeDesc->mPhysicsShapeType) { case ST_BOX: { PhysicsBoxDesc* physicsBoxDesc = static_cast<PhysicsBoxDesc*>(physicsShapeDesc); mPhysicsShapeDesc = OGRE_NEW_T(PhysicsBoxDesc, Ogre::MEMCATEGORY_SCENE_OBJECTS)(*physicsBoxDesc); } break; case ST_SPHERE: { PhysicsSphereDesc* physicsSphereDesc = static_cast<PhysicsSphereDesc*>(physicsShapeDesc); mPhysicsShapeDesc = OGRE_NEW_T(PhysicsSphereDesc, Ogre::MEMCATEGORY_SCENE_OBJECTS)(*physicsSphereDesc); } break; case ST_CAPSULE: { PhysicsCapsuleDesc* physicsCapsuleDesc = static_cast<PhysicsCapsuleDesc*>(physicsShapeDesc); mPhysicsShapeDesc = OGRE_NEW_T(PhysicsCapsuleDesc, Ogre::MEMCATEGORY_SCENE_OBJECTS)(*physicsCapsuleDesc); } break; } }
//----------------------------------------------------------------------- void TextureRotator::setRotation(DynamicAttribute* dynRotation) { if (mDynRotation) OGRE_DELETE_T(mDynRotation, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynRotation = dynRotation; }
void MeshSerializerTests::tearDown() { // Copy back original file. if (!mMeshFullPath.empty()) { copyFile(mMeshFullPath + ".bak", mMeshFullPath); } if (!mSkeletonFullPath.empty()) { copyFile(mSkeletonFullPath + ".bak", mSkeletonFullPath); } if (!mMesh.isNull()) { mMesh->unload(); mMesh.setNull(); } if (!mOrigMesh.isNull()) { mOrigMesh->unload(); mOrigMesh.setNull(); } if (!mSkeleton.isNull()) { mSkeleton->unload(); mSkeleton.setNull(); } OGRE_DELETE MeshManager::getSingletonPtr(); OGRE_DELETE SkeletonManager::getSingletonPtr(); OGRE_DELETE DefaultHardwareBufferManager::getSingletonPtr(); OGRE_DELETE ArchiveManager::getSingletonPtr(); OGRE_DELETE MaterialManager::getSingletonPtr(); OGRE_DELETE LodStrategyManager::getSingletonPtr(); OGRE_DELETE ResourceGroupManager::getSingletonPtr(); OGRE_DELETE_T(mFSLayer, FileSystemLayer, Ogre::MEMCATEGORY_GENERAL); OGRE_DELETE mLogManager; }
//----------------------------------------------------------------------- void JetAffector::setDynAcceleration(DynamicAttribute* dynAcceleration) { if (mDynAcceleration) OGRE_DELETE_T(mDynAcceleration, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynAcceleration = dynAcceleration; }
//----------------------------------------------------------------------- void TerrainSceneManager::destroyLevelIndexes() { for ( unsigned int i = 0; i < mLevelIndex.size(); i++ ) { OGRE_DELETE_T(mLevelIndex[i], IndexMap, MEMCATEGORY_GEOMETRY); } mLevelIndex.clear(); }
//----------------------------------------------------------------------- JetAffector::~JetAffector (void) { if (!mDynAcceleration) return; OGRE_DELETE_T(mDynAcceleration, DynamicAttribute, Ogre::MEMCATEGORY_SCENE_OBJECTS); mDynAcceleration = 0; }
//----------------------------------------------------------------------- ConfigFile::~ConfigFile() { SettingsBySection::iterator seci, secend; secend = mSettings.end(); for (seci = mSettings.begin(); seci != secend; ++seci) { OGRE_DELETE_T(seci->second, SettingsMultiMap, MEMCATEGORY_GENERAL); } }
//----------------------------------------------------------------------- void Material::clearBestTechniqueList(void) { for (BestTechniquesBySchemeList::iterator i = mBestTechniquesBySchemeList.begin(); i != mBestTechniquesBySchemeList.end(); ++i) { OGRE_DELETE_T(i->second, LodTechniques, MEMCATEGORY_RESOURCE); } mBestTechniquesBySchemeList.clear(); }
//----------------------------------------------------------------------- void ConfigFile::clear(void) { for (SettingsBySection::iterator seci = mSettings.begin(); seci != mSettings.end(); ++seci) { OGRE_DELETE_T(seci->second, SettingsMultiMap, MEMCATEGORY_GENERAL); } mSettings.clear(); }
TreeViewCheckBoxNode::~TreeViewCheckBoxNode() { // Clean up all user defined event handlers. for(int index = 0; index < TREEVIEWCHECKBOXNODE_EVENT_COUNT; ++index) { for(std::vector<EventHandlerSlot*>::iterator it = mTreeViewCheckBoxNodeEventHandlers[index].begin(); it != mTreeViewCheckBoxNodeEventHandlers[index].end(); ++it) OGRE_DELETE_T((*it),EventHandlerSlot,Ogre::MEMCATEGORY_GENERAL); } }
void EventHandlerManager::registerEventHandler(const Ogre::String& handlerName, EventHandlerSlot* function) { std::map<Ogre::String,EventHandlerSlot*>::iterator it = mUserDefinedEventHandlers.find(handlerName); if(it != mUserDefinedEventHandlers.end()) OGRE_DELETE_T(it->second,EventHandlerSlot,Ogre::MEMCATEGORY_GENERAL); mUserDefinedEventHandlers[handlerName] = function; }
//-------------------------------------------------------------------------- void MeshLodTests::tearDown() { if (!mMesh.isNull()) { mMesh->unload(); mMesh.setNull(); } OGRE_DELETE MeshLodGenerator::getSingletonPtr(); OGRE_DELETE Root::getSingletonPtr(); OGRE_DELETE_T(mFSLayer, FileSystemLayer, Ogre::MEMCATEGORY_GENERAL); }
void EventHandlerManager::unregisterEventHandler(const Ogre::String& handlerName) { std::map<Ogre::String,EventHandlerSlot*>::iterator it = mUserDefinedEventHandlers.find(handlerName); if(it != mUserDefinedEventHandlers.end()) { EventHandlerSlot* s = it->second; mUserDefinedEventHandlers.erase(it); OGRE_DELETE_T(s,EventHandlerSlot,Ogre::MEMCATEGORY_GENERAL); } }
//----------------------------------------------------------------------- void ConvexBody::_destroyPool() { OGRE_LOCK_MUTEX(msFreePolygonsMutex); for (PolygonList::iterator i = msFreePolygons.begin(); i != msFreePolygons.end(); ++i) { OGRE_DELETE_T(*i, Polygon, MEMCATEGORY_SCENE_CONTROL); } msFreePolygons.clear(); }
//----------------------------------------------------------------------- void PhysXActorExtern::destroyPhysicsActor(PhysicsActor* physicsActor) { if (!physicsActor) return; if (!PhysXBridge::getSingletonPtr()->getScene()) return; NxActor* nxActor = (static_cast<PhysXActor*>(physicsActor))->nxActor; PhysXBridge::getSingletonPtr()->getScene()->releaseActor(*nxActor); OGRE_DELETE_T(physicsActor, PhysicsActor, Ogre::MEMCATEGORY_SCENE_OBJECTS); // Watch the PhysicsActor type instead of PhysXActor! }
//----------------------------------------------------------------------- QueuedRenderableCollection::~QueuedRenderableCollection(void) { // destroy all the pass map entries (rather than clearing) PassGroupRenderableMap::iterator i, iend; iend = mGrouped.end(); for (i = mGrouped.begin(); i != iend; ++i) { // Free the list associated with this pass OGRE_DELETE_T(i->second, RenderableList, MEMCATEGORY_SCENE_CONTROL); } }
//----------------------------------------------------------------------- void QueuedRenderableCollection::removePassGroup(Pass* p) { PassGroupRenderableMap::iterator i; i = mGrouped.find(p); if (i != mGrouped.end()) { // free memory OGRE_DELETE_T(i->second, RenderableList, MEMCATEGORY_SCENE_CONTROL); // erase from map mGrouped.erase(i); } }
//--------------------------------------------------------------------- void CompositorManager::freePooledTextures(bool onlyIfUnreferenced) { if (onlyIfUnreferenced) { for (TexturesByDef::iterator i = mTexturesByDef.begin(); i != mTexturesByDef.end(); ++i) { TextureList* texList = i->second; for (TextureList::iterator j = texList->begin(); j != texList->end();) { // if the resource system, plus this class, are the only ones to have a reference.. // NOTE: any material references will stop this texture getting freed (e.g. compositor demo) // until this routine is called again after the material no longer references the texture if (j->useCount() == ResourceGroupManager::RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS + 1) { TextureManager::getSingleton().remove((*j)->getHandle()); j = texList->erase(j); } else ++j; } } for (ChainTexturesByDef::iterator i = mChainTexturesByDef.begin(); i != mChainTexturesByDef.end(); ++i) { TextureDefMap& texMap = i->second; for (TextureDefMap::iterator j = texMap.begin(); j != texMap.end();) { const TexturePtr& tex = j->second; if (tex.useCount() == ResourceGroupManager::RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS + 1) { TextureManager::getSingleton().remove(tex->getHandle()); texMap.erase(j++); } else ++j; } } } else { // destroy all for (TexturesByDef::iterator i = mTexturesByDef.begin(); i != mTexturesByDef.end(); ++i) { OGRE_DELETE_T(i->second, TextureList, MEMCATEGORY_GENERAL); } mTexturesByDef.clear(); mChainTexturesByDef.clear(); } }
PCZFrustum::~PCZFrustum() { removeAllCullingPlanes(); // clear out the culling plane reservoir PCPlaneList::iterator pit = mCullingPlaneReservoir.begin(); while ( pit != mCullingPlaneReservoir.end() ) { PCPlane * plane = *pit; // go to next entry pit++; //delete the entry in the list OGRE_DELETE_T(plane, PCPlane, MEMCATEGORY_SCENE_CONTROL); } mCullingPlaneReservoir.clear(); }
void ScriptWriter::addDefinition(ScriptDefinition* d) { for(std::list<ScriptDefinition*>::iterator it = mDefinitions.begin(); it != mDefinitions.end(); ++it) { // Overwrite any ScriptDefinitions that have the same type and ID if(((*it)->getType() == d->getType()) && ((*it)->getID() == d->getID())) { OGRE_DELETE_T((*it),ScriptDefinition,Ogre::MEMCATEGORY_GENERAL); (*it) = d; return; } } mDefinitions.push_back(d); }