Changeset 9784 in orxonox.OLD for branches/new_class_id/src/lib/util/loading
- Timestamp:
- Sep 22, 2006, 12:19:51 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
r9783 r9784 24 24 * standard constructor 25 25 */ 26 Resource::Resource (const std::string& fileName) 26 Resource::Resource () 27 : _pointer(NULL) 27 28 { 28 29 this->registerObject(this, Resource::_objectList); … … 40 41 41 42 43 Resource::Pointer* Resource::acquireResource(Resource::Type& resourceType, const std::string& loadString) 44 { 45 if(resourceType.id() == -1) 46 { 47 Resource::_resourceTypes.push_back(&resourceType); 48 resourceType.setID(Resource::_resourceTypes.size()); 49 } 50 const Resource::Type* const type = Resource::_resourceTypes[resourceType.id()]; 51 52 for (unsigned int i = 0; i < type->storedResources().size(); ++i) 53 if (type->storedResources()[i]->_pointer->loadString() == loadString) 54 return type->storedResources()[i]->_pointer; 55 56 return NULL; 57 } 58 42 59 43 60 -
branches/new_class_id/src/lib/util/loading/resource.h
r9783 r9784 37 37 void addExtension(const std::string& extension); 38 38 39 void addResourcePath(const std::string& path); 40 void addResourceSubPath(const std::string& subPath); 41 42 /// Retrieve Functions 39 43 const ClassID& storedClassID() const { return _classID; }; 40 44 int id() const { return _id; }; 41 45 const std::vector<std::string>& resourcePaths() const { return _resourcePaths; }; 42 46 const std::vector<std::string>& resourceSubPaths() const { return _resourceSubPaths; }; 47 const std::vector<Resource*>& storedResources() const { return _storedResources; }; 43 48 44 49 void setID(int id); … … 50 55 std::vector<std::string> _resourceSubPaths; 51 56 std::vector<std::string> _fileExtensions; 57 58 std::vector<Resource*> _storedResources; 52 59 }; 53 60 54 class Pointer {}; 61 class Pointer 62 { 63 public: 64 Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel); 65 const std::string& loadString() const { return _loadString; }; 66 const Resource::KeepLevel& keepLevel() const { return _keepLevel; }; 67 68 private: 69 std::string _loadString; //!< An identifier, to match when loading a File. 70 Resource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so none else will delete this) 71 }; 55 72 56 73 57 74 public: 58 Resource( const std::string& fileName);75 Resource(); 59 76 virtual ~Resource(); 60 77 61 bool loadResource(std::string& fileName, Resource::Pointer* ptr);62 78 virtual bool reload(); 63 79 virtual bool unload(); 64 80 81 protected: 82 Resource::Pointer* acquireResource(Resource::Type& resourceType, const std::string& loadString); 83 84 private: 85 Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. 65 86 66 87 67 private: 68 std::string _loadString; //!< An identifier, to match when loading a File. 69 std::string _fileName; 70 MultiType _parameters[3]; //!< The Parameters given to this Resource. 71 Resource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so noone else will delete this) 72 73 74 static std::vector<Resource::Type> _resourceTypes; 88 static std::vector<Resource::Type*> _resourceTypes; 75 89 76 90 //! GLOBALS
Note: See TracChangeset
for help on using the changeset viewer.