| |
| |
| |
| |
| |
|
|
| #ifndef MAMBA_SOLVER_REQUEST_HPP |
| #define MAMBA_SOLVER_REQUEST_HPP |
|
|
| #include <type_traits> |
| #include <variant> |
|
|
| #include "mamba/specs/match_spec.hpp" |
| #include "mamba/util/loop_control.hpp" |
| #include "mamba/util/type_traits.hpp" |
|
|
| namespace mamba::solver |
| { |
| struct Request |
| { |
| struct Flags |
| { |
| |
| bool keep_dependencies = true; |
| |
| bool keep_user_specs = true; |
| |
| bool force_reinstall = false; |
| |
| bool allow_downgrade = true; |
| |
| bool allow_uninstall = true; |
| |
| bool strict_repo_priority = true; |
| |
| bool order_request = true; |
| }; |
|
|
| |
| struct Install |
| { |
| specs::MatchSpec spec; |
| }; |
|
|
| |
| struct Remove |
| { |
| specs::MatchSpec spec; |
| bool clean_dependencies = true; |
| }; |
|
|
| |
| struct Update |
| { |
| specs::MatchSpec spec; |
| bool clean_dependencies = true; |
| }; |
|
|
| |
| struct UpdateAll |
| { |
| bool clean_dependencies = true; |
| }; |
|
|
| |
| struct Keep |
| { |
| specs::MatchSpec spec; |
| }; |
|
|
| |
| struct Freeze |
| { |
| specs::MatchSpec spec; |
| }; |
|
|
| |
| struct Pin |
| { |
| specs::MatchSpec spec; |
| }; |
|
|
| using Job = std::variant<Install, Remove, Update, UpdateAll, Keep, Freeze, Pin>; |
| using job_list = std::vector<Job>; |
|
|
| Flags flags = {}; |
| job_list jobs = {}; |
| }; |
|
|
| template <typename... Item, typename Func> |
| void for_each_of(const Request& request, Func&& func) |
| { |
| for (const auto& unknown_job : request.jobs) |
| { |
| const auto control = std::visit( |
| [&](const auto& itm) -> util::LoopControl |
| { |
| using Itm = std::decay_t<decltype(itm)>; |
| if constexpr (util::is_any_of_v<Itm, Item...>) |
| { |
| if constexpr (std::is_same_v<decltype(func(itm)), util::LoopControl>) |
| { |
| return func(itm); |
| } |
| else |
| { |
| func(itm); |
| return util::LoopControl::Continue; |
| } |
| } |
| else |
| { |
| return util::LoopControl::Continue; |
| } |
| }, |
| unknown_job |
| ); |
| if (control == util::LoopControl::Break) |
| { |
| break; |
| } |
| } |
| } |
| } |
| #endif |
|
|