Changeset 5308 in orxonox.OLD for trunk/src/util
- Timestamp:
- Oct 8, 2005, 12:32:52 AM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/resource_manager.cc
r5307 r5308 251 251 { 252 252 PRINTF(4)("not loading cached resource %s\n", tmpResource->name); 253 // printf("adding %s count: %d\n", tmpResource->pointer->getName(), tmpResource->count);254 253 tmpResource->count++; 255 254 if(tmpResource->prio < prio) … … 409 408 } 410 409 else 411 unload(tmpResource, prio);410 return unload(tmpResource, prio); 412 411 } 413 412 … … 416 415 * @param resource: The resource to unloade 417 416 * @param prio the PriorityLevel to unload this resource 417 * @returns true on success, false otherwise. 418 418 */ 419 419 bool ResourceManager::unload(Resource* resource, ResourcePriority prio) … … 421 421 if (resource == NULL) 422 422 return false; 423 // printf("removing %s count: %d\n", resource->pointer->getName(), resource->count);424 423 if (resource->count > 0) 425 424 resource->count--; … … 427 426 if (resource->prio <= prio) 428 427 { 429 if (resource->count <= 0)428 if (resource->count == 0) 430 429 { 431 430 // deleting the Resource … … 480 479 481 480 /** 482 * 481 * unloads all alocated Memory of Resources with a pririty lower than prio 483 482 * @param prio The priority to delete 484 483 */ … … 486 485 { 487 486 tIterator<Resource>* iterator = resourceList->getIterator(); 488 Resource* enumRes = iterator-> firstElement();487 Resource* enumRes = iterator->lastElement(); 489 488 while (enumRes) 490 489 { … … 496 495 enumRes->name, enumRes->count); 497 496 //enumRes = resourceList->nextElement(); 498 enumRes = iterator-> nextElement();497 enumRes = iterator->prevElement(); 499 498 } 500 499 delete iterator; -
trunk/src/util/resource_manager.h
r5306 r5308 66 66 { 67 67 BaseObject* pointer; //!< Pointer to the Resource. 68 intcount; //!< How many times this Resource has been loaded.68 unsigned int count; //!< How many times this Resource has been loaded. 69 69 70 70 char* name; //!< Name of the Resource. … … 85 85 //! The ResourceManager is a class, that decides if a file/resource should be loaded 86 86 /** 87 If a file/resource was already loaded the resourceManager will 88 return a void pointer to the desired resource. 89 Otherwise it will instruct the corresponding resource-loader to load, 90 and receive the pointer to it. 91 92 It does it by looking, if a desired file has already been loaded. 93 */ 87 * If a file/resource was already loaded the resourceManager will 88 * return a pointer to the desired resource. 89 * Otherwise it will instruct the corresponding resource-loader to load, 90 * and receive the pointer to it. 91 * 92 * It does it by looking, if a desired file has already been loaded. 93 * There is also the possibility to check for some variables 94 */ 94 95 class ResourceManager : public BaseObject 95 96 { … … 101 102 bool setDataDir(const char* dataDir); 102 103 /** @returns the Name of the data directory */ 103 inline const char* getDataDir() const { return this->dataDir;}104 inline const char* getDataDir() const { return this->dataDir; }; 104 105 105 106 bool checkDataDir(const char* fileInside); … … 135 136 static ResourceManager* singletonRef; //!< singleton Reference 136 137 138 char* dataDir; //!< The Data Directory, where all relevant Data is stored. 137 139 tList<Resource>* resourceList; //!< The List of Resources, that has already been loaded. 138 char* dataDir; //!< The Data Directory, where all relevant Data is stored.139 140 tList<char>* imageDirs; //!< A list of directories in which images are stored. 140 141
Note: See TracChangeset
for help on using the changeset viewer.