diff --git a/CMakeLists.txt b/CMakeLists.txt index c98ea1b2..06201c84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index f5aebb53..27a05c30 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -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" diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 12d32d44..4d4258e6 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -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 diff --git a/src/api/game/game_cache.h b/src/api/game/game_cache.h index 4e49a393..8edd2c44 100644 --- a/src/api/game/game_cache.h +++ b/src/api/game/game_cache.h @@ -29,7 +29,7 @@ #include #include -#include "api/plugin/plugin.h" +#include "api/plugin.h" namespace loot { class GameCache { diff --git a/src/api/metadata/condition_grammar.h b/src/api/metadata/condition_grammar.h index 6a3138af..b484ccd2 100644 --- a/src/api/metadata/condition_grammar.h +++ b/src/api/metadata/condition_grammar.h @@ -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 { diff --git a/src/api/plugin/plugin.cpp b/src/api/plugin.cpp similarity index 99% rename from src/api/plugin/plugin.cpp rename to src/api/plugin.cpp index 77115a79..fcb9cc76 100644 --- a/src/api/plugin/plugin.cpp +++ b/src/api/plugin.cpp @@ -22,7 +22,7 @@ . */ -#include "api/plugin/plugin.h" +#include "api/plugin.h" #include diff --git a/src/api/plugin/plugin.h b/src/api/plugin.h similarity index 98% rename from src/api/plugin/plugin.h rename to src/api/plugin.h index ff5ccec0..ada5faba 100644 --- a/src/api/plugin/plugin.h +++ b/src/api/plugin.h @@ -21,8 +21,8 @@ along with LOOT. If not, see . */ -#ifndef LOOT_API_PLUGIN_PLUGIN -#define LOOT_API_PLUGIN_PLUGIN +#ifndef LOOT_API_PLUGIN +#define LOOT_API_PLUGIN #include #include diff --git a/src/api/plugin/plugin_sorter.cpp b/src/api/sorting/plugin_sorter.cpp similarity index 95% rename from src/api/plugin/plugin_sorter.cpp rename to src/api/sorting/plugin_sorter.cpp index 892c5711..3d459839 100644 --- a/src/api/plugin/plugin_sorter.cpp +++ b/src/api/sorting/plugin_sorter.cpp @@ -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 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::vertex_iterator vertex_it; typedef boost::graph_traits::edge_descriptor edge_t; typedef boost::graph_traits::edge_iterator edge_it; diff --git a/src/api/plugin/plugin_sorter.h b/src/api/sorting/plugin_sorter.h similarity index 73% rename from src/api/plugin/plugin_sorter.h rename to src/api/sorting/plugin_sorter.h index 6f9af8e3..fe284fe3 100644 --- a/src/api/plugin/plugin_sorter.h +++ b/src/api/sorting/plugin_sorter.h @@ -22,8 +22,8 @@ . */ -#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 @@ -32,31 +32,10 @@ #include #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 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. + */ + +#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 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_); +} +} diff --git a/src/api/sorting/plugin_sorting_data.h b/src/api/sorting/plugin_sorting_data.h new file mode 100644 index 00000000..85998b9b --- /dev/null +++ b/src/api/sorting/plugin_sorting_data.h @@ -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 + . + */ + +#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 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 \ No newline at end of file diff --git a/src/tests/api/internals/main.cpp b/src/tests/api/internals/main.cpp index 6d4330bb..c9bd6c1b 100644 --- a/src/tests/api/internals/main.cpp +++ b/src/tests/api/internals/main.cpp @@ -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 diff --git a/src/tests/api/internals/plugin/plugin_test.h b/src/tests/api/internals/plugin_test.h similarity index 99% rename from src/tests/api/internals/plugin/plugin_test.h rename to src/tests/api/internals/plugin_test.h index ad297473..946e2be1 100644 --- a/src/tests/api/internals/plugin/plugin_test.h +++ b/src/tests/api/internals/plugin_test.h @@ -22,10 +22,10 @@ along with LOOT. If not, see . */ -#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" diff --git a/src/tests/api/internals/plugin/plugin_sorter_test.h b/src/tests/api/internals/sorting/plugin_sorter_test.h similarity index 98% rename from src/tests/api/internals/plugin/plugin_sorter_test.h rename to src/tests/api/internals/sorting/plugin_sorter_test.h index 9be048e4..4fc66763 100644 --- a/src/tests/api/internals/plugin/plugin_sorter_test.h +++ b/src/tests/api/internals/sorting/plugin_sorter_test.h @@ -22,10 +22,10 @@ along with LOOT. If not, see . */ -#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" diff --git a/src/tests/printers.h b/src/tests/printers.h index 43b73fc2..7a4770df 100644 --- a/src/tests/printers.h +++ b/src/tests/printers.h @@ -30,7 +30,7 @@ along with LOOT. If not, see #include #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"