Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9799 in orxonox.OLD for branches/new_class_id/src/lib/util/loading


Ignore:
Timestamp:
Sep 24, 2006, 12:06:35 PM (18 years ago)
Author:
bensch
Message:

ResourceManager now cleans up too

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

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/new_resource_manager.cc

    r9798 r9799  
    6868}
    6969
     70void NewResourceManager::unregisterType(Resources::Type* type)
     71{
     72  std::vector<Resources::Type*>::iterator it = std::find (this->_resourceTypes.begin(), this->_resourceTypes.end(), type);
     73  if (it != this->_resourceTypes.end())
     74  {
     75    this->_resourceTypes.erase(it);
     76    PRINTF(5)("ResourceType '%s' with ID %d removed\n", type->storedClassName().c_str(), type->id());
     77  }
     78}
     79
     80
    7081void NewResourceManager::setMainGlobalPath(const Directory& directory)
    7182{
     
    127138}
    128139
    129 const std::string& NewResourceManager::getKeepLevelID(unsigned int keepLevelID) const
     140const std::string& NewResourceManager::getKeepLevelName(unsigned int keepLevelID) const
    130141{
    131142  assert(keepLevelID < this->_keepLevelNames.size());
  • branches/new_class_id/src/lib/util/loading/new_resource_manager.h

    r9798 r9799  
    2525  bool addResourceSubPath(const std::string& resourceName, const std::string& pathName);
    2626  void registerType(Resources::Type* type);
     27  void unregisterType(Resources::Type* type);
    2728
    2829  unsigned int addKeepLevelName(const std::string& keepLevelName);
    2930  unsigned int getKeepLevelID(const std::string& keepLevelName) const;
    30   const std::string& getKeepLevelID(unsigned int keepLevelID) const;
     31  const std::string& getKeepLevelName(unsigned int keepLevelID) const;
    3132
    3233  const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9798 r9799  
    4444std::string NewResource::locateFile(const std::string& fileName) const
    4545{
    46   if (File(fileName).exists())
    47     return fileName;
    48   else if ((NewResourceManager::getInstance()->mainGlobalPath() + File(fileName)).exists() )
     46  if ((NewResourceManager::getInstance()->mainGlobalPath() + File(fileName)).exists() )
    4947    return (NewResourceManager::getInstance()->mainGlobalPath() + File(fileName)).name();
    5048
     
    5654    return locatedFile;
    5755  }
     56
     57  if (File(fileName).exists())
     58    return fileName;
    5859
    5960  return (NewResourceManager::getInstance()->mainGlobalPath() + File(fileName)).name();
     
    114115}
    115116
     117const std::string& Resources::KeepLevel::name() const
     118{
     119  return NewResourceManager::getInstance()->getKeepLevelName(this->_keepLevel);
     120}
     121
    116122
    117123
     
    134140  NewResourceManager::getInstance()->registerType(this);
    135141  PRINTF(4)("Created ResourceType '%s'\n", typeName.c_str());
     142}
     143
     144Resources::Type::~Type()
     145{
     146  NewResourceManager::getInstance()->unregisterType(this);
    136147}
    137148
     
    176187  for (unsigned int i = 0; i < this->_resourcePaths.size(); ++i)
    177188    PRINT(0)("    %s\n", this->_resourcePaths[i].name().c_str());
    178   PRINT(0)("  Sub-Paths:\n");
     189  PRINT(0)("  Sub-Paths:");
    179190  for (unsigned int i = 0; i < this->_resourceSubPaths.size(); ++i)
    180     PRINT(0)("    %s\n", this->_resourceSubPaths[i].name().c_str());
     191    PRINT(0)(" '%s'", this->_resourceSubPaths[i].name().c_str());
     192  PRINT(0)("\n");
    181193
    182194}
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9798 r9799  
    2323
    2424    unsigned int keepLevel() const { return _keepLevel; };
     25    const std::string& name() const;
    2526  private:
    2627    unsigned int                        _keepLevel;
     
    4344  public:
    4445    Type(const std::string& typeName);
     46    ~Type();
    4547    bool operator==(const std::string& resourceName) const { return this->_typeName == resourceName; };
    4648
Note: See TracChangeset for help on using the changeset viewer.