-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify MPool Interface #3177
Simplify MPool Interface #3177
Changes from all commits
2df4398
541c812
444c082
2ba207b
5b8725e
9644aed
856068c
fd7da61
5949ac3
0bd9a97
505335a
a3b7823
2f3de75
2b77663
fcd54d3
a4c1a2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,20 +7,19 @@ | |||||
#ifndef MAMBA_CORE_POOL_HPP | ||||||
#define MAMBA_CORE_POOL_HPP | ||||||
|
||||||
#include <functional> | ||||||
#include <memory> | ||||||
#include <optional> | ||||||
|
||||||
#include <solv/pooltypes.h> | ||||||
|
||||||
#include "mamba/core/error_handling.hpp" | ||||||
#include "mamba/solver/libsolv/parameters.hpp" | ||||||
#include "mamba/solver/libsolv/repo_info.hpp" | ||||||
#include "mamba/specs/channel.hpp" | ||||||
#include "mamba/specs/package_info.hpp" | ||||||
#include "mamba/util/loop_control.hpp" | ||||||
|
||||||
namespace mamba | ||||||
{ | ||||||
class ChannelContext; | ||||||
class Context; | ||||||
class PrefixData; | ||||||
class SubdirData; | ||||||
|
@@ -40,6 +39,12 @@ namespace mamba | |||||
class MatchSpec; | ||||||
} | ||||||
|
||||||
namespace solver::libsolv | ||||||
{ | ||||||
class Solver; | ||||||
class UnSolvable; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Pool of solvable involved in resolving en environment. | ||||||
* | ||||||
|
@@ -52,26 +57,20 @@ namespace mamba | |||||
{ | ||||||
public: | ||||||
|
||||||
MPool(Context& ctx, ChannelContext& channel_context); | ||||||
~MPool(); | ||||||
|
||||||
void set_debuglevel(); | ||||||
void create_whatprovides(); | ||||||
using logger_type = std::function<void(solver::libsolv::LogLevel, std::string_view)>; | ||||||
|
||||||
std::vector<Id> select_solvables(Id id, bool sorted = false) const; | ||||||
Id matchspec2id(const specs::MatchSpec& ms); | ||||||
MPool(specs::ChannelResolveParams channel_params); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do it in the next PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do it in the next PR |
||||||
~MPool(); | ||||||
|
||||||
std::optional<specs::PackageInfo> id2pkginfo(Id solv_id) const; | ||||||
std::optional<std::string> dep2str(Id dep_id) const; | ||||||
[[nodiscard]] auto channel_params() const -> const specs::ChannelResolveParams&; | ||||||
|
||||||
// TODO: (TMP) This is not meant to be public but is needed for a transition period | ||||||
solv::ObjPool& pool(); | ||||||
const solv::ObjPool& pool() const; | ||||||
void set_logger(logger_type callback); | ||||||
|
||||||
auto add_repo_from_repodata_json( | ||||||
const fs::u8path& path, | ||||||
std::string_view url, | ||||||
solver::libsolv::PipAsPythonDependency add = solver::libsolv::PipAsPythonDependency::No, | ||||||
solver::libsolv::UseOnlyTarBz2 only_tar = solver::libsolv::UseOnlyTarBz2::No, | ||||||
solver::libsolv::RepodataParser parser = solver::libsolv::RepodataParser::Mamba | ||||||
) -> expected_t<solver::libsolv::RepoInfo>; | ||||||
|
||||||
|
@@ -109,7 +108,7 @@ namespace mamba | |||||
void | ||||||
set_repo_priority(solver::libsolv::RepoInfo repo, solver::libsolv::Priorities priorities); | ||||||
|
||||||
void remove_repo(::Id repo_id, bool reuse_ids); | ||||||
void remove_repo(solver::libsolv::RepoInfo repo); | ||||||
|
||||||
template <typename Func> | ||||||
void for_each_package_in_repo(solver::libsolv::RepoInfo repo, Func&&) const; | ||||||
|
@@ -120,14 +119,20 @@ namespace mamba | |||||
template <typename Func> | ||||||
void for_each_package_depending_on(const specs::MatchSpec& ms, Func&&); | ||||||
|
||||||
ChannelContext& channel_context() const; | ||||||
const Context& context() const; | ||||||
/** A wrapper struct to fine-grain controll who can access the raw repr of the Pool. */ | ||||||
class Impl | ||||||
{ | ||||||
[[nodiscard]] static auto get(MPool& pool) -> solv::ObjPool&; | ||||||
[[nodiscard]] static auto get(const MPool& pool) -> const solv::ObjPool&; | ||||||
|
||||||
friend class solver::libsolv::Solver; | ||||||
friend class solver::libsolv::UnSolvable; | ||||||
}; | ||||||
|
||||||
private: | ||||||
|
||||||
struct MPoolData; | ||||||
|
||||||
|
||||||
/** | ||||||
* Make MPool behave like a shared_ptr (with move and copy). | ||||||
* | ||||||
|
@@ -142,6 +147,10 @@ namespace mamba | |||||
*/ | ||||||
std::shared_ptr<MPoolData> m_data; | ||||||
|
||||||
friend class Impl; | ||||||
auto pool() -> solv::ObjPool&; | ||||||
[[nodiscard]] auto pool() const -> const solv::ObjPool&; | ||||||
|
||||||
auto add_repo_from_packages_impl_pre(std::string_view name) -> solver::libsolv::RepoInfo; | ||||||
void add_repo_from_packages_impl_loop( | ||||||
const solver::libsolv::RepoInfo& repo, | ||||||
|
@@ -167,6 +176,8 @@ namespace mamba | |||||
}; | ||||||
|
||||||
// TODO machinery functions in separate files | ||||||
void add_spdlog_logger_to_pool(MPool& pool); | ||||||
|
||||||
auto load_subdir_in_pool(const Context& ctx, MPool& pool, const SubdirData& subdir) | ||||||
-> expected_t<solver::libsolv::RepoInfo>; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.