Mercurial > fife-parpg
comparison engine/core/util/resource/pool.h @ 644:b84dbc4665b0
loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
Fixed a small redundancy in the guimanager.
Added clearResourceLoaders() to the Pool class. This can be used if different resourceloaders have to be added at a later point in time (running editor for example, a plugin might want to have it's own loader added)
author | nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Oct 2010 22:20:00 +0000 |
parents | 54bfd1015b35 |
children | 5d6b1820b953 |
comparison
equal
deleted
inserted
replaced
643:edf6dcfe8cd4 | 644:b84dbc4665b0 |
---|---|
52 enum { RES_LOADED = 0x01, RES_NON_LOADED = 0x02}; | 52 enum { RES_LOADED = 0x01, RES_NON_LOADED = 0x02}; |
53 | 53 |
54 /** Pool is used to optimize memory usage for resources | 54 /** Pool is used to optimize memory usage for resources |
55 * | 55 * |
56 * Pool guarantees that there is minimal amount of resources | 56 * Pool guarantees that there is minimal amount of resources |
57 * used in cases when it is would possible that multiple | 57 * used in cases when it is would possible that multiple |
58 * instances of the same data would be loaded into the memory. | 58 * instances of the same data would be loaded into the memory. |
59 * Pool is the owner for resources taking care of their deletion. | 59 * Pool is the owner for resources taking care of their deletion. |
60 */ | 60 */ |
61 class Pool { | 61 class Pool { |
62 public: | 62 public: |
75 | 75 |
76 /** Adds new resource provider. Transfers provider ownership to the pool | 76 /** Adds new resource provider. Transfers provider ownership to the pool |
77 */ | 77 */ |
78 virtual void addResourceLoader(ResourceLoader* loader); | 78 virtual void addResourceLoader(ResourceLoader* loader); |
79 | 79 |
80 /** Clear the resource loaders | |
81 */ | |
82 virtual void clearResourceLoaders(); | |
83 | |
80 /** Adds new resource into the pool using the given location. | 84 /** Adds new resource into the pool using the given location. |
81 * @return The index of the resource in the pool. | 85 * @return The index of the resource in the pool. |
82 */ | 86 */ |
83 virtual int addResourceFromLocation(ResourceLocation* loc); | 87 virtual int addResourceFromLocation(ResourceLocation* loc); |
84 | 88 |
85 /** This is a convenience version of addResourceFromLocation(). | 89 /** This is a convenience version of addResourceFromLocation(). |
86 * It converts the filename into a ResourceLocation and then | 90 * It converts the filename into a ResourceLocation and then |
87 * calls addResourceFromLocation. | 91 * calls addResourceFromLocation. |
88 * | 92 * |
89 * @param filename The file to be loaded. | 93 * @param filename The file to be loaded. |
90 * @return The index of the resource in the pool. | 94 * @return The index of the resource in the pool. |
91 */ | 95 */ |
92 virtual int addResourceFromFile(const std::string& filename); | 96 virtual int addResourceFromFile(const std::string& filename); |
93 | 97 |
94 /** Gets resource from pool with given index | 98 /** Gets resource from pool with given index |
95 * | 99 * |
96 * @param inc Specifies weither this call will increase the ref counter | 100 * @param inc Specifies weither this call will increase the ref counter |
97 */ | 101 */ |
98 virtual IResource& get(unsigned int index, bool inc = false); | 102 virtual IResource& get(unsigned int index, bool inc = false); |
99 | 103 |
100 /** Removes the resource from pool if reference counter is null | 104 /** Removes the resource from pool if reference counter is null |
101 * | 105 * |
102 * @param dec Specifies weither the ref counter will be decreased | 106 * @param dec Specifies weither the ref counter will be decreased |
103 * before checking | 107 * before checking |
104 */ | 108 */ |
105 virtual void release(unsigned int index, bool dec = false); | 109 virtual void release(unsigned int index, bool dec = false); |
106 | 110 |