- Timestamp:
- Sep 22, 2006, 12:19:51 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/importer/resource_texture.cc
r9781 r9784 5 5 6 6 7 ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target) 8 { 9 Resource::Pointer* ptr = this->acquireResource(ResourceTexture::type, imageName + ',' + "TEST"); 7 10 8 ResourceTexture::TextureResourcePointer::TextureResourcePointer(TextureData* data) 9 { 10 this->pointer = new TextureData::Pointer(data); 11 if (ptr) 12 this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr()); 13 else 14 { 15 this->loadImage(imageName, target); 16 } 11 17 } 12 18 13 19 14 20 Resource::Type ResourceTexture::type(Texture::staticClassID()); 21 22 23 24 25 26 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, TextureData* data) 27 : Resource::Pointer(loadString, keepLevel) , pointer(data) 28 { 29 } 30 31 -
branches/new_class_id/src/lib/graphics/importer/resource_texture.h
r9781 r9784 18 18 19 19 private: 20 class TextureResourcePointer 20 class TextureResourcePointer : public Resource::Pointer 21 21 { 22 22 public: 23 TextureResourcePointer(TextureData* data); 23 TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, TextureData* data); 24 inline const TextureData::Pointer& ptr() const { return pointer; } 24 25 private: 25 TextureData::Pointer *pointer;26 TextureData::Pointer pointer; 26 27 }; 27 28 -
branches/new_class_id/src/lib/graphics/importer/texture.h
r9719 r9784 30 30 Texture& operator=(const Texture& texture); 31 31 Texture& operator=(const TextureData::Pointer& textureDataPointer); 32 void acquireData(const TextureData::Pointer& textureDataPointer) { this->data = textureDataPointer; }; 33 const TextureData::Pointer& dataPointer() const { return data; } 32 34 33 35 virtual ~Texture(); -
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.