Changeset 9854 in orxonox.OLD for branches/new_class_id/src/lib/util/loading
- Timestamp:
- Sep 28, 2006, 10:17:56 AM (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
r9851 r9854 134 134 //// KEEPLEVEL //// 135 135 /////////////////// 136 137 //! Constructs a default KeepLevel as Set in the ResourceManager via setDefaultKeepLevel. 138 KeepLevel::KeepLevel() 139 { 140 this->_keepLevel = ResourceManager::getInstance()->defaultKeepLevel().keepLevel(); 141 } 142 /** 143 * @param keepLevel the level to set. 144 */ 145 KeepLevel::KeepLevel(unsigned int keepLevel) 146 { 147 _keepLevel = keepLevel; 148 } 149 136 150 /** 137 151 * @brief constructor of a KeepLevel. -
branches/new_class_id/src/lib/util/loading/resource.h
r9852 r9854 26 26 { 27 27 public: 28 /** @param keepLevel the level to set. */29 inline KeepLevel(unsigned int keepLevel) { _keepLevel = keepLevel; };28 KeepLevel(); 29 KeepLevel(unsigned int keepLevel); 30 30 KeepLevel(const std::string& keepLevelName); 31 31 … … 93 93 bool operator==(const std::string& typeName) const { return this->_typeName == typeName; }; 94 94 95 //////////////////// 96 //// EXTENSIONS //// 95 97 void addExtension(const std::string& extension); 96 98 99 /////////////// 100 //// PATHS //// 97 101 bool addResourcePath(const std::string& path); 98 102 bool addResourceSubPath(const std::string& subPath); … … 109 113 const std::vector<Resources::StorePointer*>& storedResources() const { return _storedResources; }; 110 114 111 virtual void createFromString(const std::string& loadString) = 0; 112 115 /////////////////////////////// 116 //// LOADING AND UNLOADING //// 117 virtual void createFromString(const std::string& loadString, const KeepLevel& keepLevel = KeepLevel()) = 0; 113 118 void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel); 114 119 120 /////////////////// 121 //// INTERNALS //// 115 122 void addResource(Resources::StorePointer* resource); 116 123 124 /////////////// 125 //// DEBUG //// 117 126 void debug() const; 118 127 … … 144 153 tType(const std::string& typeName) : Type(typeName) {}; 145 154 /** @param loadString the String to load a Resource with @brief tries to create a Resource of Type T with a loadString */ 146 virtual void createFromString(const std::string& loadString ) { T::createFromString(loadString); }155 virtual void createFromString(const std::string& loadString, const KeepLevel& keepLevel = KeepLevel()) { T::createFromString(loadString, keepLevel); } 147 156 }; 148 157 -
branches/new_class_id/src/lib/util/loading/resource_manager.cc
r9853 r9854 35 35 */ 36 36 ResourceManager::ResourceManager () 37 : _defaultKeepLevel(0) 37 38 { 38 39 this->registerObject(this, ResourceManager::_objectList); … … 47 48 ResourceManager::~ResourceManager () 48 49 { 49 // deleting the Resources-List50 //this->unloadAllByPriority(RP_GAME);51 52 // if (!this->resourceList.empty())53 // PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());54 55 50 ResourceManager::_singletonRef = NULL; 56 51 } … … 195 190 * @param loadString the loadString to load in the Type. 196 191 */ 197 void ResourceManager::loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString )192 void ResourceManager::loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString, const KeepLevel& keepLevel) 198 193 { 199 194 std::vector<Resources::Type*>::const_iterator it; … … 202 197 if (*(*it) == resourceTypeName) 203 198 { 204 (*it)->createFromString(loadString );199 (*it)->createFromString(loadString, keepLevel); 205 200 /// TODO check if the resource was allocated!! 206 201 return ; -
branches/new_class_id/src/lib/util/loading/resource_manager.h
r9851 r9854 17 17 ObjectListDeclaration(ResourceManager); 18 18 public: 19 /////////////////////// 20 //// INSTANZIATION //// 19 21 /** @returns a Pointer to the only object of this Class */ 20 22 inline static ResourceManager* getInstance() { if (!_singletonRef) _singletonRef = new ResourceManager(); return _singletonRef; }; … … 22 24 inline static void deleteInstance() { if (_singletonRef) delete _singletonRef; }; 23 25 24 26 //////////////////////// 27 //// RESOURCE PATHS //// 25 28 void setMainGlobalPath(const Directory& directory); 26 29 void addGlobalPath(const Directory& directory); … … 31 34 void unregisterType(Resources::Type* type); 32 35 33 unsigned int addKeepLevelName(const std::string& keepLevelName);34 unsigned int getKeepLevelID(const std::string& keepLevelName) const;35 const std::string& getKeepLevelName(unsigned int keepLevelID) const;36 37 /** @returns the Types of Resources */38 const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };39 36 /** @returns the main global search Path */ 40 37 const Directory& mainGlobalPath() const { return _mainGlobalPath; }; … … 42 39 const std::vector<Directory>& globalPaths() const { return _globalPaths; }; 43 40 41 //////////////////// 42 //// KEEPLEVELS //// 43 unsigned int addKeepLevelName(const std::string& keepLevelName); 44 unsigned int getKeepLevelID(const std::string& keepLevelName) const; 45 const std::string& getKeepLevelName(unsigned int keepLevelID) const; 46 void setDefaultKeepLevel(const KeepLevel& keepLevel) { this->_defaultKeepLevel = keepLevel; }; 47 const KeepLevel& defaultKeepLevel() const { return this->_defaultKeepLevel; }; 48 49 ////////////////////////// 50 //// GENERAL QUERIES //// 51 /** @returns the Types of Resources */ 52 const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; }; 44 53 45 54 bool checkFileInMainPath(const File& fileInside); 46 55 std::string prependAbsoluteMainPath(const std::string& fileName); 47 56 57 //////////////////////////////////////// 58 //// RESOURCE LOADING AND UNLOADING //// 59 void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString, const KeepLevel& keepLevel = KeepLevel()); 60 void loadFromLoadStringHACK(const std::string& resourceTypeName, const std::string& loadString) { this->loadFromLoadString(resourceTypeName, loadString); }; 61 48 62 void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel); 49 63 void unloadAllBelowKeepLevelINT(unsigned int level) { unloadAllBelowKeepLevel(level); }; 50 void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString);51 64 65 /////////////// 66 //// DEBUG //// 52 67 void debug() const; 53 68 54 // utility functions for handling files in and around the data-directory55 static std::string getFullName(const std::string& fileName);56 static bool isInDataDir(const std::string& fileName);57 69 private: 58 70 ResourceManager(); … … 66 78 67 79 std::vector<Resources::Type*> _resourceTypes; //!< A Vector of all the stored ResourceTypes @see Resources::Type 80 68 81 std::vector<std::string> _keepLevelNames; //!< Names of KeepLevels @see Resources::KeepLevel 82 KeepLevel _defaultKeepLevel; //!< The default KeepLevel. 69 83 }; 70 84
Note: See TracChangeset
for help on using the changeset viewer.