1 | /*! |
---|
2 | * @file resource.h |
---|
3 | * @brief Definition of a Resource. |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _RESOURCE_H |
---|
7 | #define _RESOURCE_H |
---|
8 | |
---|
9 | #include "base_object.h" |
---|
10 | #include "multi_type.h" |
---|
11 | #include <string> |
---|
12 | #include <vector> |
---|
13 | #include <set> |
---|
14 | |
---|
15 | //! A Resource is an Object, that can be loaded from Disk |
---|
16 | /** |
---|
17 | * |
---|
18 | */ |
---|
19 | class Resource : virtual public BaseObject |
---|
20 | { |
---|
21 | ObjectListDeclaration(Resource); |
---|
22 | public: |
---|
23 | class KeepLevel |
---|
24 | { |
---|
25 | public: |
---|
26 | void setKeepLevelName(unsigned int level, const std::string& name); |
---|
27 | private: |
---|
28 | std::vector<std::string> _keepLevelName; |
---|
29 | }; |
---|
30 | |
---|
31 | protected: |
---|
32 | class Type |
---|
33 | { |
---|
34 | public: |
---|
35 | Type(const ClassID& classID) : _id(-1), _classID(classID) { }; |
---|
36 | |
---|
37 | void addExtension(const std::string& extension); |
---|
38 | |
---|
39 | const ClassID& storedClassID() const { return _classID; }; |
---|
40 | int id() const { return _id; }; |
---|
41 | const std::vector<std::string>& resourcePaths() const { return _resourcePaths; }; |
---|
42 | |
---|
43 | |
---|
44 | void setID(int id); |
---|
45 | |
---|
46 | private: |
---|
47 | int _id; |
---|
48 | const ClassID& _classID; |
---|
49 | std::vector<std::string> _resourcePaths; |
---|
50 | std::vector<std::string> _resourceSubPaths; |
---|
51 | std::vector<std::string> _fileExtensions; |
---|
52 | }; |
---|
53 | |
---|
54 | class Pointer {}; |
---|
55 | |
---|
56 | |
---|
57 | public: |
---|
58 | Resource(const std::string& fileName); |
---|
59 | virtual ~Resource(); |
---|
60 | |
---|
61 | bool loadResource(std::string& fileName, Resource::Pointer* ptr); |
---|
62 | virtual bool reload(); |
---|
63 | virtual bool unload(); |
---|
64 | |
---|
65 | |
---|
66 | |
---|
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; |
---|
75 | |
---|
76 | //! GLOBALS |
---|
77 | static std::string _mainGlobalPath; |
---|
78 | static std::vector<std::string> _globalPaths; |
---|
79 | }; |
---|
80 | |
---|
81 | #endif /* _RESOURCE_H */ |
---|