aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-06 17:13:36 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:06 +0100
commitd73bac2f42d4bf4d4a8c3ef75fdee0f1c22cc44b (patch)
tree47a009b3baeec15a005593debe269159113c7139
parent9f3154c1979e28b6f26a584bf0454c85f173fc29 (diff)
downloadpaludis-d73bac2f42d4bf4d4a8c3ef75fdee0f1c22cc44b.tar.gz
paludis-d73bac2f42d4bf4d4a8c3ef75fdee0f1c22cc44b.tar.xz
AllowChoiceChangesHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/allow_choice_changes_helper-fwd.hh31
-rw-r--r--paludis/resolver/allow_choice_changes_helper.cc60
-rw-r--r--paludis/resolver/allow_choice_changes_helper.hh50
-rw-r--r--paludis/resolver/resolver_test.cc6
-rw-r--r--paludis/resolver/resolver_test.hh10
-rw-r--r--src/clients/cave/resolve_common.cc11
7 files changed, 165 insertions, 5 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index ca7318f..ae18745 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -28,6 +28,7 @@ BUILT_SOURCES = \
use_existing-se.hh use_existing-se.cc
noinst_HEADERS = \
+ allow_choice_changes_helper.hh allow_choice_changes_helper-fwd.hh \
any_child_score.hh any_child_score-fwd.hh any_child_score-se.hh \
change_by_resolvent.hh change_by_resolvent-fwd.hh \
change_type.hh change_type-fwd.hh change_type-se.hh \
@@ -64,6 +65,7 @@ noinst_HEADERS = \
use_existing.hh use_existing-fwd.hh use_existing-se.hh
libpaludisresolver_a_SOURCES = \
+ allow_choice_changes_helper.cc \
any_child_score.cc \
change_by_resolvent.cc \
change_type.cc \
diff --git a/paludis/resolver/allow_choice_changes_helper-fwd.hh b/paludis/resolver/allow_choice_changes_helper-fwd.hh
new file mode 100644
index 0000000..af42698
--- /dev/null
+++ b/paludis/resolver/allow_choice_changes_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_ALLOW_CHOICE_CHANGES_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOW_CHOICE_CHANGES_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct AllowChoiceChangesHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/allow_choice_changes_helper.cc b/paludis/resolver/allow_choice_changes_helper.cc
new file mode 100644
index 0000000..7eecd10
--- /dev/null
+++ b/paludis/resolver/allow_choice_changes_helper.cc
@@ -0,0 +1,60 @@
+/* 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/allow_choice_changes_helper.hh>
+#include <paludis/util/pimp-impl.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<AllowChoiceChangesHelper>
+ {
+ bool allow_choice_changes;
+
+ Imp() :
+ allow_choice_changes(true)
+ {
+ }
+ };
+}
+
+AllowChoiceChangesHelper::AllowChoiceChangesHelper(const Environment * const) :
+ Pimp<AllowChoiceChangesHelper>()
+{
+}
+
+AllowChoiceChangesHelper::~AllowChoiceChangesHelper() = default;
+
+void
+AllowChoiceChangesHelper::set_allow_choice_changes(const bool v)
+{
+ _imp->allow_choice_changes = v;
+}
+
+bool
+AllowChoiceChangesHelper::operator() (const std::shared_ptr<const Resolution> &) const
+{
+ return _imp->allow_choice_changes;
+}
+
+template class Pimp<AllowChoiceChangesHelper>;
+
diff --git a/paludis/resolver/allow_choice_changes_helper.hh b/paludis/resolver/allow_choice_changes_helper.hh
new file mode 100644
index 0000000..a26cf98
--- /dev/null
+++ b/paludis/resolver/allow_choice_changes_helper.hh
@@ -0,0 +1,50 @@
+/* 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_ALLOW_CHOICE_CHANGES_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOW_CHOICE_CHANGES_HELPER_HH 1
+
+#include <paludis/resolver/allow_choice_changes_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE AllowChoiceChangesHelper :
+ private Pimp<AllowChoiceChangesHelper>
+ {
+ public:
+ explicit AllowChoiceChangesHelper(const Environment * const);
+ ~AllowChoiceChangesHelper();
+
+ void set_allow_choice_changes(const bool);
+
+ bool operator() (const std::shared_ptr<const Resolution> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::AllowChoiceChangesHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index c786d8d..19630b7 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -39,7 +39,6 @@
#include <paludis/util/set-impl.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/simple_visitor_cast.hh>
-#include <paludis/util/return_literal_function.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repository_factory.hh>
#include <paludis/package_database.hh>
@@ -352,7 +351,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
TestCase(s),
allowed_to_remove_names(std::make_shared<QualifiedPackageNameSet>()),
remove_if_dependent_names(std::make_shared<QualifiedPackageNameSet>()),
- prefer_or_avoid_names(std::make_shared<Map<QualifiedPackageName, bool>>())
+ prefer_or_avoid_names(std::make_shared<Map<QualifiedPackageName, bool>>()),
+ allow_choice_changes_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -398,7 +398,7 @@ ResolverFunctions
ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraints)
{
return make_named_values<ResolverFunctions>(
- n::allow_choice_changes_fn() = std::bind(return_literal_function(true)),
+ n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::bind(&allowed_to_remove_fn,
allowed_to_remove_names, std::placeholders::_1, std::placeholders::_2),
n::always_via_binary_fn() = &always_via_binary_fn,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 6ae71fb..7356863 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -34,14 +34,22 @@
#include <paludis/resolver/package_or_block_dep_spec-fwd.hh>
#include <paludis/resolver/resolved-fwd.hh>
#include <paludis/resolver/change_by_resolvent-fwd.hh>
+
+#include <paludis/resolver/allow_choice_changes_helper.hh>
+
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/map-fwd.hh>
+
#include <paludis/dep_spec-fwd.hh>
#include <paludis/filtered_generator-fwd.hh>
#include <paludis/generator-fwd.hh>
+
#include <test/test_framework.hh>
+
#include <memory>
#include <string>
#include <map>
@@ -146,6 +154,8 @@ namespace paludis
std::shared_ptr<QualifiedPackageNameSet> remove_if_dependent_names;
std::shared_ptr<Map<QualifiedPackageName, bool> > prefer_or_avoid_names;
+ AllowChoiceChangesHelper allow_choice_changes_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 d551062..a754ed4 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -45,8 +45,10 @@
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/return_literal_function.hh>
+
#include <paludis/args/do_help.hh>
#include <paludis/args/escape.hh>
+
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
@@ -62,6 +64,9 @@
#include <paludis/resolver/decisions.hh>
#include <paludis/resolver/change_by_resolvent.hh>
#include <paludis/resolver/labels_classifier.hh>
+
+#include <paludis/resolver/allow_choice_changes_helper.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/generator.hh>
@@ -1987,9 +1992,11 @@ paludis::cave::resolve_common(
using std::placeholders::_3;
using std::placeholders::_4;
+ AllowChoiceChangesHelper allow_choice_changes_helper(env.get());;
+ allow_choice_changes_helper.set_allow_choice_changes(! resolution_options.a_no_override_flags.specified());
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
- n::allow_choice_changes_fn() = std::bind(return_literal_function(
- ! resolution_options.a_no_override_flags.specified())),
+ n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::bind(&allowed_to_remove_fn,
env.get(), std::cref(allowed_to_remove_specs), _1, _2),
n::always_via_binary_fn() = std::bind(&always_via_binary_fn,