aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-07 09:36:10 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commiteace2183970d97a52b5e6b1b07b3fab8bd7fd839 (patch)
treec2fe63b7849a83af9ba6a2ff115d0a578e454c6d
parent1d8ee4cd7de4608dbbaa8ef207da80a6ca819b6a (diff)
downloadpaludis-eace2183970d97a52b5e6b1b07b3fab8bd7fd839.tar.gz
paludis-eace2183970d97a52b5e6b1b07b3fab8bd7fd839.tar.xz
GetConstraintsForViaBinaryHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/get_constraints_for_via_binary_helper-fwd.hh31
-rw-r--r--paludis/resolver/get_constraints_for_via_binary_helper.cc84
-rw-r--r--paludis/resolver/get_constraints_for_via_binary_helper.hh52
-rw-r--r--paludis/resolver/resolver_test.cc27
-rw-r--r--paludis/resolver/resolver_test.hh7
-rw-r--r--src/clients/cave/resolve_common.cc31
7 files changed, 178 insertions, 56 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 6da5b94..a06bd0e 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -45,6 +45,7 @@ noinst_HEADERS = \
find_repository_for_helper.hh find_repository_for_helper-fwd.hh \
get_constraints_for_dependent_helper.hh get_constraints_for_dependent_helper-fwd.hh \
get_constraints_for_purge_helper.hh get_constraints_for_dependent_helper-fwd.hh \
+ get_constraints_for_via_binary_helper.hh get_constraints_for_via_binary_helper-fwd.hh \
job.hh job-fwd.hh \
job_list.hh job_list-fwd.hh \
job_lists.hh job_lists-fwd.hh \
@@ -89,6 +90,7 @@ libpaludisresolver_a_SOURCES = \
find_repository_for_helper.cc \
get_constraints_for_dependent_helper.cc \
get_constraints_for_purge_helper.cc \
+ get_constraints_for_via_binary_helper.cc \
job.cc \
job_list.cc \
job_lists.cc \
diff --git a/paludis/resolver/get_constraints_for_via_binary_helper-fwd.hh b/paludis/resolver/get_constraints_for_via_binary_helper-fwd.hh
new file mode 100644
index 0000000..f4219d7
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_via_binary_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_VIA_BINARY_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_VIA_BINARY_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct GetConstraintsForViaBinaryHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/get_constraints_for_via_binary_helper.cc b/paludis/resolver/get_constraints_for_via_binary_helper.cc
new file mode 100644
index 0000000..3f4cd7c
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_via_binary_helper.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<GetConstraintsForViaBinaryHelper>
+ {
+ const Environment * const env;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+GetConstraintsForViaBinaryHelper::GetConstraintsForViaBinaryHelper(const Environment * const e) :
+ Pimp<GetConstraintsForViaBinaryHelper>(e)
+{
+}
+
+GetConstraintsForViaBinaryHelper::~GetConstraintsForViaBinaryHelper() = default;
+
+const std::shared_ptr<ConstraintSequence>
+GetConstraintsForViaBinaryHelper::operator() (
+ const std::shared_ptr<const Resolution> & resolution,
+ const std::shared_ptr<const Resolution> & other_resolution) const
+{
+ auto result(std::make_shared<ConstraintSequence>());
+
+ PartiallyMadePackageDepSpec partial_spec({ });
+ partial_spec.package(resolution->resolvent().package());
+ PackageDepSpec spec(partial_spec);
+
+ auto reason(std::make_shared<ViaBinaryReason>(other_resolution->resolvent()));
+
+ result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
+ n::destination_type() = resolution->resolvent().destination_type(),
+ n::nothing_is_fine_too() = false,
+ n::reason() = reason,
+ n::spec() = spec,
+ n::untaken() = true,
+ n::use_existing() = ue_never
+ )));
+
+ return result;
+}
+
+template class Pimp<GetConstraintsForViaBinaryHelper>;
+
diff --git a/paludis/resolver/get_constraints_for_via_binary_helper.hh b/paludis/resolver/get_constraints_for_via_binary_helper.hh
new file mode 100644
index 0000000..bdb3d81
--- /dev/null
+++ b/paludis/resolver/get_constraints_for_via_binary_helper.hh
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_VIA_BINARY_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_CONSTRAINTS_FOR_VIA_BINARY_HELPER_HH 1
+
+#include <paludis/resolver/get_constraints_for_via_binary_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/resolver/constraint-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE GetConstraintsForViaBinaryHelper :
+ private Pimp<GetConstraintsForViaBinaryHelper>
+ {
+ public:
+ explicit GetConstraintsForViaBinaryHelper(const Environment * const);
+ ~GetConstraintsForViaBinaryHelper();
+
+ const std::shared_ptr<ConstraintSequence> operator() (
+ const std::shared_ptr<const Resolution> &,
+ const std::shared_ptr<const Resolution> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::GetConstraintsForViaBinaryHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 9c018dd..2c8d7a3 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -222,28 +222,6 @@ paludis::resolver::resolver_test::order_early_fn(
return indeterminate;
}
-const std::shared_ptr<ConstraintSequence>
-paludis::resolver::resolver_test::get_constraints_for_via_binary_fn(
- const std::shared_ptr<const Resolution> & resolution,
- const std::shared_ptr<const Resolution> & because_resolution)
-{
- PartiallyMadePackageDepSpec partial_spec({ });
- partial_spec.package(resolution->resolvent().package());
- PackageDepSpec spec(partial_spec);
-
- std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
- result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
- n::destination_type() = resolution->resolvent().destination_type(),
- n::nothing_is_fine_too() = false,
- n::reason() = std::make_shared<ViaBinaryReason>(because_resolution->resolvent()),
- n::spec() = spec,
- n::untaken() = false,
- n::use_existing() = ue_if_possible
- )));
-
- return result;
-}
-
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
@@ -256,7 +234,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
confirm_helper(&env),
find_repository_for_helper(&env),
get_constraints_for_dependent_helper(&env),
- get_constraints_for_purge_helper(&env)
+ get_constraints_for_purge_helper(&env),
+ get_constraints_for_via_binary_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -310,7 +289,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::find_repository_for_fn() = std::cref(find_repository_for_helper),
n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = std::cref(get_constraints_for_purge_helper),
- n::get_constraints_for_via_binary_fn() = &get_constraints_for_via_binary_fn,
+ n::get_constraints_for_via_binary_fn() = std::cref(get_constraints_for_via_binary_helper),
n::get_destination_types_for_error_fn() = &get_destination_types_for_error_fn,
n::get_initial_constraints_for_fn() =
std::bind(&initial_constraints_for_fn, std::ref(initial_constraints),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 31d3686..1568640 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -43,6 +43,7 @@
#include <paludis/resolver/find_repository_for_helper.hh>
#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
+#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -81,11 +82,6 @@ namespace paludis
const InitialConstraints & initial_constraints,
const Resolvent & resolvent);
- const std::shared_ptr<ConstraintSequence>
- get_constraints_for_via_binary_fn(
- const std::shared_ptr<const Resolution> &,
- const std::shared_ptr<const Resolution> &);
-
std::shared_ptr<Resolvents> get_resolvents_for_fn(
const Environment * const,
const PackageDepSpec & spec,
@@ -136,6 +132,7 @@ namespace paludis
FindRepositoryForHelper find_repository_for_helper;
GetConstraintsForDependentHelper get_constraints_for_dependent_helper;
GetConstraintsForPurgeHelper get_constraints_for_purge_helper;
+ GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index fbd974f..bb59142 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -73,6 +73,7 @@
#include <paludis/resolver/find_repository_for_helper.hh>
#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
+#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1168,31 +1169,6 @@ namespace
return indeterminate;
}
- const std::shared_ptr<ConstraintSequence> get_constraints_for_via_binary_fn(
- const Environment * const,
- const std::shared_ptr<const Resolution> & resolution,
- const std::shared_ptr<const Resolution> & other_resolution)
- {
- const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
-
- PartiallyMadePackageDepSpec partial_spec({ });
- partial_spec.package(resolution->resolvent().package());
- PackageDepSpec spec(partial_spec);
-
- const std::shared_ptr<ViaBinaryReason> reason(std::make_shared<ViaBinaryReason>(other_resolution->resolvent()));
-
- result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
- n::destination_type() = resolution->resolvent().destination_type(),
- n::nothing_is_fine_too() = false,
- n::reason() = reason,
- n::spec() = spec,
- n::untaken() = true,
- n::use_existing() = ue_never
- )));
-
- return result;
- }
-
void serialise_resolved(StringListStream & ser_stream, const Resolved & resolved)
{
Serialiser ser(ser_stream);
@@ -1699,6 +1675,8 @@ paludis::cave::resolve_common(
i != i_end ; ++i)
get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper(env.get());
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
@@ -1708,8 +1686,7 @@ paludis::cave::resolve_common(
n::find_repository_for_fn() = std::cref(find_repository_for_helper),
n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = std::cref(get_constraints_for_purge_helper),
- n::get_constraints_for_via_binary_fn() = std::bind(&get_constraints_for_via_binary_fn,
- env.get(), _1, _2),
+ n::get_constraints_for_via_binary_fn() = std::cref(get_constraints_for_via_binary_helper),
n::get_destination_types_for_error_fn() = std::bind(&get_destination_types_for_fn,
env.get(), std::cref(resolution_options), _1, make_null_shared_ptr(), _2),
n::get_initial_constraints_for_fn() = std::bind(&initial_constraints_for_fn,