source:
orxonox.OLD/branches/new_class_id/src/lib/util/loading/resource.h
@
9725
Last change on this file since 9725 was 9718, checked in by bensch, 18 years ago | |
---|---|
File size: 1.7 KB |
Rev | Line | |
---|---|---|
[4838] | 1 | /*! |
[7193] | 2 | * @file resource.h |
[7195] | 3 | * @brief Definition of a Resource. |
[3245] | 4 | */ |
[1853] | 5 | |
[7193] | 6 | #ifndef _RESOURCE_H |
7 | #define _RESOURCE_H | |
[1853] | 8 | |
[3543] | 9 | #include "base_object.h" |
[7193] | 10 | #include "multi_type.h" |
[7195] | 11 | #include <string> |
[9714] | 12 | #include <vector> |
13 | #include <set> | |
[1853] | 14 | |
[9714] | 15 | //! A Resource is an Object, that can be loaded from Disk |
[7195] | 16 | /** |
[9714] | 17 | * |
[7195] | 18 | */ |
[9714] | 19 | class Resource : virtual public BaseObject |
[7195] | 20 | { |
[9718] | 21 | ObjectListDeclaration(Resource); |
[9714] | 22 | public: |
[9718] | 23 | class KeepLevel |
[9714] | 24 | { |
25 | public: | |
[9718] | 26 | void setKeepLevelName(unsigned int level, const std::string& name) |
[9714] | 27 | { |
[9718] | 28 | if (_keepLevelName.size() <= level) |
29 | _keepLevelName.resize(level+1); | |
30 | _keepLevelName[level] = name; | |
[9714] | 31 | } |
32 | private: | |
[9718] | 33 | std::vector<std::string> _keepLevelName; |
[9714] | 34 | }; |
[7195] | 35 | |
36 | ||
[9714] | 37 | class Type |
38 | { | |
39 | public: | |
[9715] | 40 | Type(const ClassID& classID) : _classID(classID) { }; |
[7195] | 41 | |
[9714] | 42 | void addExtension(const std::string& extension); |
[1853] | 43 | |
[9714] | 44 | private: |
[9715] | 45 | const ClassID& _classID; |
[9714] | 46 | std::vector<std::string> _resourcePaths; |
47 | std::vector<std::string> _resourceSubPaths; | |
48 | std::vector<std::string> _fileExtensions; | |
49 | }; | |
50 | ||
51 | public: | |
52 | Resource(const std::string& fileName); | |
[7193] | 53 | virtual ~Resource(); |
[1853] | 54 | |
[7195] | 55 | virtual bool load(std::string& fileName, const MultiType& param1, const MultiType& param2); |
[7193] | 56 | virtual bool reload(); |
57 | virtual bool unload(); | |
[3245] | 58 | |
59 | ||
[9714] | 60 | private: |
[9718] | 61 | std::string _fileName; |
62 | MultiType _parameters[3]; //!< The Parameters given to this Resource. | |
63 | Resource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so noone else will delete this) | |
[7195] | 64 | |
[9714] | 65 | |
[9718] | 66 | static std::vector<Resource::Type> _resourceTypes; |
[9714] | 67 | |
68 | //! GLOBALS | |
[9718] | 69 | static std::string _mainGlobalPath; |
70 | static std::vector<std::string> _globalPaths; | |
[1853] | 71 | }; |
72 | ||
[7193] | 73 | #endif /* _RESOURCE_H */ |
Note: See TracBrowser
for help on using the repository browser.