annotate engine/core/util/resource/pool.cpp @ 697:ecaa4d98f05f tip

Abstracted the GUI code and refactored the GUIChan-specific code into its own module. * Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring. * GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass. * The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class. * The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged. * Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 18 Jun 2011 00:28:40 -1000
parents b84dbc4665b0
children
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // Second block: files included from the same folder
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 #include "util/base/exception.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "util/log/logger.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "pool.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 static Logger _log(LM_POOL);
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
37
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
38 Pool::Pool(const std::string& name):
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 m_entries(),
100
69a7d40ccf62 added hashing to pool to improve techdemo loading time
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
40 m_location_to_entry(),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 m_loaders(),
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
42 m_name(name)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 Pool::~Pool() {
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
47 FL_LOG(_log, LMsg("Pool destroyed: ") << m_name);
144
d2f1e81fbe2c * Fixed a scons issue, where libraries checked for C instead of C++
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 100
diff changeset
48 printStatistics();
588
a46368b3d8a0 * Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 156
diff changeset
49 // This is only usefull for debugging
a46368b3d8a0 * Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 156
diff changeset
50 //sanityCheck();
148
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
51 reset();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 std::vector<ResourceLoader*>::iterator loader;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 for (loader = m_loaders.begin(); loader != m_loaders.end(); loader++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 delete (*loader);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 }
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
57
148
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
58 void Pool::reset() {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 std::vector<PoolEntry*>::iterator entry;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 for (entry = m_entries.begin(); entry != m_entries.end(); entry++) {
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
61 // Warn about leaks, but at least display ALL of them
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
62 // Instead of bailing out with an exception in the FifeClass destructor.
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
63 if( (*entry)->resource && (*entry)->resource->getRefCount() > 0 ) {
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
64 FL_WARN(_log, LMsg(m_name + " leak: ") << (*entry)->location->getFilename());
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
65 (*entry)->resource = 0;
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
66 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 delete (*entry);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 m_entries.clear();
100
69a7d40ccf62 added hashing to pool to improve techdemo loading time
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
70 m_location_to_entry.clear();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72
148
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
73 int Pool::purgeLoadedResources() {
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
74 int count = 0;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
75 std::vector<PoolEntry*>::iterator it;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
76 for (it = m_entries.begin(); it != m_entries.end(); it++) {
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
77 PoolEntry* entry = *it;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
78 if( entry->resource && entry->resource->getRefCount() == 0 ) {
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
79 delete entry->resource;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
80 entry->resource = 0;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
81 ++count;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
82 }
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
83 }
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
84 return count;
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
85 }
72c25cc27d8b For your convenience pools now have a function
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 147
diff changeset
86
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 void Pool::addResourceLoader(ResourceLoader* loader) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 m_loaders.push_back(loader);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
91 void Pool::clearResourceLoaders() {
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
92 m_loaders.clear();
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
93 }
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
94
156
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
95 int Pool::addResourceFromLocation(ResourceLocation* loc) {
100
69a7d40ccf62 added hashing to pool to improve techdemo loading time
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
96 ResourceLocationToEntry::const_iterator it = m_location_to_entry.find(loc);
69a7d40ccf62 added hashing to pool to improve techdemo loading time
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
97 if (it != m_location_to_entry.end()) {
156
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
98 return it->second;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 }
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
100
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 PoolEntry* entry = new PoolEntry();
156
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
102 entry->location = loc->clone();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 m_entries.push_back(entry);
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
104 size_t index = m_entries.size() - 1;
156
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
105 m_location_to_entry[entry->location] = index;
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
106 return index;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 int Pool::addResourceFromFile(const std::string& filename) {
156
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
110 ResourceLocation r = ResourceLocation(filename);
376b8afc9a18 Fixed a horrendous misconeception in the pool.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 152
diff changeset
111 return addResourceFromLocation(&r);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 IResource& Pool::get(unsigned int index, bool inc) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 if (index >= m_entries.size()) {
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
116 FL_ERR(_log, LMsg("Tried to get with index ") << index << ", only " << m_entries.size() << " items in pool " + m_name);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 throw IndexOverflow( __FUNCTION__ );
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 IResource* res = NULL;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 PoolEntry* entry = m_entries[index];
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 if (entry->resource) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 res = entry->resource;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 } else {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 if (!entry->loader) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 findAndSetProvider(*entry);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 } else {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 entry->resource = entry->loader->loadResource(*entry->location);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 }
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
129
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 if (!entry->loader) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 LMsg msg("No suitable loader was found for resource ");
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
132 msg << "#" << index << "<" << entry->location->getFilename()
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
133 << "> in pool " << m_name;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 FL_ERR(_log, msg);
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
135
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 throw NotFound(msg.str);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 }
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
138
149
823544621b5b Removed the pool listener interface as purpose
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 148
diff changeset
139 // This branch will only be relevant if the resource has been
823544621b5b Removed the pool listener interface as purpose
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 148
diff changeset
140 // loaded successfully before, but for some reason the loader
823544621b5b Removed the pool listener interface as purpose
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 148
diff changeset
141 // can't load the resource anymore.
823544621b5b Removed the pool listener interface as purpose
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 148
diff changeset
142 // Maybe someone deleted a file under FIFE's hands?
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 if (!entry->resource) {
149
823544621b5b Removed the pool listener interface as purpose
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 148
diff changeset
144 LMsg msg("The loader was unable to load the resource ");
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
145 msg << "#" << index << "<" << entry->location->getFilename()
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
146 << "> in pool " << m_name;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 FL_ERR(_log, msg);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 throw NotFound(msg.str);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 res = entry->resource;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 if (inc) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 res->addRef();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 res->setPoolId(index);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 return *res;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 void Pool::release(unsigned int index, bool dec) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 if (index >= m_entries.size()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 throw IndexOverflow( __FUNCTION__ );
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 IResource* res = NULL;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 PoolEntry* entry = m_entries[index];
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 if (entry->resource) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 res = entry->resource;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 if (dec) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 res->decRef();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 if(res->getRefCount() == 0) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 delete entry->resource;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 entry->resource = 0;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 int Pool::getResourceCount(int status) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 int amount = 0;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 std::vector<PoolEntry*>::iterator entry;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 for (entry = m_entries.begin(); entry != m_entries.end(); entry++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 if (status & RES_LOADED) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 if ((*entry)->resource) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 amount++;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 if (status & RES_NON_LOADED) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 if (!(*entry)->resource) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 amount++;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 return amount;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 void Pool::findAndSetProvider(PoolEntry& entry) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 std::vector<ResourceLoader*>::iterator it = m_loaders.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 std::vector<ResourceLoader*>::iterator end = m_loaders.end();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 if( it == end ) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 FL_PANIC(_log, "no loader constructors given for resource pool");
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 for(; it != end; ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 IResource* res = (*it)->loadResource(*entry.location);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 if (res) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 entry.resource = res;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 entry.loader = *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 return;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 };
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 void Pool::printStatistics() {
144
d2f1e81fbe2c * Fixed a scons issue, where libraries checked for C instead of C++
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 100
diff changeset
213 FL_LOG(_log, LMsg("Pool not loaded =") << getResourceCount(RES_NON_LOADED));
d2f1e81fbe2c * Fixed a scons issue, where libraries checked for C instead of C++
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 100
diff changeset
214 FL_LOG(_log, LMsg("Pool loaded =") << getResourceCount(RES_LOADED));
146
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
215 int amount = 0;
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
216 std::vector<PoolEntry*>::iterator entry;
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
217 for (entry = m_entries.begin(); entry != m_entries.end(); entry++) {
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
218 if ((*entry)->resource) {
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
219 if ((*entry)->resource->getRefCount() > 0) {
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
220 amount++;
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
221 }
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
222 }
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
223 }
54b3984e1afc The getIndex function was a hack that shadowed another bug
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 144
diff changeset
224 FL_LOG(_log, LMsg("Pool locked =") << amount);
144
d2f1e81fbe2c * Fixed a scons issue, where libraries checked for C instead of C++
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 100
diff changeset
225 FL_LOG(_log, LMsg("Pool total size =") << m_entries.size());
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 }
147
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
227
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
228 void Pool::sanityCheck() {
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
229 // It is easy to mess up the important consistent
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
230 // less-than operator for the location classes.
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 588
diff changeset
231 // This will check if according to the '==' operator
147
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
232 // entries are duplicate (=memory leaks).
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
233 // Slow and inaccurate. But should barf at real messups.
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
234 for(unsigned i = 0; i != m_entries.size(); ++i) {
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
235 int count = 0;
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
236 for(unsigned j = i+1; j < m_entries.size(); ++j) {
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
237 if( *m_entries[i]->location == *m_entries[j]->location )
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
238 count ++;
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
239 }
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
240 if( 0 == count )
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
241 continue;
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
242 FL_WARN(_log, LMsg("Multiple entries: ") << m_entries[i]->location->getFilename()
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
243 << " #entries = " << (count+1) );
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
244 }
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
245 }
fb6ccb367dd1 Added just some docs and a sanityCheck against the
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 146
diff changeset
246
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 }