Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9851 in orxonox.OLD


Ignore:
Timestamp:
Sep 28, 2006, 12:48:03 AM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: Resources now get Loaded and Unloaded correctly by will alone

Location:
branches/new_class_id/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r9848 r9851  
    5656  SHELL_COMMAND(debug, ResourceManager, debug);
    5757  SHELL_COMMAND(load, ResourceManager, loadFromLoadString);
     58  SHELL_COMMAND(unload, ResourceManager, unloadAllBelowKeepLevelINT);
    5859}
    5960
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9850 r9851  
    165165  StorePointer::StorePointer(const std::string& loadString, const KeepLevel& keeplevel)
    166166      : _loadString(loadString), _keepLevel(keeplevel)
    167   {}
    168 
     167  {
     168    PRINTF(4)("Acquired a Resource with LoadString '%s' and KeepLevel '%s'\n", _loadString.c_str(), _keepLevel.name().c_str());
     169  }
     170
     171  StorePointer::~StorePointer()
     172  {
     173    PRINTF(4)("Deleting Stored Resource '%s' from KeepLevel '%s'\n", _loadString.c_str(), _keepLevel.name().c_str());
     174  };
    169175
    170176
     
    234240  void Type::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel)
    235241  {
    236     std::vector<Resources::StorePointer*>::iterator it;
    237     for (it = this->_storedResources.begin(); it != this->_storedResources.end(); ++it)
    238       if((*it)->keepLevel() < keepLevel && (*it)->last())
    239       {
    240         delete (*it);
    241         this->_storedResources.erase(it);
    242         it = this->_storedResources.begin();
    243       }
     242    std::vector<Resources::StorePointer*>::iterator it, it2;
     243    bool finished = false;
     244
     245    while (!finished)
     246    {
     247      finished = true;
     248      for (it = this->_storedResources.begin(); it != this->_storedResources.end();++it)
     249        if((*it)->keepLevel() < keepLevel && (*it)->last())
     250        {
     251          delete (*it);
     252          this->_storedResources.erase(it);
     253          finished = false;
     254          break;
     255        }
     256    }
    244257  }
    245258
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9850 r9851  
    5555  public:
    5656    //! Virtual Destructor, that removes the Stored information-pointer.
    57     virtual ~StorePointer() {};
     57    virtual ~StorePointer();
    5858
    5959    /** @returns the LoadString this resource was loaded with */
  • branches/new_class_id/src/lib/util/loading/resource_manager.h

    r9848 r9851  
    4747
    4848    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
     49    void unloadAllBelowKeepLevelINT(unsigned int level) { unloadAllBelowKeepLevel(level); };
    4950    void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString);
    5051
Note: See TracChangeset for help on using the changeset viewer.