Changeset 9845 in orxonox.OLD for branches/new_class_id/src/lib
- Timestamp:
- Sep 27, 2006, 11:13:17 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util/loading
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/resource.cc
r9843 r9845 137 137 ////////////// 138 138 Type::Type(const std::string& typeName) 139 : _ id(-1), _typeName(typeName)139 : _typeName(typeName) 140 140 { 141 141 ResourceManager::getInstance()->registerType(this); … … 151 151 { 152 152 this->_storedResources.push_back(resource); 153 154 153 } 155 154 … … 175 174 } 176 175 177 178 void Type::setID(int id) 179 { 180 this->_id = id; 176 void Type::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel) 177 { 178 std::vector<Resources::StorePointer*>::iterator it; 179 for (it = this->_storedResources.begin(); it != this->_storedResources.end(); ++it) 180 if((*it)->keepLevel() < keepLevel) 181 { 182 delete (*it); 183 this->_storedResources.erase(it); 184 it = this->_storedResources.begin(); 185 } 181 186 } 182 187 … … 184 189 void Type::debug() const 185 190 { 186 PRINT(0)(" ResourceType '%s' with ID %d stores %d Resources\n", this->_typeName.c_str(), this->_id, this->_storedResources.size());191 PRINT(0)(" ResourceType '%s' stores %d Resources\n", this->_typeName.c_str(), this->_storedResources.size()); 187 192 PRINT(0)(" Paths:\n"); 188 193 for (unsigned int i = 0; i < this->_resourcePaths.size(); ++i) -
branches/new_class_id/src/lib/util/loading/resource.h
r9844 r9845 29 29 KeepLevel(const std::string& keepLevelName); 30 30 31 bool operator==(const KeepLevel& keepLevel) const { return this->_keepLevel == keepLevel._keepLevel; }; 32 bool operator!=(const KeepLevel& keepLevel) const { return this->_keepLevel != keepLevel._keepLevel; }; 33 bool operator<=(const KeepLevel& keepLevel) const { return this->_keepLevel <= keepLevel._keepLevel; }; 34 bool operator<(const KeepLevel& keepLevel) const { return this->_keepLevel < keepLevel._keepLevel; }; 35 31 36 /** @returns the KeepLevel */ 32 37 unsigned int keepLevel() const { return _keepLevel; }; … … 41 46 public: 42 47 StorePointer(const std::string& loadString, const Resources::KeepLevel& keeplevel); 48 //! Virtual Destructor, that removes the Stored information-pointer. 49 virtual ~StorePointer() {}; 50 43 51 /** @returns the LoadString this resource was loaded with */ 44 52 const std::string& loadString() const { return _loadString; }; … … 73 81 const std::string& storedClassName() const { return _typeName; }; 74 82 /** @returns the ID of the Type != ClassID */ 75 int id() const { return _id; };76 83 /** @returns the type-specific paths this Resource searches in. */ 77 84 const std::vector<Directory>& resourcePaths() const { return _resourcePaths; }; … … 83 90 virtual void createFromString(const std::string& loadString) = 0; 84 91 85 void setID(int id); 92 void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel); 93 86 94 void addResource(Resources::StorePointer* resource); 87 95 … … 94 102 Type(const Type& type) {}; 95 103 private: 96 int _id; //!< ID of the Type in over all of the Types.97 104 const std::string _typeName; //!< Name of the Type. (Name of the Resource this loads.) 98 105 std::vector<Directory> _resourcePaths; //!< The Paths to search for files in this type -
branches/new_class_id/src/lib/util/loading/resource_manager.cc
r9836 r9845 60 60 void ResourceManager::registerType(Resources::Type* type) 61 61 { 62 if(type->id() == -1) 63 { 64 type->setID(this->_resourceTypes.size()); 65 this->_resourceTypes.push_back(type); 66 PRINTF(5)("ResourceType '%s' with ID %d added\n", type->storedClassName().c_str(), type->id()); 67 } 62 this->_resourceTypes.push_back(type); 63 PRINTF(5)("ResourceType '%s' added\n", type->storedClassName().c_str()); 68 64 } 69 65 … … 74 70 { 75 71 this->_resourceTypes.erase(it); 76 PRINTF(5)("ResourceType '%s' with ID %d removed\n", type->storedClassName().c_str(), type->id());72 PRINTF(5)("ResourceType '%s' removed\n", type->storedClassName().c_str()); 77 73 } 78 74 } … … 149 145 150 146 147 void ResourceManager::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel) 148 { 149 std::vector<Resources::Type*>::const_iterator it; 150 for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it) 151 { 152 (*it)->unloadAllBelowKeepLevel(keepLevel); 153 } 154 } 155 156 151 157 /** 152 158 * @brief outputs debug information about the ResourceManager -
branches/new_class_id/src/lib/util/loading/resource_manager.h
r9836 r9845 46 46 std::string prependAbsoluteMainPath(const std::string& fileName); 47 47 48 bool unloadAllByKeepLevel(const Resources::KeepLevel& keepLevel);48 void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel); 49 49 50 50 void debug() const;
Note: See TracChangeset
for help on using the changeset viewer.