ManaPlus
|
Typedefs | |
typedef Resource *(* | loader) (SDL_RWops *rw, const std::string &name) |
typedef Resource *(&) | generator(const void *const data) |
typedef std::map< std::string, Resource * > | Resources |
typedef Resources::iterator | ResourceIterator |
typedef Resources::const_iterator | ResourceCIterator |
Functions | |
void | deleteResourceManager () |
void | cleanUp (Resource *const res) |
void | cleanProtected () |
bool | cleanOrphans (const bool always) |
void | logResource (const Resource *const res) |
void | logResources (const std::string &msg) |
void | clearDeleted (const bool full) |
bool | addResource (const std::string &idPath, Resource *const resource) |
Resource * | getFromCache (const std::string &filename, const int variant) |
bool | isInCache (const std::string &idPath) |
Resource * | getTempResource (const std::string &idPath) |
Resource * | getFromCache (const std::string &idPath) |
Resource * | get (const std::string &idPath, generator fun, const void *const data) |
void | release (Resource *const res) |
void | moveToDeleted (Resource *const res) |
void | decRefDelete (Resource *const res) |
void | deleteInstance () |
void | scheduleDelete (SDL_Surface *const surface) |
void | clearScheduled () |
void | clearCache () |
int | calcMemoryLocal () |
int | calcMemoryChilds (const int level) |
int | calcMemory (const int level) |
int | size () |
Variables | |
std::set< SDL_Surface * > | deletedSurfaces |
Resources | mResources |
Resources | mOrphanedResources |
std::set< Resource * > | mDeletedResources |
time_t | mOldestOrphan = 0 |
bool | mDestruction = false |
Definition at line 39 of file resourcefunctiontypes.h.
typedef Resource*(* ResourceManager::loader) (SDL_RWops *rw, const std::string &name) |
Definition at line 37 of file resourcefunctiontypes.h.
typedef Resources::const_iterator ResourceManager::ResourceCIterator |
Definition at line 38 of file resourcetypes.h.
typedef Resources::iterator ResourceManager::ResourceIterator |
Definition at line 37 of file resourcetypes.h.
typedef std::map<std::string, Resource*> ResourceManager::Resources |
Definition at line 36 of file resourcetypes.h.
bool ResourceManager::addResource | ( | const std::string & | idPath, |
Resource *const | resource | ||
) |
Definition at line 360 of file resourcemanager.cpp.
References Resource::incRef(), Logger::log(), logger, Resource::mIdPath, and mResources.
Referenced by AtlasManager::injectToResources().
int ResourceManager::calcMemory | ( | const int | level | ) |
Definition at line 681 of file resourcemanager.cpp.
References calcMemoryChilds(), calcMemoryLocal(), and MemoryManager::printMemory().
Referenced by MemoryManager::printAllMemory().
int ResourceManager::calcMemoryChilds | ( | const int | level | ) |
Definition at line 661 of file resourcemanager.cpp.
References FOR_EACH, mDeletedResources, mOrphanedResources, and mResources.
Referenced by calcMemory().
int ResourceManager::calcMemoryLocal | ( | ) |
Definition at line 651 of file resourcemanager.cpp.
References deletedSurfaces, FOR_EACH, and MemoryManager::getSurfaceSize().
Referenced by calcMemory(), and SubImage::calcMemoryLocal().
bool ResourceManager::cleanOrphans | ( | const bool | always | ) |
Definition at line 227 of file resourcemanager.cpp.
References logResource(), mOldestOrphan, mOrphanedResources, and Resource::mTimeStamp.
Referenced by cleanUp(), clearCache(), deleteInstance(), main(), and Gui::slowLogic().
void ResourceManager::cleanProtected | ( | ) |
Definition at line 204 of file resourcemanager.cpp.
References Resource::decRef(), Resource::mProtected, and mResources.
Referenced by Game::changeMap(), clearCache(), and deleteInstance().
void ResourceManager::cleanUp | ( | Resource *const | res | ) |
Definition at line 183 of file resourcemanager.cpp.
References cleanOrphans(), Logger::log(), logger, Resource::mIdPath, and Resource::mRefCount.
Referenced by deleteResourceManager().
void ResourceManager::clearCache | ( | ) |
Definition at line 644 of file resourcemanager.cpp.
References cleanOrphans(), and cleanProtected().
Referenced by Client::unloadData().
void ResourceManager::clearDeleted | ( | const bool | full | ) |
Definition at line 321 of file resourcemanager.cpp.
References Logger::log1(), logger, logResource(), and mDeletedResources.
Referenced by deleteResourceManager(), and AtlasResource::~AtlasResource().
void ResourceManager::clearScheduled | ( | ) |
Definition at line 635 of file resourcemanager.cpp.
References BLOCK_END, BLOCK_START, deletedSurfaces, FOR_EACH, and MSDL_FreeSurface.
Referenced by deleteResourceManager(), and Gui::logic().
void ResourceManager::decRefDelete | ( | Resource *const | res | ) |
Definition at line 560 of file resourcemanager.cpp.
References Resource::decRef(), logResource(), Resource::mIdPath, mOrphanedResources, Resource::mRefCount, and mResources.
Referenced by SoundManager::close(), and Desktop::setBestFittingWallpaper().
void ResourceManager::deleteInstance | ( | ) |
Deletes the class instance if it exists.
Definition at line 590 of file resourcemanager.cpp.
References cleanOrphans(), cleanProtected(), deleteResourceManager(), Logger::log(), Logger::log1(), logger, Resource::mIdPath, Resource::mRefCount, mResources, reportAlways, and Catch::toString().
Referenced by Client::gameClear().
void ResourceManager::deleteResourceManager | ( | ) |
Cleans up remaining resources, warning about resources that were still referenced.
Definition at line 68 of file resourcemanager.cpp.
References cleanUp(), clearDeleted(), clearScheduled(), Logger::log(), logger, mDestruction, mOrphanedResources, mResources, reportAlways, and Catch::toString().
Referenced by deleteInstance().
Resource * ResourceManager::get | ( | const std::string & | idPath, |
generator | fun, | ||
const void *const | data | ||
) |
Creates a resource and adds it to the resource map.
idPath | The resource identifier path. |
fun | A function for generating the resource. |
data | Extra parameters for the generator. |
NULL
if the resource could not be generated. Definition at line 428 of file resourcemanager.cpp.
References data, getFromCache(), Resource::incRef(), Logger::log(), logger, Resource::mIdPath, mResources, and reportAlways.
Referenced by Loader::getAtlas(), Loader::getEmptyAtlas(), Loader::getImage(), Loader::getImageSet(), Loader::getMusic(), Loader::getRescaled(), Loader::getShader(), Loader::getShaderProgram(), Loader::getSoundEffect(), Loader::getSprite(), Loader::getSubImage(), Loader::getSubImageSet(), Loader::getWalkLayer(), and Loader::getXml().
Resource * ResourceManager::getFromCache | ( | const std::string & | filename, |
const int | variant | ||
) |
Definition at line 378 of file resourcemanager.cpp.
Referenced by AnimatedSprite::delayedLoad(), and get().
Resource * ResourceManager::getFromCache | ( | const std::string & | idPath | ) |
Definition at line 404 of file resourcemanager.cpp.
References Resource::incRef(), mOrphanedResources, and mResources.
Resource * ResourceManager::getTempResource | ( | const std::string & | idPath | ) |
Definition at line 392 of file resourcemanager.cpp.
References mResources.
Referenced by AtlasManager::loadEmptyImages(), and AtlasManager::loadImages().
bool ResourceManager::isInCache | ( | const std::string & | idPath | ) |
void ResourceManager::logResource | ( | const Resource *const | res | ) |
Definition at line 271 of file resourcemanager.cpp.
References Logger::log(), logger, Resource::mIdPath, Resource::mRefCount, Resource::mSource, and Catch::toString().
Referenced by cleanOrphans(), clearDeleted(), decRefDelete(), logResources(), and moveToDeleted().
void ResourceManager::logResources | ( | const std::string & | msg | ) |
Definition at line 300 of file resourcemanager.cpp.
References FOR_EACH, Logger::log(), logger, logResource(), mDeletedResources, mOrphanedResources, mResources, and Actions::msg().
void ResourceManager::moveToDeleted | ( | Resource *const | res | ) |
Move resource to deleted resources list.
Definition at line 526 of file resourcemanager.cpp.
References Resource::decRef(), logResource(), mDeletedResources, Resource::mIdPath, mOrphanedResources, Resource::mRefCount, and mResources.
Referenced by AtlasManager::loadEmptyImages(), AtlasManager::loadImages(), and AtlasManager::moveToDeleted().
void ResourceManager::release | ( | Resource *const | res | ) |
Releases a resource, placing it in the set of orphaned resources.
Definition at line 476 of file resourcemanager.cpp.
References mDeletedResources, mDestruction, Resource::mIdPath, mOldestOrphan, mOrphanedResources, mResources, and Resource::mTimeStamp.
Referenced by Resource::decRef().
void ResourceManager::scheduleDelete | ( | SDL_Surface *const | surface | ) |
Definition at line 630 of file resourcemanager.cpp.
References deletedSurfaces.
int ResourceManager::size | ( | ) |
Definition at line 692 of file resourcemanager.cpp.
References CAST_S32, and mResources.
std::set<SDL_Surface*> ResourceManager::deletedSurfaces |
Definition at line 61 of file resourcemanager.cpp.
Referenced by calcMemoryLocal(), clearScheduled(), and scheduleDelete().
std::set<Resource*> ResourceManager::mDeletedResources |
Definition at line 64 of file resourcemanager.cpp.
Referenced by calcMemoryChilds(), clearDeleted(), logResources(), moveToDeleted(), and release().
bool ResourceManager::mDestruction = false |
Definition at line 66 of file resourcemanager.cpp.
Referenced by deleteResourceManager(), and release().
time_t ResourceManager::mOldestOrphan = 0 |
Definition at line 65 of file resourcemanager.cpp.
Referenced by cleanOrphans(), and release().
Resources ResourceManager::mOrphanedResources |
Definition at line 63 of file resourcemanager.cpp.
Referenced by calcMemoryChilds(), cleanOrphans(), decRefDelete(), deleteResourceManager(), getFromCache(), logResources(), moveToDeleted(), and release().
Resources ResourceManager::mResources |
Definition at line 62 of file resourcemanager.cpp.
Referenced by addResource(), calcMemoryChilds(), cleanProtected(), decRefDelete(), deleteInstance(), deleteResourceManager(), get(), getFromCache(), getTempResource(), isInCache(), logResources(), moveToDeleted(), release(), and size().