Changeset 9785 in orxonox.OLD for branches/new_class_id/src/lib/util
- Timestamp:
- Sep 22, 2006, 3:40:06 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/filesys/directory.cc
r9719 r9785 212 212 213 213 } 214 215 File operator+(const Directory& dir, const File& file) 216 { 217 return File(dir.name() + '/' + file.name()); 218 } -
branches/new_class_id/src/lib/util/filesys/directory.h
r9719 r9785 77 77 }; 78 78 79 File operator+(const Directory& dir, const File& file); 80 79 81 #endif /* __DIRECTORY_H_ */ 80 82 -
branches/new_class_id/src/lib/util/loading/resource.cc
r9784 r9785 17 17 18 18 #include "resource.h" 19 #include "filesys/file.h" 19 20 20 21 ObjectListDefinition(Resource); 22 23 24 std::vector<Resource::Type*> Resource::_resourceTypes; 25 26 //! GLOBALS 27 Directory Resource::_mainGlobalPath; 28 std::vector<Directory> Resource::_globalPaths; 21 29 22 30 … … 24 32 * standard constructor 25 33 */ 26 Resource::Resource ( )27 : _pointer(NULL) 34 Resource::Resource (Resource::Type* type) 35 : _pointer(NULL), _type(type) 28 36 { 29 37 this->registerObject(this, Resource::_objectList); 38 39 if(this->_type->id() == -1) 40 { 41 Resource::_resourceTypes.push_back(this->_type); 42 this->_type->setID(Resource::_resourceTypes.size()-1); 43 } 30 44 31 45 } … … 40 54 41 55 56 std::string Resource::locateFile(const std::string& fileName) 57 { 58 if (File(fileName).exists()) 59 return fileName; 60 else if ((Resource::_mainGlobalPath+File(fileName)) . exists() ) 61 return (Resource::_mainGlobalPath + File(fileName)).name(); 42 62 43 Resource::Pointer* Resource::acquireResource(Resource::Type& resourceType, const std::string& loadString) 63 64 return std::string("/home/bensch/svn/orxonox/data/") + fileName; 65 66 } 67 68 69 Resource::Pointer* Resource::acquireResource(const std::string& loadString) 44 70 { 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()]; 71 //const Resource::Type* const type = Resource::_resourceTypes[this->_type->id()]; 51 72 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;73 for (unsigned int i = 0; i < _type->storedResources().size(); ++i) 74 if (_type->storedResources()[i]->_pointer->loadString() == loadString) 75 return _type->storedResources()[i]->_pointer; 55 76 56 77 return NULL; 57 78 } 79 80 void Resource::setMainGlobalPath(const Directory& directory) 81 { 82 Resource::_mainGlobalPath = directory; 83 Resource::_mainGlobalPath.open(); 84 } 85 86 void Resource::addGlobalPath(const Directory& directory) 87 { 88 std::vector<Directory>::const_iterator it = std::find(Resource::_globalPaths.begin(), Resource::_globalPaths.end(), directory); 89 if (it == Resource::_globalPaths.end()) 90 Resource::_globalPaths.push_back(directory); 91 } 92 93 94 95 void Resource::addResource(Resource::Pointer* pointer) 96 {} 97 98 99 100 58 101 59 102 … … 68 111 _keepLevelName[level] = name; 69 112 } 113 114 115 116 117 118 119 120 121 122 123 Resource::Pointer::Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel) 124 { 125 } 126 127 void Resource::Type::setID(int id) 128 { 129 this->_id = id; 130 } -
branches/new_class_id/src/lib/util/loading/resource.h
r9784 r9785 12 12 #include <vector> 13 13 #include <set> 14 15 #include "filesys/directory.h" 14 16 15 17 //! A Resource is an Object, that can be loaded from Disk … … 48 50 49 51 void setID(int id); 52 void addResource(Resource* resource); 50 53 51 54 private: … … 73 76 74 77 public: 75 Resource( );78 Resource(Resource::Type* type); 76 79 virtual ~Resource(); 77 80 78 virtual bool reload(); 79 virtual bool unload(); 81 virtual bool reload() { return false; }; 82 virtual bool unload() { return false; }; 83 84 std::string locateFile(const std::string& fileName); 85 86 87 public: 88 static void setMainGlobalPath(const Directory& directory); 89 static void addGlobalPath(const Directory& directory); 90 80 91 81 92 protected: 82 Resource::Pointer* acquireResource(Resource::Type& resourceType, const std::string& loadString); 93 Resource::Pointer* acquireResource(const std::string& loadString); 94 void addResource(Resource::Pointer* pointer); 83 95 84 96 private: 85 97 Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. 98 Resource::Type* _type; //!< Type of the Resource. 86 99 87 100 … … 89 102 90 103 //! GLOBALS 91 static std::string_mainGlobalPath;92 static std::vector< std::string>_globalPaths;104 static Directory _mainGlobalPath; 105 static std::vector<Directory> _globalPaths; 93 106 }; 94 107
Note: See TracChangeset
for help on using the changeset viewer.