43 if (find(resourcePathsLoaded.begin(), resourcePathsLoaded.end(), path) == resourcePathsLoaded.end() ||
44 find(resourcePathsToUnload.begin(), resourcePathsToUnload.end(), path) != resourcePathsToUnload.end())
46 resourcePathsToLoad.push_back(path);
47 canUnloadPathToLoad[path] = isUnloadable;
48 dependenciesToLoad[path] = dependenciesInLibrary;
99 if (find(cachePathsLoaded.begin(), cachePathsLoaded.end(), path) == cachePathsLoaded.end() ||
100 find(cachePathsToUnload.begin(), cachePathsToUnload.end(), path) != cachePathsToUnload.end())
102 cachePathsToLoad.push_back(path);
103 canUnloadPathToLoad[path] = isUnloadable;
104 dependenciesToLoad[path] = dependenciesInLibrary;
105 cachePathLoadedCallbacks[path] = doAfterLoadAttempted;
117 if (find(cachePathsLoaded.begin(), cachePathsLoaded.end(), path) != cachePathsLoaded.end())
119 if (! canUnloadPathLoaded[path])
121 VUserLog(
"The cache library %s can't be unloaded.", path.c_str());
125 cachePathsToUnload.insert(path);
127 else if (find(cachePathsToUnload.begin(), cachePathsToUnload.end(), path) == cachePathsToUnload.end())
132 return dependenciesLoaded[path];
140 for (map<
string, set<string> >::iterator i = dependenciesLoaded.begin(); i != dependenciesLoaded.end(); ++i)
142 if (i->second.find(dependency) != i->second.end())
144 string libraryPath = i->first;
146 if (! canUnloadPathLoaded[libraryPath])
148 VUserLog(
"The library containing %s (%s) can't be unloaded.", dependency.c_str(), libraryPath.c_str());
152 if (find(resourcePathsLoaded.begin(), resourcePathsLoaded.end(), libraryPath) != resourcePathsLoaded.end())
153 resourcePathsToUnload.insert(libraryPath);
154 if (find(cachePathsLoaded.begin(), cachePathsLoaded.end(), libraryPath) != cachePathsLoaded.end())
155 cachePathsToUnload.insert(libraryPath);
173 vector<string> libraryPathsToLoad;
175 for (vector<string>::iterator i = cachePathsLoaded.begin(); i != cachePathsLoaded.end(); ++i)
176 if (canUnloadPathLoaded[*i])
177 libraryPathsToLoad.push_back(*i);
179 libraryPathsToLoad.insert(libraryPathsToLoad.end(), cachePathsToLoad.begin(), cachePathsToLoad.end());
181 for (
const string &cachePath : cachePathsToLoad)
183 auto callbackIter = cachePathLoadedCallbacks.find(cachePath);
184 if (callbackIter != cachePathLoadedCallbacks.end())
186 doAfterLoadAttempted.push_back(callbackIter->second);
187 cachePathLoadedCallbacks.erase(callbackIter);
191 for (vector<string>::iterator i = resourcePathsLoaded.begin(); i != resourcePathsLoaded.end(); ++i)
192 if (canUnloadPathLoaded[*i])
193 libraryPathsToLoad.push_back(*i);
195 libraryPathsToLoad.insert(libraryPathsToLoad.end(), resourcePathsToLoad.begin(), resourcePathsToLoad.end());
197 resourcePathsLoaded.insert(resourcePathsLoaded.end(), resourcePathsToLoad.begin(), resourcePathsToLoad.end());
198 resourcePathsToLoad.clear();
200 cachePathsLoaded.insert(cachePathsLoaded.end(), cachePathsToLoad.begin(), cachePathsToLoad.end());
201 cachePathsToLoad.clear();
203 dependenciesLoaded.insert(dependenciesToLoad.begin(), dependenciesToLoad.end());
204 dependenciesToLoad.clear();
206 canUnloadPathLoaded.insert(canUnloadPathToLoad.begin(), canUnloadPathToLoad.end());
207 canUnloadPathToLoad.clear();
209 return libraryPathsToLoad;
221 for (set<string>::iterator i = resourcePathsToUnload.begin(); i != resourcePathsToUnload.end(); ++i)
223 dependenciesLoaded.erase(*i);
224 canUnloadPathLoaded.erase(*i);
226 if (shouldDeleteResourceLibraries)
230 for (set<string>::iterator i = cachePathsToUnload.begin(); i != cachePathsToUnload.end(); ++i)
232 dependenciesLoaded.erase(*i);
233 canUnloadPathLoaded.erase(*i);
236 for (
int i = resourcePathsLoaded.size()-1; i >= 0; --i)
237 if (find(resourcePathsToUnload.begin(), resourcePathsToUnload.end(), resourcePathsLoaded[i]) != resourcePathsToUnload.end())
238 resourcePathsLoaded.erase(resourcePathsLoaded.begin() + i);
240 for (
int i = cachePathsLoaded.size()-1; i >= 0; --i)
241 if (find(cachePathsToUnload.begin(), cachePathsToUnload.end(), cachePathsLoaded[i]) != cachePathsToUnload.end())
242 cachePathsLoaded.erase(cachePathsLoaded.begin() + i);
244 vector<string> libraryPathsToUnload;
246 libraryPathsToUnload.insert(libraryPathsToUnload.end(), resourcePathsToUnload.rbegin(), resourcePathsToUnload.rend());
248 for (vector<string>::reverse_iterator i = resourcePathsLoaded.rbegin(); i != resourcePathsLoaded.rend(); ++i)
249 if (canUnloadPathLoaded[*i])
250 libraryPathsToUnload.push_back(*i);
252 libraryPathsToUnload.insert(libraryPathsToUnload.end(), cachePathsToUnload.rbegin(), cachePathsToUnload.rend());
254 for (vector<string>::reverse_iterator i = cachePathsLoaded.rbegin(); i != cachePathsLoaded.rend(); ++i)
255 if (canUnloadPathLoaded[*i])
256 libraryPathsToUnload.push_back(*i);
258 resourcePathsToUnload.clear();
259 cachePathsToUnload.clear();
261 return libraryPathsToUnload;
269 vector<string> libraryPathsLoaded;
271 for (vector<string>::iterator i = cachePathsLoaded.begin(); i != cachePathsLoaded.end(); ++i)
272 if (! canUnloadPathLoaded[*i])
273 libraryPathsLoaded.push_back(*i);
275 for (vector<string>::iterator i = resourcePathsLoaded.begin(); i != resourcePathsLoaded.end(); ++i)
276 if (! canUnloadPathLoaded[*i])
277 libraryPathsLoaded.push_back(*i);
279 return libraryPathsLoaded;
287 vector<string> libraryPathsLoaded;
289 for (vector<string>::iterator i = cachePathsLoaded.begin(); i != cachePathsLoaded.end(); ++i)
290 if (canUnloadPathLoaded[*i] && cachePathsToUnload.find(*i) == cachePathsToUnload.end())
291 libraryPathsLoaded.push_back(*i);
293 for (vector<string>::iterator i = resourcePathsLoaded.begin(); i != resourcePathsLoaded.end(); ++i)
294 if (canUnloadPathLoaded[*i] && resourcePathsToUnload.find(*i) == resourcePathsToUnload.end())
295 libraryPathsLoaded.push_back(*i);
297 return libraryPathsLoaded;
346 set<string> dependenciesLoadedSet;
348 set<string> libraryPathsLoaded;
351 libraryPathsLoaded.insert(nonUnloadable.begin(), nonUnloadable.end());
352 libraryPathsLoaded.insert(unloadable.begin(), unloadable.end());
354 for (set<string>::iterator i = libraryPathsLoaded.begin(); i != libraryPathsLoaded.end(); ++i)
356 map<string, set<string> >::iterator j = dependenciesLoaded.find(*i);
357 if (j != dependenciesLoaded.end())
358 dependenciesLoadedSet.insert(j->second.begin(), j->second.end());
361 return dependenciesLoadedSet;