- Timestamp:
- Sep 22, 2006, 6:55:52 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/importer/resource_texture.cc
r9786 r9788 6 6 7 7 ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target) 8 : Resource(&ResourceTexture::type)8 : NewResource(&ResourceTexture::type) 9 9 { 10 Resource::Pointer* ptr = this->acquireResource(imageName + ',' + "TEST");10 NewResource::Pointer* ptr = this->acquireResource(imageName + ',' + "TEST"); 11 11 12 12 if (ptr) … … 18 18 { 19 19 printf("NOT FOUNT TEXTURE: %s\n", imageName.c_str()); 20 std::string fileName = this-> Resource::locateFile(imageName);20 std::string fileName = this->NewResource::locateFile(imageName); 21 21 this->Texture::loadImage(fileName, target); 22 this-> Resource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", KeepLevel(), this->Texture::dataPointer()));22 this->NewResource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", KeepLevel(), this->Texture::dataPointer())); 23 23 } 24 24 } 25 25 26 26 27 Resource::Type ResourceTexture::type(Texture::staticClassID());27 NewResource::Type ResourceTexture::type(Texture::staticClassID()); 28 28 29 29 … … 31 31 32 32 33 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, const TextureData::Pointer& data)34 : Resource::Pointer(loadString, keepLevel) , pointer(data)33 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const NewResource::KeepLevel& keepLevel, const TextureData::Pointer& data) 34 : NewResource::Pointer(loadString, keepLevel) , pointer(data) 35 35 {} 36 36 -
branches/new_class_id/src/lib/graphics/importer/resource_texture.h
r9785 r9788 12 12 13 13 14 class ResourceTexture : public Texture, public Resource14 class ResourceTexture : public Texture, public NewResource 15 15 { 16 16 public: … … 19 19 20 20 private: 21 class TextureResourcePointer : public Resource::Pointer21 class TextureResourcePointer : public NewResource::Pointer 22 22 { 23 23 public: 24 TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, const TextureData::Pointer& data);24 TextureResourcePointer(const std::string& loadString, const NewResource::KeepLevel& keepLevel, const TextureData::Pointer& data); 25 25 inline const TextureData::Pointer& ptr() const { return pointer; } 26 26 private: … … 29 29 30 30 private: 31 static Resource::Type type;31 static NewResource::Type type; 32 32 }; 33 33 -
branches/new_class_id/src/lib/util/loading/resource.cc
r9787 r9788 19 19 #include "filesys/file.h" 20 20 21 ObjectListDefinition( Resource);21 ObjectListDefinition(NewResource); 22 22 23 23 24 std::vector< Resource::Type*>Resource::_resourceTypes;24 std::vector<NewResource::Type*> NewResource::_resourceTypes; 25 25 26 26 //! GLOBALS 27 Directory Resource::_mainGlobalPath;28 std::vector<Directory> Resource::_globalPaths;27 Directory NewResource::_mainGlobalPath; 28 std::vector<Directory> NewResource::_globalPaths; 29 29 30 30 … … 32 32 * standard constructor 33 33 */ 34 Resource::Resource (Resource::Type* type)34 NewResource::NewResource (NewResource::Type* type) 35 35 : _pointer(NULL), _type(type) 36 36 { 37 this->registerObject(this, Resource::_objectList);37 this->registerObject(this, NewResource::_objectList); 38 38 39 39 if(this->_type->id() == -1) 40 40 { 41 Resource::_resourceTypes.push_back(this->_type);42 this->_type->setID( Resource::_resourceTypes.size()-1);41 NewResource::_resourceTypes.push_back(this->_type); 42 this->_type->setID(NewResource::_resourceTypes.size()-1); 43 43 } 44 44 … … 48 48 * standard deconstructor 49 49 */ 50 Resource::~Resource ()50 NewResource::~NewResource () 51 51 { 52 52 // delete what has to be deleted here … … 54 54 55 55 56 std::string Resource::locateFile(const std::string& fileName)56 std::string NewResource::locateFile(const std::string& fileName) 57 57 { 58 58 if (File(fileName).exists()) 59 59 return fileName; 60 else if (( Resource::_mainGlobalPath+File(fileName)) . exists() )61 return ( Resource::_mainGlobalPath + File(fileName)).name();60 else if ((NewResource::_mainGlobalPath+File(fileName)) . exists() ) 61 return (NewResource::_mainGlobalPath + File(fileName)).name(); 62 62 63 63 return std::string("/home/bensch/svn/orxonox/data/") + fileName; … … 66 66 67 67 68 Resource::Pointer*Resource::acquireResource(const std::string& loadString)68 NewResource::Pointer* NewResource::acquireResource(const std::string& loadString) 69 69 { 70 //const Resource::Type* const type =Resource::_resourceTypes[this->_type->id()];70 //const NewResource::Type* const type = NewResource::_resourceTypes[this->_type->id()]; 71 71 72 72 for (unsigned int i = 0; i < _type->storedResources().size(); ++i) … … 79 79 } 80 80 81 void Resource::setMainGlobalPath(const Directory& directory)81 void NewResource::setMainGlobalPath(const Directory& directory) 82 82 { 83 Resource::_mainGlobalPath = directory;84 Resource::_mainGlobalPath.open();83 NewResource::_mainGlobalPath = directory; 84 NewResource::_mainGlobalPath.open(); 85 85 } 86 86 87 void Resource::addGlobalPath(const Directory& directory)87 void NewResource::addGlobalPath(const Directory& directory) 88 88 { 89 std::vector<Directory>::const_iterator it = std::find( Resource::_globalPaths.begin(),Resource::_globalPaths.end(), directory);90 if (it == Resource::_globalPaths.end())91 Resource::_globalPaths.push_back(directory);89 std::vector<Directory>::const_iterator it = std::find(NewResource::_globalPaths.begin(), NewResource::_globalPaths.end(), directory); 90 if (it == NewResource::_globalPaths.end()) 91 NewResource::_globalPaths.push_back(directory); 92 92 } 93 93 94 94 95 95 96 void Resource::addResource(Resource::Pointer* pointer)96 void NewResource::addResource(NewResource::Pointer* pointer) 97 97 { 98 98 this->_type->addResource(pointer); … … 108 108 109 109 110 void Resource::KeepLevel::setKeepLevelName(unsigned int level, const std::string& name)110 void NewResource::KeepLevel::setKeepLevelName(unsigned int level, const std::string& name) 111 111 { 112 112 if (_keepLevelName.size() <= level) … … 117 117 118 118 119 void Resource::Type::addResource(Resource::Pointer* resource)119 void NewResource::Type::addResource(NewResource::Pointer* resource) 120 120 { 121 121 this->_storedResources.push_back(resource); … … 124 124 125 125 126 Resource::Pointer::Pointer(const std::string& loadString, constResource::KeepLevel& keeplevel)126 NewResource::Pointer::Pointer(const std::string& loadString, const NewResource::KeepLevel& keeplevel) 127 127 : _loadString(loadString), _keepLevel(keeplevel) 128 128 {} 129 129 130 130 131 void Resource::Type::setID(int id)131 void NewResource::Type::setID(int id) 132 132 { 133 133 this->_id = id; -
branches/new_class_id/src/lib/util/loading/resource.h
r9786 r9788 1 1 /*! 2 2 * @file resource.h 3 * @brief Definition of a Resource.3 * @brief Definition of a NewResource. 4 4 */ 5 5 … … 15 15 #include "filesys/directory.h" 16 16 17 //! A Resource is an Object, that can be loaded from Disk17 //! A NewResource is an Object, that can be loaded from Disk 18 18 /** 19 19 * 20 20 */ 21 class Resource : virtual public BaseObject21 class NewResource : virtual public BaseObject 22 22 { 23 ObjectListDeclaration( Resource);23 ObjectListDeclaration(NewResource); 24 24 public: 25 25 class KeepLevel … … 35 35 { 36 36 public: 37 Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel);37 Pointer(const std::string& loadString, const NewResource::KeepLevel& keeplevel); 38 38 const std::string& loadString() const { return _loadString; }; 39 const Resource::KeepLevel& keepLevel() const { return _keepLevel; };39 const NewResource::KeepLevel& keepLevel() const { return _keepLevel; }; 40 40 41 41 private: 42 42 std::string _loadString; //!< An identifier, to match when loading a File. 43 Resource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so none else will delete this)43 NewResource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so none else will delete this) 44 44 }; 45 45 … … 60 60 const std::vector<std::string>& resourcePaths() const { return _resourcePaths; }; 61 61 const std::vector<std::string>& resourceSubPaths() const { return _resourceSubPaths; }; 62 const std::vector< Resource::Pointer*>& storedResources() const { return _storedResources; };62 const std::vector<NewResource::Pointer*>& storedResources() const { return _storedResources; }; 63 63 64 64 void setID(int id); 65 void addResource( Resource::Pointer* resource);65 void addResource(NewResource::Pointer* resource); 66 66 67 67 private: … … 72 72 std::vector<std::string> _fileExtensions; 73 73 74 std::vector< Resource::Pointer*> _storedResources;74 std::vector<NewResource::Pointer*> _storedResources; 75 75 }; 76 76 77 77 78 78 public: 79 Resource(Resource::Type* type);80 virtual ~ Resource();79 NewResource(NewResource::Type* type); 80 virtual ~NewResource(); 81 81 82 82 virtual bool reload() { return false; }; … … 92 92 93 93 protected: 94 Resource::Pointer* acquireResource(const std::string& loadString);95 void addResource( Resource::Pointer* pointer);94 NewResource::Pointer* acquireResource(const std::string& loadString); 95 void addResource(NewResource::Pointer* pointer); 96 96 97 97 private: 98 Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData.99 Resource::Type* _type; //!< Type of theResource.98 NewResource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. 99 NewResource::Type* _type; //!< Type of the NewResource. 100 100 101 101 102 static std::vector< Resource::Type*> _resourceTypes;102 static std::vector<NewResource::Type*> _resourceTypes; 103 103 104 104 //! GLOBALS
Note: See TracChangeset
for help on using the changeset viewer.