mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add DatabaseInterface::GetGroupsPath()
It returns the path between the two given groups that maximises user metadata and minimises masterlist metadata involved.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "loot/exception/cyclic_interaction_error.h"
|
||||
#include "loot/metadata/group.h"
|
||||
#include "loot/metadata/message.h"
|
||||
#include "loot/metadata/plugin_metadata.h"
|
||||
@@ -191,7 +192,8 @@ public:
|
||||
* metadata from the masterlist.
|
||||
* @returns An unordered set of Group objects.
|
||||
*/
|
||||
virtual std::unordered_set<Group> GetGroups(bool includeUserMetadata = true) const = 0;
|
||||
virtual std::unordered_set<Group> GetGroups(
|
||||
bool includeUserMetadata = true) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the groups that are defined or extended in the loaded userlist.
|
||||
@@ -207,6 +209,25 @@ public:
|
||||
*/
|
||||
virtual void SetUserGroups(const std::unordered_set<Group>& groups) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the "shortest" path between the two given groups according to
|
||||
* their load after metadata.
|
||||
* @details The "shortest" path is defined as the path that maximises the
|
||||
* amount of user metadata involved while minimising the amount of
|
||||
* masterlist metadata involved. It's not the path involving the
|
||||
* fewest groups.
|
||||
* @param fromGroupName
|
||||
* The name of the source group, that loads earlier.
|
||||
* @param toGroupName
|
||||
* The name of the destination group, that loads later.
|
||||
* @returns A vector of Vertex elements representing the path from the source
|
||||
* group to the destination group, or an empty vector if no path
|
||||
* exists.
|
||||
*/
|
||||
virtual std::vector<Vertex> GetGroupsPath(
|
||||
const std::string& fromGroupName,
|
||||
const std::string& toGroupName) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the groups
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2012-2016 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_EDGE_TYPE
|
||||
#define LOOT_EDGE_TYPE
|
||||
|
||||
/**
|
||||
* The namespace used by the LOOT API.
|
||||
*/
|
||||
namespace loot {
|
||||
/**
|
||||
* @brief An enum representing the different possible types of interactions
|
||||
* between plugins or groups.
|
||||
*/
|
||||
enum struct EdgeType : unsigned int {
|
||||
hardcoded,
|
||||
masterFlag,
|
||||
master,
|
||||
masterlistRequirement,
|
||||
userRequirement,
|
||||
masterlistLoadAfter,
|
||||
userLoadAfter,
|
||||
group,
|
||||
overlap,
|
||||
tieBreak,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -26,60 +26,11 @@
|
||||
#define LOOT_EXCEPTION_CYCLIC_INTERACTION_ERROR
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "loot/vertex.h"
|
||||
|
||||
namespace loot {
|
||||
/**
|
||||
* @brief An enum representing the different possible types of interactions
|
||||
* between plugins or groups.
|
||||
*/
|
||||
enum struct EdgeType : unsigned int {
|
||||
hardcoded,
|
||||
masterFlag,
|
||||
master,
|
||||
masterlistRequirement,
|
||||
userRequirement,
|
||||
masterlistLoadAfter,
|
||||
userLoadAfter,
|
||||
group,
|
||||
overlap,
|
||||
tieBreak,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class representing a plugin or group vertex in a cyclic interaction
|
||||
* path, and the type of the interaction with the next vertex in the
|
||||
* path.
|
||||
*/
|
||||
class Vertex {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a Vertex with the given name and out edge type.
|
||||
* @param name The name of the plugin or group that this vertex represents.
|
||||
* @param outEdgeType The type of the edge going out from this vertex.
|
||||
*/
|
||||
Vertex(std::string name, EdgeType outEdgeType);
|
||||
|
||||
/**
|
||||
* @brief Get the name of the plugin or group.
|
||||
* @return The name of the plugin or group.
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* @brief Get the type of the edge going to the next vertex.
|
||||
* @details Each edge goes from the vertex that loads earlier to the vertex
|
||||
* that loads later.
|
||||
* @return The edge type.
|
||||
*/
|
||||
EdgeType GetTypeOfEdgeToNextVertex() const;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
EdgeType outEdgeType_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An exception class thrown if a cyclic interaction is detected when
|
||||
* sorting a load order.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2014-2016 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_VERTEX
|
||||
#define LOOT_VERTEX
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "loot/api_decorator.h"
|
||||
#include "loot/enum/edge_type.h"
|
||||
|
||||
namespace loot {
|
||||
/**
|
||||
* @brief A class representing a plugin or group vertex in a path, and the
|
||||
type of the edge to the next vertex in the path if one exists.
|
||||
*/
|
||||
class Vertex {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a Vertex with the given name and no out edge.
|
||||
* @param name The name of the plugin or group that this vertex represents.
|
||||
*/
|
||||
LOOT_API Vertex(std::string name);
|
||||
|
||||
/**
|
||||
* @brief Construct a Vertex with the given name and out edge type.
|
||||
* @param name The name of the plugin or group that this vertex represents.
|
||||
* @param outEdgeType The type of the edge going out from this vertex.
|
||||
*/
|
||||
LOOT_API Vertex(std::string name, EdgeType outEdgeType);
|
||||
|
||||
/**
|
||||
* @brief Get the name of the plugin or group.
|
||||
* @return The name of the plugin or group.
|
||||
*/
|
||||
LOOT_API std::string GetName() const;
|
||||
|
||||
/**
|
||||
* @brief Get the type of the edge going to the next vertex.
|
||||
* @details Each edge goes from the vertex that loads earlier to the vertex
|
||||
* that loads later.
|
||||
* @return The edge type.
|
||||
*/
|
||||
LOOT_API std::optional<EdgeType> GetTypeOfEdgeToNextVertex() const;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::optional<EdgeType> outEdgeType_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user