Don't cache load order in the API

Leave the load order caching up to libloadorder, which knows when the
cache should be expired.
This commit is contained in:
Oliver Hamlet
2017-02-06 18:03:18 +00:00
parent 44b358c19e
commit ea4c3b9a6c
3 changed files with 2 additions and 21 deletions
+1 -7
View File
@@ -67,7 +67,6 @@ Game::Game(const GameType gameType,
BOOST_LOG_TRIVIAL(info) << "Initialising load order data for game of type " << (int)type_ << " at: " << gamePath_;
loadOrderHandler_.Init(type_, gamePath_, localDataPath_);
StoreLoadOrder(loadOrderHandler_.GetLoadOrder());
database_ = std::make_shared<ApiDatabase>(*this);
}
@@ -196,15 +195,10 @@ bool Game::IsPluginActive(const std::string& plugin) const {
}
std::vector<std::string> Game::GetLoadOrder() const {
auto loadOrder = GameCache::GetLoadOrder();
if (loadOrder.empty())
return loadOrderHandler_.GetLoadOrder();
return loadOrder;
return loadOrderHandler_.GetLoadOrder();
}
void Game::SetLoadOrder(const std::vector<std::string>& loadOrder) {
loadOrderHandler_.SetLoadOrder(loadOrder);
StoreLoadOrder(loadOrder);
}
}
-9
View File
@@ -106,18 +106,9 @@ void GameCache::AddPlugin(const Plugin&& plugin) {
if (it != end(plugins_))
plugins_.erase(it);
plugins_.emplace(plugin.GetLowercasedName(), std::make_shared<Plugin>(std::move(plugin)));
}
std::vector<std::string> GameCache::GetLoadOrder() const {
return loadOrder_;
}
void GameCache::StoreLoadOrder(const std::vector<std::string>& loadOrder) {
loadOrder_ = loadOrder;
}
void GameCache::ClearCachedConditions() {
lock_guard<mutex> guard(mutex_);
+1 -5
View File
@@ -52,9 +52,6 @@ public:
std::shared_ptr<const Plugin> GetPlugin(const std::string& pluginName) const;
void AddPlugin(const Plugin&& plugin);
std::vector<std::string> GetLoadOrder() const;
void StoreLoadOrder(const std::vector<std::string>& loadOrder);
void ClearCachedConditions();
void ClearCachedPlugins();
private:
@@ -62,7 +59,6 @@ private:
MetadataList userlist_;
std::unordered_map<std::string, bool> conditions_;
std::unordered_map<std::string, std::shared_ptr<const Plugin>> plugins_;
std::vector<std::string> loadOrder_;
mutable std::mutex mutex_;
};
@@ -71,7 +67,7 @@ private:
namespace std {
template<>
struct less<std::shared_ptr<const loot::Plugin>> {
size_t operator() (const std::shared_ptr<const loot::Plugin>& lhs,
size_t operator() (const std::shared_ptr<const loot::Plugin>& lhs,
const std::shared_ptr<const loot::Plugin>& rhs) const {
return lhs->GetLowercasedName() < rhs->GetLowercasedName();
}