aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-10 09:05:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-10 01:54:20 +0100
commit84daa318b72accbd8ee7e92654a4803fa2e37eb7 (patch)
treeecaa7dae385cfc335522e4e31ee8e0f4700501fd
parent5644993d39a614216c354b59e19b27e258f98a88 (diff)
downloadpaludis-84daa318b72accbd8ee7e92654a4803fa2e37eb7.tar.gz
paludis-84daa318b72accbd8ee7e92654a4803fa2e37eb7.tar.xz
Generalise destination types
-rw-r--r--paludis/resolver/Makefile.am11
-rw-r--r--paludis/resolver/constraint.cc17
-rw-r--r--paludis/resolver/constraint.hh8
-rw-r--r--paludis/resolver/destination_types-fwd.hh38
-rw-r--r--paludis/resolver/destination_types.cc30
-rw-r--r--paludis/resolver/destination_types.hh33
-rw-r--r--paludis/resolver/destination_types.se14
-rw-r--r--paludis/resolver/resolver.cc16
-rw-r--r--paludis/resolver/resolver.hh3
-rw-r--r--paludis/resolver/serialise-impl.hh50
-rw-r--r--src/clients/cave/cmd_display_resolution.cc18
-rw-r--r--src/clients/cave/cmd_resolve.cc2
12 files changed, 213 insertions, 27 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 7735ab6..3388ac1 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -2,13 +2,16 @@ CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT *.epicfail
MAINTAINERCLEANFILES = Makefile.in
DISTCLEANFILES = \
decision-se.hh decision-se.cc \
+ destination_types-se.hh destination_types-se.cc \
use_installed-se.hh use_installed-se.cc
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
EXTRA_DIST = \
decision-se.hh decision-se.cc decision.se \
+ destination_types-se.hh destination_types-se.cc destination_types.se \
use_installed-se.hh use_installed-se.cc use_installed.se
BUILT_SOURCES = \
decision-se.hh decision-se.cc \
+ destination_types-se.hh destination_types-se.cc \
use_installed-se.hh use_installed-se.cc
TESTS =
@@ -17,6 +20,7 @@ noinst_HEADERS = \
arrow.hh arrow-fwd.hh \
constraint.hh constraint-fwd.hh \
decision.hh decision-fwd.hh decision-se.hh \
+ destination_types.hh destination_types-fwd.hh destination_types-se.hh \
destinations.hh destinations-fwd.hh \
qpn_s.hh qpn_s-fwd.hh \
reason.hh reason-fwd.hh \
@@ -33,6 +37,7 @@ libpaludisresolver_a_SOURCES = \
arrow.cc \
constraint.cc \
decision.cc \
+ destination_types.cc \
destinations.cc \
qpn_s.cc \
reason.cc \
@@ -81,3 +86,9 @@ decision-se.hh : decision.se $(top_srcdir)/misc/make_se.bash
decision-se.cc : decision.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/decision.se > $@ ; then rm -f $@ ; exit 1 ; fi
+destination_types-se.hh : destination_types.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/destination_types.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
+destination_types-se.cc : destination_types.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/destination_types.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index e1458d7..76bebf8 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -38,13 +38,12 @@ namespace paludis
{
UseInstalled strictest_use_installed;
bool nothing_is_fine_too;
- bool to_destination_slash;
+ DestinationTypes to_destinations;
Sequence<std::tr1::shared_ptr<const Constraint> > constraints;
Implementation() :
strictest_use_installed(ui_if_possible),
- nothing_is_fine_too(true),
- to_destination_slash(false)
+ nothing_is_fine_too(true)
{
}
};
@@ -77,7 +76,7 @@ Constraints::add(const std::tr1::shared_ptr<const Constraint> & c)
_imp->constraints.push_back(c);
_imp->strictest_use_installed = std::min(_imp->strictest_use_installed, c->use_installed());
_imp->nothing_is_fine_too = _imp->nothing_is_fine_too && c->nothing_is_fine_too();
- _imp->to_destination_slash = _imp->to_destination_slash || c->to_destination_slash();
+ _imp->to_destinations |= c->to_destinations();
}
bool
@@ -98,10 +97,10 @@ Constraints::nothing_is_fine_too() const
return _imp->nothing_is_fine_too;
}
-bool
-Constraints::to_destination_slash() const
+const DestinationTypes
+Constraints::to_destinations() const
{
- return _imp->to_destination_slash;
+ return _imp->to_destinations;
}
void
@@ -130,7 +129,7 @@ Constraint::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "nothing_is_fine_too", nothing_is_fine_too())
.member(SerialiserFlags<serialise::might_be_null>(), "reason", reason())
.member(SerialiserFlags<>(), "spec", spec())
- .member(SerialiserFlags<>(), "to_destination_slash", to_destination_slash())
+ .member(SerialiserFlags<>(), "to_destinations", to_destinations())
.member(SerialiserFlags<>(), "use_installed", stringify(use_installed()))
;
}
@@ -176,7 +175,7 @@ Constraint::deserialise(Deserialisation & d)
value_for<n::reason>(reason),
value_for<n::spec>(PackageOrBlockDepSpec::deserialise(*v.find_remove_member("spec"),
reason->accept_returning<std::tr1::shared_ptr<const PackageID> >(id_finder))),
- value_for<n::to_destination_slash>(v.member<bool>("to_destination_slash")),
+ value_for<n::to_destinations>(v.member<DestinationTypes>("to_destinations")),
value_for<n::use_installed>(destringify<UseInstalled>(v.member<std::string>("use_installed")))
)));
}
diff --git a/paludis/resolver/constraint.hh b/paludis/resolver/constraint.hh
index 2c8c760..f244dd0 100644
--- a/paludis/resolver/constraint.hh
+++ b/paludis/resolver/constraint.hh
@@ -25,7 +25,9 @@
#include <paludis/resolver/use_installed-fwd.hh>
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/serialise-fwd.hh>
+#include <paludis/resolver/destination_types.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/util/options.hh>
#include <paludis/dep_spec.hh>
#include <tr1/memory>
@@ -36,7 +38,7 @@ namespace paludis
struct nothing_is_fine_too;
struct reason;
struct spec;
- struct to_destination_slash;
+ struct to_destinations;
struct use_installed;
}
@@ -47,7 +49,7 @@ namespace paludis
NamedValue<n::nothing_is_fine_too, bool> nothing_is_fine_too;
NamedValue<n::reason, std::tr1::shared_ptr<const Reason> > reason;
NamedValue<n::spec, PackageOrBlockDepSpec> spec;
- NamedValue<n::to_destination_slash, bool> to_destination_slash;
+ NamedValue<n::to_destinations, DestinationTypes> to_destinations;
NamedValue<n::use_installed, UseInstalled> use_installed;
void serialise(Serialiser &) const;
@@ -65,7 +67,7 @@ namespace paludis
UseInstalled strictest_use_installed() const PALUDIS_ATTRIBUTE((warn_unused_result));
bool nothing_is_fine_too() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool to_destination_slash() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const DestinationTypes to_destinations() const PALUDIS_ATTRIBUTE((warn_unused_result));
void add(const std::tr1::shared_ptr<const Constraint> &);
diff --git a/paludis/resolver/destination_types-fwd.hh b/paludis/resolver/destination_types-fwd.hh
new file mode 100644
index 0000000..d4dd07b
--- /dev/null
+++ b/paludis/resolver/destination_types-fwd.hh
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_DESTINATION_TYPES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_TYPES_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ namespace resolver
+ {
+
+#include <paludis/resolver/destination_types-se.hh>
+
+ typedef Options<DestinationType> DestinationTypes;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/destination_types.cc b/paludis/resolver/destination_types.cc
new file mode 100644
index 0000000..8a5181b
--- /dev/null
+++ b/paludis/resolver/destination_types.cc
@@ -0,0 +1,30 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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/destination_types.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/exception.hh>
+#include <istream>
+#include <ostream>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+#include <paludis/resolver/destination_types-se.cc>
+
diff --git a/paludis/resolver/destination_types.hh b/paludis/resolver/destination_types.hh
new file mode 100644
index 0000000..ac0d5f5
--- /dev/null
+++ b/paludis/resolver/destination_types.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_DESTINATION_TYPES_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_TYPES_HH 1
+
+#include <paludis/resolver/destination_types-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+
+ }
+}
+
+#endif
diff --git a/paludis/resolver/destination_types.se b/paludis/resolver/destination_types.se
new file mode 100644
index 0000000..0fa1bc9
--- /dev/null
+++ b/paludis/resolver/destination_types.se
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_DestinationType()
+{
+ prefix dt
+ namespace paludis::resolver
+
+ key dt_slash "The / fs"
+
+ want_destringify
+}
+
+
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index a899cbd..6c92146 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -180,7 +180,7 @@ Resolver::_make_destinations_for(const QPN_S & qpn_s,
break;
}
- bool requires_slash(resolution->constraints()->to_destination_slash());
+ bool requires_slash(resolution->constraints()->to_destinations()[dt_slash]);
return make_shared_ptr(new Destinations(
make_named_values<Destinations>(
@@ -378,7 +378,7 @@ Resolver::_make_constraint_from_target(
value_for<n::nothing_is_fine_too>(false),
value_for<n::reason>(reason),
value_for<n::spec>(spec),
- value_for<n::to_destination_slash>(true),
+ value_for<n::to_destinations>(DestinationTypes() + dt_slash),
value_for<n::use_installed>(_imp->fns.get_use_installed_fn()(qpn_s, spec, reason))
)));
}
@@ -392,7 +392,7 @@ Resolver::_make_constraint_from_dependency(const QPN_S & qpn_s, const SanitisedD
value_for<n::nothing_is_fine_too>(false),
value_for<n::reason>(reason),
value_for<n::spec>(*dep.spec().if_package()),
- value_for<n::to_destination_slash>(_dependency_to_destination_slash(qpn_s, dep)),
+ value_for<n::to_destinations>(_destination_types_for_dependency(qpn_s, dep)),
value_for<n::use_installed>(_imp->fns.get_use_installed_fn()(qpn_s, *dep.spec().if_package(), reason))
)));
else if (dep.spec().if_block())
@@ -406,7 +406,7 @@ Resolver::_make_constraint_from_dependency(const QPN_S & qpn_s, const SanitisedD
value_for<n::nothing_is_fine_too>(ids->empty()),
value_for<n::reason>(reason),
value_for<n::spec>(dep.spec()),
- value_for<n::to_destination_slash>(true),
+ value_for<n::to_destinations>(DestinationTypes() + dt_slash),
value_for<n::use_installed>(ui_if_possible)
)));
}
@@ -534,7 +534,7 @@ Resolver::_make_constraint_for_preloading(
value_for<n::nothing_is_fine_too>(false),
value_for<n::reason>(reason),
value_for<n::spec>(d->if_package_id()->uniquely_identifying_spec()),
- value_for<n::to_destination_slash>(false),
+ value_for<n::to_destinations>(DestinationTypes()),
value_for<n::use_installed>(_imp->fns.get_use_installed_fn()(
qpn_s, d->if_package_id()->uniquely_identifying_spec(), reason))
)));
@@ -883,10 +883,10 @@ Resolver::_initial_constraints_for(const QPN_S & qpn_s) const
return _imp->fns.get_initial_constraints_for_fn()(qpn_s);
}
-bool
-Resolver::_dependency_to_destination_slash(const QPN_S &, const SanitisedDependency &) const
+DestinationTypes
+Resolver::_destination_types_for_dependency(const QPN_S &, const SanitisedDependency &) const
{
- return true;
+ return DestinationTypes() + dt_slash;
}
Resolver::ResolutionsByQPN_SConstIterator
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index e6b7df9..108b230 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -31,6 +31,7 @@
#include <paludis/resolver/destinations-fwd.hh>
#include <paludis/resolver/resolutions-fwd.hh>
#include <paludis/resolver/resolver_functions-fwd.hh>
+#include <paludis/resolver/destination_types-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -131,7 +132,7 @@ namespace paludis
const std::tr1::shared_ptr<Constraints> _initial_constraints_for(const QPN_S &) const;
- bool _dependency_to_destination_slash(
+ DestinationTypes _destination_types_for_dependency(
const QPN_S &, const SanitisedDependency &) const;
bool _same_slot(const std::tr1::shared_ptr<const PackageID> & a,
diff --git a/paludis/resolver/serialise-impl.hh b/paludis/resolver/serialise-impl.hh
index 81b6941..c2c05c6 100644
--- a/paludis/resolver/serialise-impl.hh
+++ b/paludis/resolver/serialise-impl.hh
@@ -24,9 +24,12 @@
#include <paludis/util/remove_shared_ptr.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/tokeniser.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <tr1/type_traits>
+#include <list>
#include <ostream>
#include <istream>
@@ -77,11 +80,24 @@ namespace paludis
template <
typename T_>
- struct SerialiserObjectWriterHandler<false, false, T_>
+ struct SerialiserObjectWriterHandler<false, false, Options<T_> >
{
- static void write(Serialiser & s, const T_ & t)
+ static void write(Serialiser & s, const Options<T_> & t)
{
- t.serialise(s);
+ std::stringstream ss;
+ for (T_ i(static_cast<T_>(0)), i_end(t.highest_bit()) ;
+ i != i_end ; i = static_cast<T_>(static_cast<int>(i) + 1))
+ {
+ if (! t[i])
+ continue;
+ if (! ss.str().empty())
+ ss << ",";
+ ss << i;
+ }
+
+ s.raw_stream() << "\"";
+ s.escape_write(ss.str());
+ s.raw_stream() << "\";";
}
};
@@ -96,6 +112,16 @@ namespace paludis
};
template <
+ typename T_>
+ struct SerialiserObjectWriterHandler<false, false, T_>
+ {
+ static void write(Serialiser & s, const T_ & t)
+ {
+ t.serialise(s);
+ }
+ };
+
+ template <
bool is_container_,
typename T_>
struct SerialiserObjectWriterHandler<is_container_, true, T_>
@@ -208,6 +234,24 @@ namespace paludis
};
template <typename T_>
+ struct DeserialisatorHandler<Options<T_> >
+ {
+ static Options<T_> handle(Deserialisation & v)
+ {
+ Options<T_> result;
+ std::list<std::string> tokens;
+ tokenise<delim_kind::AnyOfTag, delim_mode::BoundaryTag>(v.string_value(),
+ ",", "", std::back_inserter(tokens));
+
+ for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ result += destringify<T_>(*t);
+
+ return result;
+ }
+ };
+
+ template <typename T_>
struct DeserialisatorHandler
{
static T_ handle(Deserialisation & v)
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index f1ba9b2..cdb9835 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -561,8 +561,22 @@ namespace
break;
}
- if ((*c)->to_destination_slash())
- std::cout << ", installing to /";
+ for (DestinationType t(static_cast<DestinationType>(0)), t_end(last_dt) ;
+ t != t_end ; t = static_cast<DestinationType>(static_cast<int>(t) + 1))
+ {
+ if (! (*c)->to_destinations()[t])
+ continue;
+
+ switch (t)
+ {
+ case dt_slash:
+ std::cout << ", installing to /";
+ break;
+
+ case last_dt:
+ break;
+ }
+ }
std::cout << std::endl;
std::cout << " Because of ";
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 0feff2d..6373e2e 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -256,7 +256,7 @@ namespace
value_for<n::nothing_is_fine_too>(false),
value_for<n::reason>(make_shared_ptr(new PresetReason)),
value_for<n::spec>(make_package_dep_spec(PartiallyMadePackageDepSpecOptions()).package(qpn_s.package())),
- value_for<n::to_destination_slash>(false),
+ value_for<n::to_destinations>(DestinationTypes()),
value_for<n::use_installed>(ui_only_if_transient)
))));
}