Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6642 in orxonox.OLD


Ignore:
Timestamp:
Jan 21, 2006, 2:32:04 PM (18 years ago)
Author:
bensch
Message:

trunk: ResourceManager now has Vectors instead of Lists

Location:
trunk/src/util/loading
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/resource_manager.cc

    r6641 r6642  
    7979  while (!this->imageDirs.empty())
    8080  {
    81     delete[] this->imageDirs.front();
    82     this->imageDirs.pop_front();
     81    delete[] this->imageDirs.back();
     82    this->imageDirs.pop_back();
    8383  }
    8484
     
    203203  {
    204204    // check if the Directory has been added before
    205     std::list<char*>::const_iterator imageDir;
     205    std::vector<char*>::const_iterator imageDir;
    206206    for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    207207    {
     
    467467    else
    468468    {
    469       std::list<char*>::iterator imageDir;
     469      std::vector<char*>::iterator imageDir;
    470470      for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    471471      {
     
    611611      PRINTF(4)("Resource %s safely removed.\n", resource->name);
    612612      delete[] resource->name;
    613       std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
     613      std::vector<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
    614614      this->resourceList.erase(resourceIT);
    615615      delete resource;
     
    630630bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
    631631{
    632   std::list<Resource*>::iterator resource, pre;
    633   pre = --this->resourceList.end();
    634632  unsigned int removeCount;
    635633  for (unsigned int round = 0; round < 3; round++)
    636634  {
     635    int index = this->resourceList.size() - 1;
    637636    removeCount = 0;
    638     while (pre != resourceList.end())
    639     {
    640       resource = pre;
    641       pre--;
    642       if ((*resource)->prio <= prio)
     637    while (index >= 0)
     638    {
     639      if (this->resourceList[index]->prio <= prio)
    643640      {
    644         if ((*resource)->count == 0)
    645           unload((*resource), prio);
     641        if (this->resourceList[index]->count == 0)
     642          unload(this->resourceList[index], prio);
    646643        else
    647644        {
    648645          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
    649                     (*resource)->name, (*resource)->count);
     646                    this->resourceList[index]->name, this->resourceList[index]->count);
    650647          removeCount++;
    651648        }
    652649      }
     650      index--;
    653651    }
    654652    if (removeCount == 0) break;
     
    669667    void* param1, void* param2, void* param3) const
    670668{
    671   std::list<Resource*>::const_iterator resource;
     669  std::vector<Resource*>::const_iterator resource;
    672670  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
    673671  {
     
    751749{
    752750  //  Resource* enumRes = resourceList->enumerate();
    753   std::list<Resource*>::const_iterator resource;
     751  std::vector<Resource*>::const_iterator resource;
    754752  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
    755753    if (pointer == (*resource)->pointer)
     
    967965  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
    968966  PRINT(0)(" List of Image-Directories: ");
    969   std::list<char*>::const_iterator imageDir;
     967  std::vector<char*>::const_iterator imageDir;
    970968  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    971969    PRINT(0)("%s ", (*imageDir));
     
    973971
    974972  PRINT(0)("List of all stored Resources:\n");
    975   std::list<Resource*>::const_iterator resource;
     973  std::vector<Resource*>::const_iterator resource;
    976974  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
    977975
  • trunk/src/util/loading/resource_manager.h

    r6640 r6642  
    2323
    2424
    25 #include <list>
     25#include <vector>
    2626
    2727//! An eumerator for different fileTypes the resourceManager supports
     
    154154
    155155  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    156   std::list<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
    157   std::list<char*>         imageDirs;          //!< A list of directories in which images are stored.
     156  std::vector<char*>       imageDirs;          //!< A list of directories in which images are stored.
    158157
     158  std::vector<Resource*>   resourceList;       //!< The List of Resources, that has already been loaded.
    159159};
    160160
Note: See TracChangeset for help on using the changeset viewer.