Move plugin sorting classes

I'm about to add classes for group sorting, so it makes sense to have a
sorting directory.
This commit is contained in:
Oliver Hamlet
2018-03-17 18:26:37 +00:00
parent fab92f4f55
commit 64871cd65e
15 changed files with 137 additions and 74 deletions
+8 -6
View File
@@ -181,8 +181,9 @@ set (LOOT_API_SRC "${CMAKE_BINARY_DIR}/generated/loot_version.cpp"
"${CMAKE_SOURCE_DIR}/src/api/game/load_order_handler.cpp"
"${CMAKE_SOURCE_DIR}/src/api/metadata_list.cpp"
"${CMAKE_SOURCE_DIR}/src/api/masterlist.cpp"
"${CMAKE_SOURCE_DIR}/src/api/plugin/plugin.cpp"
"${CMAKE_SOURCE_DIR}/src/api/plugin/plugin_sorter.cpp"
"${CMAKE_SOURCE_DIR}/src/api/plugin.cpp"
"${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorter.cpp"
"${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorting_data.cpp"
"${CMAKE_SOURCE_DIR}/src/api/helpers/crc.cpp"
"${CMAKE_SOURCE_DIR}/src/api/helpers/git_helper.cpp"
"${CMAKE_SOURCE_DIR}/src/api/helpers/version.cpp"
@@ -231,8 +232,9 @@ set (LOOT_API_HEADERS "${CMAKE_SOURCE_DIR}/include/loot/api.h"
"${CMAKE_SOURCE_DIR}/src/api/game/load_order_handler.h"
"${CMAKE_SOURCE_DIR}/src/api/metadata_list.h"
"${CMAKE_SOURCE_DIR}/src/api/masterlist.h"
"${CMAKE_SOURCE_DIR}/src/api/plugin/plugin.h"
"${CMAKE_SOURCE_DIR}/src/api/plugin/plugin_sorter.h"
"${CMAKE_SOURCE_DIR}/src/api/plugin.h"
"${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorter.h"
"${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorting_data.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/git_helper.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/crc.h"
"${CMAKE_SOURCE_DIR}/src/api/helpers/logging.h"
@@ -260,8 +262,8 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/api/internals/game/game_t
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/plugin_metadata_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/priority_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/tag_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/plugin/plugin_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/plugin/plugin_sorter_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/plugin_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/sorting/plugin_sorter_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/masterlist_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata_list_test.h"
"${CMAKE_SOURCE_DIR}/src/tests/common_game_test_fixture.h"
+1 -1
View File
@@ -32,7 +32,7 @@
#include "api/game/game.h"
#include "api/metadata/condition_evaluator.h"
#include "api/metadata/yaml/plugin_metadata.h"
#include "api/plugin/plugin_sorter.h"
#include "api/sorting/plugin_sorter.h"
#include "loot/metadata/group.h"
#include "loot/exception/file_access_error.h"
+1 -1
View File
@@ -32,7 +32,7 @@
#include "api/api_database.h"
#include "api/helpers/logging.h"
#include "api/plugin/plugin_sorter.h"
#include "api/sorting/plugin_sorter.h"
#include "loot/exception/file_access_error.h"
#ifdef _WIN32
+1 -1
View File
@@ -29,7 +29,7 @@
#include <string>
#include <unordered_map>
#include "api/plugin/plugin.h"
#include "api/plugin.h"
namespace loot {
class GameCache {
+1 -1
View File
@@ -47,7 +47,7 @@
#include "api/helpers/logging.h"
#include "api/helpers/version.h"
#include "api/metadata/condition_evaluator.h"
#include "api/plugin/plugin.h"
#include "api/plugin.h"
#include "loot/exception/condition_syntax_error.h"
namespace loot {
@@ -22,7 +22,7 @@
<https://www.gnu.org/licenses/>.
*/
#include "api/plugin/plugin.h"
#include "api/plugin.h"
#include <regex>
+2 -2
View File
@@ -21,8 +21,8 @@
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_API_PLUGIN_PLUGIN
#define LOOT_API_PLUGIN_PLUGIN
#ifndef LOOT_API_PLUGIN
#define LOOT_API_PLUGIN
#include <cstdint>
#include <list>
@@ -42,33 +42,6 @@ using std::string;
using std::vector;
namespace loot {
PluginSortingData::PluginSortingData(const Plugin& plugin,
const PluginMetadata&& metadata) :
plugin_(plugin),
PluginMetadata(metadata) {}
std::string PluginSortingData::GetName() const { return plugin_.GetName(); }
bool PluginSortingData::IsMaster() const {
return plugin_.IsMaster() || (plugin_.IsLightMaster() &&
!boost::iends_with(plugin_.GetName(), ".esp"));
}
bool PluginSortingData::LoadsArchive() const { return plugin_.LoadsArchive(); }
std::vector<std::string> PluginSortingData::GetMasters() const {
return plugin_.GetMasters();
}
size_t PluginSortingData::NumOverrideFormIDs() const {
return plugin_.NumOverrideFormIDs();
}
bool PluginSortingData::DoFormIDsOverlap(
const PluginSortingData& plugin) const {
return plugin_.DoFormIDsOverlap(plugin.plugin_);
}
typedef boost::graph_traits<PluginGraph>::vertex_iterator vertex_it;
typedef boost::graph_traits<PluginGraph>::edge_descriptor edge_t;
typedef boost::graph_traits<PluginGraph>::edge_iterator edge_it;
@@ -22,8 +22,8 @@
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_API_PLUGIN_PLUGIN_SORTER
#define LOOT_API_PLUGIN_PLUGIN_SORTER
#ifndef LOOT_API_SORTING_PLUGIN_SORTER
#define LOOT_API_SORTING_PLUGIN_SORTER
#include <map>
@@ -32,31 +32,10 @@
#include <boost/graph/graph_traits.hpp>
#include "api/game/game.h"
#include "api/plugin/plugin.h"
#include "api/plugin.h"
#include "api/sorting/plugin_sorting_data.h"
namespace loot {
class PluginSortingData : private PluginMetadata {
public:
PluginSortingData(const Plugin& plugin, const PluginMetadata&& metadata);
std::string GetName() const;
bool IsMaster() const;
bool LoadsArchive() const;
std::vector<std::string> GetMasters() const;
size_t NumOverrideFormIDs() const;
bool DoFormIDsOverlap(const PluginSortingData& plugin) const;
using PluginMetadata::GetGlobalPriority;
using PluginMetadata::GetLoadAfterFiles;
using PluginMetadata::GetLocalPriority;
using PluginMetadata::GetRequirements;
using PluginMetadata::SetGlobalPriority;
using PluginMetadata::SetLocalPriority;
private:
const Plugin& plugin_;
};
typedef boost::adjacency_list<boost::listS,
boost::listS,
boost::directedS,
+54
View File
@@ -0,0 +1,54 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2018 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#include "plugin_sorting_data.h"
namespace loot {
PluginSortingData::PluginSortingData(const Plugin& plugin,
const PluginMetadata&& metadata) :
plugin_(plugin),
PluginMetadata(metadata) {}
std::string PluginSortingData::GetName() const { return plugin_.GetName(); }
bool PluginSortingData::IsMaster() const {
return plugin_.IsMaster() || (plugin_.IsLightMaster() &&
!boost::iends_with(plugin_.GetName(), ".esp"));
}
bool PluginSortingData::LoadsArchive() const { return plugin_.LoadsArchive(); }
std::vector<std::string> PluginSortingData::GetMasters() const {
return plugin_.GetMasters();
}
size_t PluginSortingData::NumOverrideFormIDs() const {
return plugin_.NumOverrideFormIDs();
}
bool PluginSortingData::DoFormIDsOverlap(
const PluginSortingData& plugin) const {
return plugin_.DoFormIDsOverlap(plugin.plugin_);
}
}
+55
View File
@@ -0,0 +1,55 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2018 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_API_SORTING_PLUGIN_SORTING_DATA
#define LOOT_API_SORTING_PLUGIN_SORTING_DATA
#include "api/plugin.h"
#include "loot/metadata/plugin_metadata.h"
namespace loot {
class PluginSortingData : private PluginMetadata {
public:
PluginSortingData(const Plugin& plugin, const PluginMetadata&& metadata);
std::string GetName() const;
bool IsMaster() const;
bool LoadsArchive() const;
std::vector<std::string> GetMasters() const;
size_t NumOverrideFormIDs() const;
bool DoFormIDsOverlap(const PluginSortingData& plugin) const;
using PluginMetadata::GetGlobalPriority;
using PluginMetadata::GetLoadAfterFiles;
using PluginMetadata::GetLocalPriority;
using PluginMetadata::GetRequirements;
using PluginMetadata::SetGlobalPriority;
using PluginMetadata::SetLocalPriority;
private:
const Plugin& plugin_;
};
}
#endif
+2 -2
View File
@@ -45,8 +45,8 @@
#include "tests/api/internals/metadata/priority_test.h"
#include "tests/api/internals/metadata/tag_test.h"
#include "tests/api/internals/metadata_list_test.h"
#include "tests/api/internals/plugin/plugin_sorter_test.h"
#include "tests/api/internals/plugin/plugin_test.h"
#include "tests/api/internals/sorting/plugin_sorter_test.h"
#include "tests/api/internals/plugin_test.h"
TEST(ModuloOperator, shouldConformToTheCpp11Standard) {
// C++11 defines the modulo operator more strongly
@@ -22,10 +22,10 @@ along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_TESTS_API_INTERNALS_PLUGIN_PLUGIN_TEST
#define LOOT_TESTS_API_INTERNALS_PLUGIN_PLUGIN_TEST
#ifndef LOOT_TESTS_API_INTERNALS_PLUGIN_TEST
#define LOOT_TESTS_API_INTERNALS_PLUGIN_TEST
#include "api/plugin/plugin.h"
#include "api/plugin.h"
#include "api/game/game.h"
#include "tests/common_game_test_fixture.h"
@@ -22,10 +22,10 @@ along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_TESTS_API_INTERNALS_PLUGIN_PLUGIN_SORTER_TEST
#define LOOT_TESTS_API_INTERNALS_PLUGIN_PLUGIN_SORTER_TEST
#ifndef LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_SORTER_TEST
#define LOOT_TESTS_API_INTERNALS_SORTING_PLUGIN_SORTER_TEST
#include "api/plugin/plugin_sorter.h"
#include "api/sorting/plugin_sorter.h"
#include "loot/exception/cyclic_interaction_error.h"
#include "tests/common_game_test_fixture.h"
+1 -1
View File
@@ -30,7 +30,7 @@ along with LOOT. If not, see
#include <gtest/gtest.h>
#include "api/metadata/message_content.h"
#include "api/plugin/plugin.h"
#include "api/plugin.h"
#include "loot/metadata/file.h"
#include "loot/metadata/location.h"
#include "loot/metadata/message.h"