Changeset 9850 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Sep 28, 2006, 12:16:37 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util/loading
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/resource.cc
r9847 r9850 24 24 namespace Resources 25 25 { 26 //! Define an ObjectList for the Resources 26 27 ObjectListDefinition(Resource); 27 28 28 29 29 30 /** 30 * standard constructor 31 */ 31 * @brief standard constructor 32 * @param type the Type this resource belongs to. 33 */ 32 34 Resource::Resource (Type* type) 33 35 : _pointer(NULL), _type(type) … … 37 39 38 40 /** 39 * standard deconstructor41 * @brief standard deconstructor 40 42 */ 41 43 Resource::~Resource () … … 44 46 } 45 47 46 48 /** 49 * @brief Locates a File inside of the Resources Paths and returns the appended path. 50 * 51 * @param fileName the Name of the file to look for. 52 * @returns the Name of the File prepended with the PAth it is in, if found, empty String ("") otherwise. 53 * 54 * This Function searches in (ordered): 55 * 1. mainGlobalPath (from ResourceManger) 56 * 2. all of the global Paths (from ResourceManger) 57 * 3. all of the Resources Paths (from Resources::Type) 58 * 59 * in each of these directory, first "./" is searched, and afterwards all of the subDirs (from Resources::Type) are searched. 60 * 61 * @todo finish it!! 62 */ 47 63 std::string Resource::locateFile(const std::string& fileName) const 48 64 { … … 83 99 84 100 85 101 /** 102 * @param loadString the Identifier of the Resource. 103 * @returns a Store-Pointer to the Resource if found, NULL otherwise 104 */ 86 105 StorePointer* Resource::acquireResource(const std::string& loadString) 87 106 { … … 97 116 } 98 117 99 118 /** 119 * @brief registers a StorePointer to a Resource's Type. 120 * @param pointer the StorePointer to register. 121 */ 100 122 void Resource::addResource(StorePointer* pointer) 101 123 { 124 assert(pointer != NULL); 102 125 this->_type->addResource(pointer); 103 126 } … … 111 134 //// KEEPLEVEL //// 112 135 /////////////////// 136 /** 137 * @brief constructor of a KeepLevel. 138 * @param keepLevelName the Name of the KeepLevel. Must be one Name of the defined Names in the ResourceManager. 139 * 140 * @note the Name is transformed into an Integer for fast interpretation. 141 */ 113 142 KeepLevel::KeepLevel(const std::string& keepLevelName) 114 143 { … … 116 145 } 117 146 147 /** 148 * @returns the name of the KeepLevel. 149 */ 118 150 const std::string& KeepLevel::name() const 119 151 { … … 126 158 //// STORE POINTER //// 127 159 /////////////////////// 160 /** 161 * @brief allocates a StorePointer. 162 * @param loadString An identifier String that is unique between all resources of this type. 163 * @param keepLevel the KeepLevel at wich to keep this resource. 164 */ 128 165 StorePointer::StorePointer(const std::string& loadString, const KeepLevel& keeplevel) 129 166 : _loadString(loadString), _keepLevel(keeplevel) … … 136 173 //// TYPE //// 137 174 ////////////// 175 /** 176 * @brief allocates a Type. 177 * @param typeName the Name of the Type to be stored in this Container. 178 */ 138 179 Type::Type(const std::string& typeName) 139 180 : _typeName(typeName) … … 143 184 } 144 185 186 //! Destructs a Type. 145 187 Type::~Type() 146 188 { … … 148 190 } 149 191 192 /** 193 * @brief adds a Resource to this Resource's type. 194 * @param resource the Resource to add. 195 */ 150 196 void Type::addResource(StorePointer* resource) 151 197 { … … 153 199 } 154 200 201 /** 202 * @brief adds a Path to the Type's resource-paths. 203 * @param path the path-name to add. 204 */ 155 205 bool Type::addResourcePath(const std::string& path) 156 206 { … … 164 214 } 165 215 216 /** 217 * @brief Adds a SubPath to the Type's resource-subpaths. 218 * @param subPath the subpath to add. 219 */ 166 220 bool Type::addResourceSubPath(const std::string& subPath) 167 221 { … … 174 228 } 175 229 230 /** 231 * @brief Unloads all Resources below a certain Level. 232 * @param keepLevel the KeepLevel at what to remove the Resources from. 233 */ 176 234 void Type::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel) 177 235 { … … 179 237 for (it = this->_storedResources.begin(); it != this->_storedResources.end(); ++it) 180 238 if((*it)->keepLevel() < keepLevel && (*it)->last()) 181 { 182 delete (*it); 183 this->_storedResources.erase(it); 184 it = this->_storedResources.begin(); 185 } 186 } 187 188 239 { 240 delete (*it); 241 this->_storedResources.erase(it); 242 it = this->_storedResources.begin(); 243 } 244 } 245 246 /** 247 * @brief print out some nice Debug information in a beatifully designed style 248 */ 189 249 void Type::debug() const 190 250 { -
branches/new_class_id/src/lib/util/loading/resource.h
r9848 r9850 14 14 #include "filesys/directory.h" 15 15 16 //! A Namespace Resources and ResourceHandling is defined in. 16 17 namespace Resources 17 18 { … … 29 30 KeepLevel(const std::string& keepLevelName); 30 31 32 //! Compare equality 31 33 inline bool operator==(const KeepLevel& keepLevel) const { return this->_keepLevel == keepLevel._keepLevel; }; 34 //! Compares inequality 32 35 inline bool operator!=(const KeepLevel& keepLevel) const { return this->_keepLevel != keepLevel._keepLevel; }; 36 //! Compares less/equal than 33 37 inline bool operator<=(const KeepLevel& keepLevel) const { return this->_keepLevel <= keepLevel._keepLevel; }; 38 //! Compares less than 34 39 inline bool operator<(const KeepLevel& keepLevel) const { return this->_keepLevel < keepLevel._keepLevel; }; 35 40 36 /** @returns the KeepLevel */41 /** @returns the KeepLevel as a number */ 37 42 inline unsigned int keepLevel() const { return _keepLevel; }; 38 43 const std::string& name() const; … … 85 90 public: 86 91 virtual ~Type(); 87 /** @returns true if the names match @param resourceName the Name to compare. @brief compare the Type with a Name */88 bool operator==(const std::string& resourceName) const { return this->_typeName == resourceName; };92 /** @returns true if the names match @param typeName the Name to compare. @brief compare the Type with a Name */ 93 bool operator==(const std::string& typeName) const { return this->_typeName == typeName; }; 89 94 90 95 void addExtension(const std::string& extension);
Note: See TracChangeset
for help on using the changeset viewer.