Mercurial > fife-parpg
comparison engine/core/util/resource/pool.h @ 146:54b3984e1afc
The getIndex function was a hack that shadowed another bug
that caused the pools to misbehave.
AddResourceFromFile works now exactly as getIndex,
it's just faster.
Fixed GUIImage to not hold a reference, it uses the
index directly anyway.
Plus heaps of minor adjustments for
more informative debug output and statistics.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 09 Oct 2008 12:36:21 +0000 |
parents | 69a7d40ccf62 |
children | fb6ccb367dd1 |
comparison
equal
deleted
inserted
replaced
145:e7a431577c95 | 146:54b3984e1afc |
---|---|
65 */ | 65 */ |
66 static const int INVALID_ID = -1; | 66 static const int INVALID_ID = -1; |
67 | 67 |
68 /** Default constructor. | 68 /** Default constructor. |
69 */ | 69 */ |
70 Pool(); | 70 Pool(const std::string& name); |
71 | 71 |
72 /** Destructor. | 72 /** Destructor. |
73 */ | 73 */ |
74 virtual ~Pool(); | 74 virtual ~Pool(); |
75 | 75 |
98 virtual IResource& get(unsigned int index, bool inc = false); | 98 virtual IResource& get(unsigned int index, bool inc = false); |
99 | 99 |
100 /** Gets resource index from pool with given filename | 100 /** Gets resource index from pool with given filename |
101 * The resource will be created if it is not in the pool | 101 * The resource will be created if it is not in the pool |
102 */ | 102 */ |
103 virtual unsigned int getIndex(const std::string& filename); | 103 virtual int getIndex(const std::string& filename); |
104 | 104 |
105 /** Removes the resource from pool if reference counter is null | 105 /** Removes the resource from pool if reference counter is null |
106 * | 106 * |
107 * @param dec Specifies weither the ref counter will be decreased | 107 * @param dec Specifies weither the ref counter will be decreased |
108 * before checking | 108 * before checking |
148 // Resource loader. | 148 // Resource loader. |
149 ResourceLoader* loader; | 149 ResourceLoader* loader; |
150 }; | 150 }; |
151 | 151 |
152 void findAndSetProvider(PoolEntry& entry); | 152 void findAndSetProvider(PoolEntry& entry); |
153 | |
153 std::vector<PoolEntry*> m_entries; | 154 std::vector<PoolEntry*> m_entries; |
154 typedef std::map<ResourceLocation, int> ResourceLocationToEntry; | 155 typedef std::map<ResourceLocation, int> ResourceLocationToEntry; |
155 ResourceLocationToEntry m_location_to_entry; | 156 ResourceLocationToEntry m_location_to_entry; |
156 std::vector<IPoolListener*> m_listeners; | 157 std::vector<IPoolListener*> m_listeners; |
157 std::vector<ResourceLoader*> m_loaders; | 158 std::vector<ResourceLoader*> m_loaders; |
158 int m_curind; | 159 int m_curind; |
160 std::string m_name; | |
159 }; | 161 }; |
160 | 162 |
161 } // FIFE | 163 } // FIFE |
162 | 164 |
163 #endif | 165 #endif |