aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-29 22:36:02 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-29 22:36:02 +0100
commit368ffe6421de8efb8c90923ccc0f6411629cdeee (patch)
treeecb99bd3360cad492930b3b53dd6e15181491614
parent665a627924124fc55f169c13e90d95f5c2697e93 (diff)
downloadpaludis-368ffe6421de8efb8c90923ccc0f6411629cdeee.tar.gz
paludis-368ffe6421de8efb8c90923ccc0f6411629cdeee.tar.xz
moar
-rw-r--r--paludis/resolver/constraint-fwd.hh3
-rw-r--r--paludis/resolver/constraint.cc50
-rw-r--r--paludis/resolver/constraint.hh21
-rw-r--r--paludis/resolver/resolution.hh2
-rw-r--r--paludis/resolver/resolver.cc30
-rw-r--r--paludis/resolver/resolver.hh2
-rw-r--r--paludis/resolver/use_installed.se2
-rw-r--r--src/clients/cave/cmd_resolve.cc6
8 files changed, 91 insertions, 25 deletions
diff --git a/paludis/resolver/constraint-fwd.hh b/paludis/resolver/constraint-fwd.hh
index 9ee7491..e9943e9 100644
--- a/paludis/resolver/constraint-fwd.hh
+++ b/paludis/resolver/constraint-fwd.hh
@@ -30,8 +30,7 @@ namespace paludis
namespace resolver
{
struct Constraint;
-
- typedef Sequence<std::tr1::shared_ptr<const Constraint> > ConstraintSequence;
+ struct Constraints;
std::ostream & operator<< (std::ostream & s, const Constraint & c) PALUDIS_VISIBLE;
}
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index 7ec02f5..1b1e638 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -20,9 +20,10 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/reason.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/sequence-impl.hh>
#include <sstream>
+#include <list>
using namespace paludis;
using namespace paludis::resolver;
@@ -40,6 +41,49 @@ paludis::resolver::operator<< (std::ostream & s, const Constraint & c)
return s;
}
-template class Sequence<std::tr1::shared_ptr<const Constraint> >;
-template class WrappedForwardIterator<ConstraintSequence::ConstIteratorTag, const std::tr1::shared_ptr<const Constraint> >;
+namespace paludis
+{
+ template <>
+ struct Implementation<Constraints>
+ {
+ UseInstalled strictest_use_installed;
+ std::list<std::tr1::shared_ptr<const Constraint> > constraints;
+
+ Implementation() :
+ strictest_use_installed(ui_if_possible)
+ {
+ }
+ };
+}
+
+Constraints::Constraints() :
+ PrivateImplementationPattern<Constraints>(new Implementation<Constraints>)
+{
+}
+
+Constraints::~Constraints()
+{
+}
+
+Constraints::ConstIterator
+Constraints::begin() const
+{
+ return ConstIterator(_imp->constraints.begin());
+}
+
+Constraints::ConstIterator
+Constraints::end() const
+{
+ return ConstIterator(_imp->constraints.end());
+}
+
+void
+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());
+}
+
+template class PrivateImplementationPattern<Constraints>;
+template class WrappedForwardIterator<Constraints::ConstIteratorTag, const std::tr1::shared_ptr<const Constraint> >;
diff --git a/paludis/resolver/constraint.hh b/paludis/resolver/constraint.hh
index b94d566..a13d15b 100644
--- a/paludis/resolver/constraint.hh
+++ b/paludis/resolver/constraint.hh
@@ -44,7 +44,28 @@ namespace paludis
NamedValue<n::spec, PackageDepSpec> spec;
NamedValue<n::use_installed, UseInstalled> use_installed;
};
+
+ class PALUDIS_VISIBLE Constraints :
+ private PrivateImplementationPattern<Constraints>
+ {
+ public:
+ Constraints();
+ ~Constraints();
+
+ UseInstalled strictest_use_installed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void add(const std::tr1::shared_ptr<const Constraint> &);
+
+ struct ConstIteratorTag;
+ typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<const Constraint> > ConstIterator;
+ ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
}
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<resolver::Constraints>;
+#endif
}
#endif
diff --git a/paludis/resolver/resolution.hh b/paludis/resolver/resolution.hh
index 335a270..18d8fb4 100644
--- a/paludis/resolver/resolution.hh
+++ b/paludis/resolver/resolution.hh
@@ -43,7 +43,7 @@ namespace paludis
{
NamedValue<n::already_ordered, bool> already_ordered;
NamedValue<n::arrows, std::tr1::shared_ptr<ArrowSequence> > arrows;
- NamedValue<n::constraints, std::tr1::shared_ptr<ConstraintSequence> > constraints;
+ NamedValue<n::constraints, std::tr1::shared_ptr<Constraints> > constraints;
NamedValue<n::decision, std::tr1::shared_ptr<Decision> > decision;
};
}
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 5467a42..87a31c2 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -52,7 +52,7 @@ using namespace paludis;
using namespace paludis::resolver;
typedef std::map<QPN_S, std::tr1::shared_ptr<Resolution> > ResolutionsByQPN_SMap;
-typedef std::map<QPN_S, std::tr1::shared_ptr<ConstraintSequence> > InitialConstraints;
+typedef std::map<QPN_S, std::tr1::shared_ptr<Constraints> > InitialConstraints;
typedef std::list<std::tr1::shared_ptr<const Resolution> > OrderedResolutionsList;
namespace paludis
@@ -303,7 +303,7 @@ Resolver::_apply_resolution_constraint(
if (resolution->decision())
_verify_new_constraint(qpn_s, resolution, constraint);
- resolution->constraints()->push_back(constraint);
+ resolution->constraints()->add(constraint);
}
void
@@ -348,10 +348,6 @@ Resolver::_constraint_matches(
ok = ok && (decision->is_same_version() || decision->is_transient());
break;
- case ui_always:
- ok = ok && decision->is_installed();
- break;
-
case last_ui:
break;
}
@@ -423,7 +419,7 @@ Resolver::_best_id_from(
{
bool ok(true);
- for (ConstraintSequence::ConstIterator c(resolution->constraints()->begin()),
+ for (Constraints::ConstIterator c(resolution->constraints()->begin()),
c_end(resolution->constraints()->end()) ;
c != c_end ; ++c)
{
@@ -491,8 +487,8 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
}
bool
-Resolver::_care_about_dependency_spec(const QPN_S & qpn_s,
- const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency & dep) const
+Resolver::_care_about_dependency_spec(const QPN_S &,
+ const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency &) const
{
return true;
// return _desire_strength_from_sanitised_dependency(qpn_s, dep) >= ds_recommendation;
@@ -506,7 +502,7 @@ Resolver::_resolve_arrows()
for (ResolutionsByQPN_SMap::iterator i(_imp->resolutions_by_qpn_s.begin()), i_end(_imp->resolutions_by_qpn_s.end()) ;
i != i_end ; ++i)
{
- for (ConstraintSequence::ConstIterator c(i->second->constraints()->begin()),
+ for (Constraints::ConstIterator c(i->second->constraints()->begin()),
c_end(i->second->constraints()->end()) ;
c != c_end ; ++c)
{
@@ -702,7 +698,7 @@ Resolver::_unable_to_decide(
i != i_end ; ++i)
{
std::cout << " * " << **i << " doesn't match:" << std::endl;
- for (ConstraintSequence::ConstIterator c(resolution->constraints()->begin()),
+ for (Constraints::ConstIterator c(resolution->constraints()->begin()),
c_end(resolution->constraints()->end()) ;
c != c_end ; ++c)
if (! _constraint_matches(*c, _decision_from_package_id(qpn_s, *i)))
@@ -731,12 +727,12 @@ Resolver::_unable_to_order_more() const
throw InternalError(PALUDIS_HERE, "not implemented");
}
-const std::tr1::shared_ptr<ConstraintSequence>
+const std::tr1::shared_ptr<Constraints>
Resolver::_initial_constraints_for(const QPN_S & qpn_s) const
{
InitialConstraints::const_iterator i(_imp->initial_constraints.find(qpn_s));
if (i == _imp->initial_constraints.end())
- return make_shared_ptr(new ConstraintSequence);
+ return make_shared_ptr(new Constraints);
else
return i->second;
}
@@ -748,7 +744,7 @@ Resolver::_made_wrong_decision(const QPN_S & qpn_s,
{
/* can we find a resolution that works for all our constraints? */
std::tr1::shared_ptr<Resolution> adapted_resolution(make_shared_ptr(new Resolution(*resolution)));
- adapted_resolution->constraints()->push_back(constraint);
+ adapted_resolution->constraints()->add(constraint);
const std::tr1::shared_ptr<Decision> decision(_try_to_find_decision_for(qpn_s, adapted_resolution));
if (decision)
@@ -810,8 +806,8 @@ Resolver::add_initial_constraint(const QPN_S & q, const std::tr1::shared_ptr<con
{
InitialConstraints::iterator i(_imp->initial_constraints.find(q));
if (i == _imp->initial_constraints.end())
- i = _imp->initial_constraints.insert(std::make_pair(q, make_shared_ptr(new ConstraintSequence))).first;
- i->second->push_back(c);
+ i = _imp->initial_constraints.insert(std::make_pair(q, make_shared_ptr(new Constraints))).first;
+ i->second->add(c);
}
#if 0
@@ -992,7 +988,7 @@ Resolver::find_any_score(const QPN_S & our_qpn_s, const SanitisedDependency & de
{
const std::tr1::shared_ptr<Resolution> resolution(_create_resolution_for_qpn_s(*qpn_s));
const std::tr1::shared_ptr<Constraint> constraint(_make_constraint_from_dependency(our_qpn_s, dep));
- resolution->constraints()->push_back(constraint);
+ resolution->constraints()->add(constraint);
const std::tr1::shared_ptr<Decision> decision(_try_to_find_decision_for(*qpn_s, resolution));
if (decision)
return 20 + operator_bias;
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 3598462..c82f25c 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -115,7 +115,7 @@ namespace paludis
void _unable_to_order_more() const PALUDIS_ATTRIBUTE((noreturn));
- const std::tr1::shared_ptr<ConstraintSequence> _initial_constraints_for(const QPN_S &) const;
+ const std::tr1::shared_ptr<Constraints> _initial_constraints_for(const QPN_S &) const;
void _suggest_restart_with(const QPN_S &,
const std::tr1::shared_ptr<const Resolution> &,
diff --git a/paludis/resolver/use_installed.se b/paludis/resolver/use_installed.se
index 508378a..ec6e438 100644
--- a/paludis/resolver/use_installed.se
+++ b/paludis/resolver/use_installed.se
@@ -6,11 +6,11 @@ make_enum_UseInstalled()
prefix ui
namespace paludis::resolver
+ # must be kept in strictness order
key ui_never "Never"
key ui_only_if_transient "Only if it is transient"
key ui_if_same "If it is the same"
key ui_if_same_version "If it is the same version"
key ui_if_possible "If possible"
- key ui_always "Always"
}
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index c9335e5..14ebed6 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -139,6 +139,12 @@ namespace
// args::SwitchArg a_install_to_chroot;
// args::SwitchArg a_install_to_root;
+// args::ArgsGroup g_interactivity_options;
+// args::SwitchArg a_interactive;
+// args::SwitchArg a_interactive_slots;
+// args::SwitchArg a_interactive_decisions;
+// args::SwitchArg a_interactive_ordering;
+
args::ArgsGroup g_dump_options;
args::SwitchArg a_dump;
args::SwitchArg a_dump_dependencies;